Merge pull request #2213 from EternalPhane/master

Fix #1855, #2211
This commit is contained in:
Terence Parr 2018-06-16 09:58:25 -07:00 committed by GitHub
commit 98dc2c0f02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -182,3 +182,4 @@ YYYY/MM/DD, github id, Full name, email
2017/12/27, jkmar, Jakub Marciniszyn, marciniszyn.jk@gmail.com
2018/02/11, io7m, Mark Raynsford, code@io7m.com
2018/15/05, johnvanderholt, jan dillingh johnvanderholte@gmail.com
2018/06/16, EternalPhane, Zongyuan Zuo, eternalphane@gmail.com

View File

@ -11,6 +11,3 @@ Any::~Any()
{
delete _ptr;
}
Any::Base::~Base() {
}

View File

@ -100,7 +100,7 @@ struct ANTLR4CPP_PUBLIC Any
private:
struct Base {
virtual ~Base();
virtual ~Base() {};
virtual Base* clone() const = 0;
};
@ -112,10 +112,21 @@ private:
T value;
Base* clone() const {
return clone<>();
}
private:
template<int N = 0, typename std::enable_if<N == N && std::is_nothrow_copy_constructible<T>::value, int>::type = 0>
Base* clone() const {
return new Derived<T>(value);
}
template<int N = 0, typename std::enable_if<N == N && !std::is_nothrow_copy_constructible<T>::value, int>::type = 0>
Base* clone() const {
return nullptr;
}
};
Base* clone() const