From b942ee4ed41edc9ab9a0accbc985da9d6f991a68 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Thu, 12 Dec 2019 22:02:13 +0100 Subject: [PATCH] implicit move construction of values in abstraction::Value --- alib2abstraction/src/abstraction/ValueHolderInterface.hpp | 6 +++--- alib2cli/src/ast/statements/ResultVariableStatement.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/alib2abstraction/src/abstraction/ValueHolderInterface.hpp b/alib2abstraction/src/abstraction/ValueHolderInterface.hpp index 9a94ce2eff..4c35df1cdb 100644 --- a/alib2abstraction/src/abstraction/ValueHolderInterface.hpp +++ b/alib2abstraction/src/abstraction/ValueHolderInterface.hpp @@ -55,7 +55,7 @@ ParamType retrieveValue ( const std::shared_ptr < abstraction::Value > & param, (void) move; using Type = std::decay_t < ParamType >; - std::shared_ptr < ValueHolderInterface < std::decay_t < Type > > > interface = std::dynamic_pointer_cast < ValueHolderInterface < std::decay_t < Type > > > ( param->getProxyAbstraction ( ) ); + std::shared_ptr < ValueHolderInterface < Type > > interface = std::dynamic_pointer_cast < ValueHolderInterface < Type > > ( param->getProxyAbstraction ( ) ); if ( ! interface ) throw std::invalid_argument ( "Abstraction does not provide value of type " + ext::to_string < ParamType > ( ) + " but " + param->getType ( ) + "." ); @@ -80,14 +80,14 @@ ParamType retrieveValue ( const std::shared_ptr < abstraction::Value > & param, return res; } } else if constexpr ( std::is_copy_constructible_v < Type > && ! std::is_move_constructible_v < Type > ) { - if ( ! interface->isConst ( ) && move ) + if ( ! interface->isConst ( ) && ( move || interface->isTemporary ( ) ) ) throw std::domain_error ( "Value not move constructible" ); else { Type && res = interface->getValue ( ); return res; } } else if constexpr ( ! std::is_copy_constructible_v < Type > && std::is_move_constructible_v < Type > ) { - if ( ! interface->isConst ( ) && move ) + if ( ! interface->isConst ( ) && ( move || interface->isTemporary ( ) ) ) return std::move ( interface->getValue ( ) ); else throw std::domain_error ( "Value not copy constructible" ); diff --git a/alib2cli/src/ast/statements/ResultVariableStatement.h b/alib2cli/src/ast/statements/ResultVariableStatement.h index cd623aa24c..461662bd87 100644 --- a/alib2cli/src/ast/statements/ResultVariableStatement.h +++ b/alib2cli/src/ast/statements/ResultVariableStatement.h @@ -13,7 +13,7 @@ public: } std::shared_ptr < abstraction::Value > translateAndEval ( const std::shared_ptr < abstraction::Value > & prev, Environment & environment ) const override { - std::shared_ptr < abstraction::Value > res = prev->clone ( nullptr, abstraction::ParamQualifiers::ParamQualifierSet::NONE, false, true ); + std::shared_ptr < abstraction::Value > res = prev->clone ( nullptr, abstraction::ParamQualifiers::ParamQualifierSet::NONE, false, false ); environment.setVariable ( m_name->eval ( environment ), res ); return res; } -- GitLab