diff --git a/contributors.txt b/contributors.txt index d475526d3..d5ebacd47 100644 --- a/contributors.txt +++ b/contributors.txt @@ -269,6 +269,7 @@ YYYY/MM/DD, github id, Full name, email 2020/06/02, cohomology, Kilian Kilger, kkilger AT gmail.com 2020/06/04, IohannRabeson, Iohann Rabeson, iotaka6@gmail.com 2020/06/04, sigmasoldi3r, Pablo Blanco, pablobc.1995@gmail.com +2020/06/15, mattpaletta, Matthew Paletta, mattpaletta@gmail.com 2020/07/01, sha-N, Shan M Mathews, admin@bluestarqatar.com 2020/08/22, stevenjohnstone, Steven Johnstone, steven.james.johnstone@gmail.com 2020/09/06, ArthurSonzogni, Sonzogni Arthur, arthursonzogni@gmail.com diff --git a/runtime/Cpp/runtime/src/support/Any.h b/runtime/Cpp/runtime/src/support/Any.h index 468db9894..e80bedeb2 100644 --- a/runtime/Cpp/runtime/src/support/Any.h +++ b/runtime/Cpp/runtime/src/support/Any.h @@ -65,16 +65,26 @@ struct ANTLR4CPP_PUBLIC Any return derived->value; } - template + template::value || std::is_copy_assignable::value>::value> operator U() { return as>(); } - template + template::value && !std::is_copy_assignable::value) && (std::is_move_constructible::value || std::is_move_assignable::value)>::value> + operator U() { + return std::move(as>()); + } + + template::value || std::is_copy_assignable::value>::value> operator const U() const { return as>(); } + template::value && !std::is_copy_assignable::value) && (std::is_move_constructible::value || std::is_move_assignable::value)>::value> + operator const U() const { + return std::move(as>()); + } + Any& operator = (const Any& a) { if (_ptr == a._ptr) return *this; @@ -99,7 +109,7 @@ struct ANTLR4CPP_PUBLIC Any virtual ~Any(); - virtual bool equals(Any other) const { + virtual bool equals(const Any& other) const { return _ptr == other._ptr; }