Skip to content

Commit 77cd2df

Browse files
committed
Support moving from the contained value in value_to_function in more cases
1 parent 7a0f5e3 commit 77cd2df

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

source/bounded/value_to_function.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace bounded {
1111

1212
export template<typename T>
1313
struct value_to_function {
14+
static_assert(std::is_reference_v<T>);
15+
1416
constexpr explicit value_to_function(T && ref) noexcept:
1517
m_ptr(std::addressof(ref))
1618
{
@@ -19,8 +21,8 @@ struct value_to_function {
1921
constexpr auto operator()() const & noexcept -> T & {
2022
return *m_ptr;
2123
}
22-
constexpr auto operator()() && noexcept -> T && {
23-
return static_cast<T &&>(*m_ptr);
24+
constexpr auto operator()() const && noexcept -> T {
25+
return static_cast<T>(*m_ptr);
2426
}
2527

2628
private:

0 commit comments

Comments
 (0)