diff --git a/alib2abstraction/src/abstraction/ValueHolderInterface.hpp b/alib2abstraction/src/abstraction/ValueHolderInterface.hpp index 1995d0130fe4453054eaf36f5fb40133942633f9..aa6849fa937c2d4bf000066ed9178d3b9acf224a 100644 --- a/alib2abstraction/src/abstraction/ValueHolderInterface.hpp +++ b/alib2abstraction/src/abstraction/ValueHolderInterface.hpp @@ -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 > ) {