Skip to content

Commit 115baba

Browse files
Define an add_const utility function
This is useful in particular when we want to force the const version of a method to be called. For exprt there can be differences in performance between const and non-const.
1 parent eabc411 commit 115baba

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/util/add_const.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*******************************************************************\
2+
3+
Module: Util
4+
5+
Author: Romain Brenguier, [email protected]
6+
7+
\*******************************************************************/
8+
9+
#ifndef CPROVER_UTIL_ADD_CONST_H
10+
#define CPROVER_UTIL_ADD_CONST_H
11+
12+
/// Return a reference to the same object but ensures the type is const
13+
template <typename T>
14+
const T &add_const(T &value)
15+
{
16+
return static_cast<const T &>(value);
17+
}
18+
19+
#endif // CPROVER_UTIL_ADD_CONST_H

0 commit comments

Comments
 (0)