diff options
author | Joe George <joe@zeroc.com> | 2021-03-29 10:01:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-29 10:01:10 -0400 |
commit | c095b7f9c123e1b07bf3844e7aaad9bb1a56d143 (patch) | |
tree | b31a58b033e02a10f47279985f59247839efdd65 /cpp/src/slice2cpp/Gen.cpp | |
parent | Fix whitespace (diff) | |
download | ice-c095b7f9c123e1b07bf3844e7aaad9bb1a56d143.tar.bz2 ice-c095b7f9c123e1b07bf3844e7aaad9bb1a56d143.tar.xz ice-c095b7f9c123e1b07bf3844e7aaad9bb1a56d143.zip |
Support for building C++98 with a C++11 compiler (#1267)
Fixes #1266
Diffstat (limited to 'cpp/src/slice2cpp/Gen.cpp')
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index fdabfd205e0..29b353e8e19 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -1383,7 +1383,24 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) } H << allParamDecls << epar << ';'; } + + H.zeroIndent(); + H << sp << nl << "#ifdef ICE_CPP11_COMPILER"; + H.restoreIndent(); + H << nl << name << "(const " << name << "&) = default;"; + H << nl << name << "& operator=(const " << name << "&) = default;"; + H << nl << "virtual ~" << name << "();"; + + H.zeroIndent(); + H << nl << "#else"; + H.restoreIndent(); + H << nl << "virtual ~" << name << "() throw();"; + + H.zeroIndent(); + H << nl << "#endif"; + H.restoreIndent(); + H << sp; if(!p->isLocal()) @@ -1478,11 +1495,28 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) C << eb; } - C << sp << nl; + C.zeroIndent(); + C << sp << nl << "#ifdef ICE_CPP11_COMPILER"; + C.restoreIndent(); + + C << nl; + C << scoped.substr(2) << "::~" << name << "()"; + C << sb; + C << eb; + + C.zeroIndent(); + C << nl << "#else"; + C.restoreIndent(); + + C << nl; C << scoped.substr(2) << "::~" << name << "() throw()"; C << sb; C << eb; + C.zeroIndent(); + C << nl << "#endif"; + C.restoreIndent(); + H << nl << "/**"; H << nl << " * Obtains the Slice type ID of this exception."; H << nl << " * @return The fully-scoped type ID."; @@ -2966,6 +3000,21 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) emitOneShotConstructor(p); } + H.zeroIndent(); + H << sp << nl << "#ifdef ICE_CPP11_COMPILER"; + H.restoreIndent(); + if (p->isInterface()) + { + // If this is not an interface it's defined above + H << nl << name << "() = default;"; + } + H << nl << name << "(const " << name << "&) = default;"; + H << nl << name << "& operator=(const " << name << "&) = default;"; + + H.zeroIndent(); + H << nl << "#endif"; + H.restoreIndent(); + if(!p->isLocal()) { C << sp; |