Skip to content

Commit 9cd1e56

Browse files
Delete as_const on xvalue
This is done similarly to the standard library (C++17) to avoid returning a reference to a temporary value which may have been destroyed.
1 parent 00f125f commit 9cd1e56

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/util/as_const.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ const T &as_const(T &value)
1616
return static_cast<const T &>(value);
1717
}
1818

19+
/// Deleted to avoid calling as_const on an xvalue
20+
template <typename T>
21+
void as_const(T &&) = delete;
22+
1923
#endif // CPROVER_UTIL_AS_CONST_H

0 commit comments

Comments
 (0)