Merge pull request #2849 from mattpaletta/master
Added templated move support for antlrcpp::Any
This commit is contained in:
commit
e404d26f61
|
@ -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
|
||||
|
|
|
@ -65,16 +65,26 @@ struct ANTLR4CPP_PUBLIC Any
|
|||
return derived->value;
|
||||
}
|
||||
|
||||
template<class U>
|
||||
template<class U, typename std::enable_if<std::is_copy_constructible<U>::value || std::is_copy_assignable<U>::value>::value>
|
||||
operator U() {
|
||||
return as<StorageType<U>>();
|
||||
}
|
||||
|
||||
template<class U>
|
||||
template<class U, typename std::enable_if<(!std::is_copy_constructible<U>::value && !std::is_copy_assignable<U>::value) && (std::is_move_constructible<U>::value || std::is_move_assignable<U>::value)>::value>
|
||||
operator U() {
|
||||
return std::move(as<StorageType<U>>());
|
||||
}
|
||||
|
||||
template<class U, typename std::enable_if<std::is_copy_constructible<U>::value || std::is_copy_assignable<U>::value>::value>
|
||||
operator const U() const {
|
||||
return as<const StorageType<U>>();
|
||||
}
|
||||
|
||||
template<class U, typename std::enable_if<!(!std::is_copy_constructible<U>::value && !std::is_copy_assignable<U>::value) && (std::is_move_constructible<U>::value || std::is_move_assignable<U>::value)>::value>
|
||||
operator const U() const {
|
||||
return std::move(as<const StorageType<U>>());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue