14template <
class Type >
25template <
class ParamType >
26ParamType
retrieveValue (
const std::shared_ptr < abstraction::Value > & param,
bool move =
false ) {
27 using Type = std::decay_t < ParamType >;
29 std::shared_ptr < ValueHolderInterface < Type > >
interface = std::dynamic_pointer_cast <
ValueHolderInterface <
Type > > ( param->getProxyAbstraction ( ) );
31 throw std::invalid_argument (
"Abstraction does not provide value of type " + ext::to_string < ParamType > ( ) +
" but " + param->getType ( ) +
"." );
38 if constexpr ( std::is_rvalue_reference_v < ParamType > ) {
39 if ( param->isTemporary ( ) || move )
40 return std::move ( interface->getValue ( ) );
42 throw std::domain_error (
"Cannot bind without move" );
43 }
else if constexpr ( std::is_lvalue_reference_v < ParamType > && std::is_const_v < std::remove_reference_t < ParamType > > ) {
44 Type &&
res = interface->getValue ( );
46 }
else if constexpr ( std::is_lvalue_reference_v < ParamType > ) {
48 throw std::domain_error (
"Cannot bind temporary to non-const reference" );
49 Type &&
res = interface->getValue ( );
51 }
else if constexpr ( std::is_copy_constructible_v < Type > && std::is_move_constructible_v < Type > ) {
53 return std::move ( interface->getValue ( ) );
55 const Type &
res = interface->getValue ( );
58 }
else if constexpr ( std::is_copy_constructible_v < Type > && ! std::is_move_constructible_v < Type > ) {
60 throw std::domain_error (
"Value not move constructible" );
62 Type &&
res = interface->getValue ( );
65 }
else if constexpr ( ! std::is_copy_constructible_v < Type > && std::is_move_constructible_v < Type > ) {
67 return std::move ( interface->getValue ( ) );
69 throw std::domain_error (
"Value not copy constructible" );
72 throw std::domain_error (
"Value not move constructible" );
74 throw std::domain_error (
"Value not copy constructible" );
static constexpr bool isConst(TypeQualifierSet arg)
Definition: TypeQualifiers.hpp:35
static constexpr bool isRef(TypeQualifierSet arg)
Definition: TypeQualifiers.hpp:39
Definition: ValueHolderInterface.hpp:15
virtual void setValue(const Type &)=0
virtual Type && getValue()=0
Definition: AlgorithmAbstraction.hpp:11
ParamType retrieveValue(const std::shared_ptr< abstraction::Value > ¶m, bool move=false)
Definition: ValueHolderInterface.hpp:26
return res
Definition: MinimizeByPartitioning.h:145
Type
Definition: MeasurementTypes.hpp:20