Skip to content
Snippets Groups Projects
Commit f52865b5 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

disallow temporaries to bind to non-const references

parent 0c103b06
No related branches found
No related tags found
1 merge request!118Merge jt
Pipeline #56551 passed with warnings
......@@ -29,6 +29,10 @@ public:
return m_isConst;
}
 
bool isRef ( ) const {
return isRvalueRef ( ) || isLvalueRef ( );
}
bool isRvalueRef ( ) const {
return m_isRvalueRef;
}
......@@ -73,7 +77,12 @@ ParamType retrieveValue ( const std::shared_ptr < abstraction::Value > & param,
return std::move ( interface->getValue ( ) );
else
throw std::domain_error ( "Cannot bind without move" );
} else if constexpr ( std::is_lvalue_reference_v < ParamType > && std::is_const_v < std::remove_reference_t < ParamType > > ) {
Type && res = interface->getValue ( );
return res;
} else if constexpr ( std::is_lvalue_reference_v < ParamType > ) {
if ( interface->isAutoMove ( ) && ! interface->isRef ( ) )
throw std::domain_error ( "Cannot bind temporary to non-const reference" );
Type && res = interface->getValue ( );
return res;
} else if constexpr ( std::is_copy_constructible_v < Type > && std::is_move_constructible_v < Type > ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment