I have something that can be compiled in gcc 4.9, but failed in gcc 4.7.
It is a class which has move constructor, but I set its copy constructor to private:
class Option
{
public:
Option(const std::string& name_long,
char name_short,
const std::string& group,
bool* value_store,
int32_t flags,
const std::string& option_desc);
// and several similar constructors
Option(Option&& other);
private:
Option(const Option& other);
};
The issue occurs when it is called by vector's emplace_back()
function:
// options is a std::vector<Option>
options.emplace_back("help", 'h', OPTION_GROUP_MISC,
&opt_show_help, htio2::Option::FLAG_NONE,
"Show help and exit.");
This successfully compiles and works well by gcc 4.9, but gcc 4.7 claims a two-screen-long error, claiming that its copy constructor is private:
In file included from /public/yx/works/writing_tcrklass2/src/TCRklass2-1.90.0-Source/src/tcrk2/App.h:4:0,
from /public/yx/works/writing_tcrklass2/src/TCRklass2-1.90.0-Source/src/tcrk2/App.cpp:1:
......
/public/yx/works/writing_tcrklass2/src/TCRklass2-1.90.0-Source/src/tcrk2/App.cpp:58:47: required from here
/usr/local/include/htio2/OptionParser.h:188:5: error: ‘htio2::Option::Option(const htio2::Option&)’ is private
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/move.h:57:0,
......
/usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/type_traits:762:43: error: within this context
As some of my users has very old system, which is probably using old version of compilers, I really want to know if is there any way to work around it.
Aucun commentaire:
Enregistrer un commentaire