From 9bf40e4a91f6a792c3279d9184b67451cf58bf49 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 9 Dec 2015 18:02:40 +0200 Subject: Add --std option with c++{98,11,14} values; use function-static in C++11 This way we can use option descriptions during static initialization (e.g., of an Apache module). --- cli/source.cxx | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'cli/source.cxx') diff --git a/cli/source.cxx b/cli/source.cxx index 38df449..eae40dc 100644 --- a/cli/source.cxx +++ b/cli/source.cxx @@ -924,23 +924,20 @@ namespace { string desc ("_cli_" + name + "_desc"); - os << "static " << cli << "::options " << desc << "_;" - << endl; - - os << "struct " << desc << "_init" + os << "struct " << desc << "_type: " << cli << "::options" << "{" - << desc << "_init (" << cli << "::options& os)" + << desc << "_type ()" << "{" - << name << "::fill (os);" + << fq_name (c) << "::fill (*this);" << "}" << "};"; - os << "static " << desc << "_init " << desc << "_init_ (" << - desc << "_);" - << endl; + if (options.std () < cxx_version::cxx11) + os << "static " << desc << "_type " << desc << "_;" + << endl; os << "void " << name << "::" << endl - << "fill (" << cli << "::options& " << (ho || hb ? " os)" : ")") + << "fill (" << cli << "::options&" << (ho || hb ? " os)" : ")") << "{"; // Add the entries from our bases first so that our entires @@ -953,8 +950,12 @@ namespace os << "const " << cli << "::options& " << name << "::" << endl << "description ()" - << "{" - << "return " << desc << "_;" + << "{"; + + if (options.std () >= cxx_version::cxx11) + os << "static ::" << desc << "_type " << desc << "_;"; + + os << "return " << desc << "_;" << "};"; } -- cgit v1.1