aboutsummaryrefslogtreecommitdiff
path: root/xsd/cxx/tree/stream-extraction-source.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-01-19 10:05:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2014-01-19 10:06:32 +0200
commit0fdf19714613a82a184f4f6e75fb9a4f9b62f18a (patch)
tree93bb2df0f9d9eab44d36dedf29d4df500ecefcbc /xsd/cxx/tree/stream-extraction-source.cxx
parent45db924dfc19b49b7930522dbddd123fb9575e32 (diff)
Use std::unique_ptr instead of std::auto_ptr in C++11 mode
Diffstat (limited to 'xsd/cxx/tree/stream-extraction-source.cxx')
-rw-r--r--xsd/cxx/tree/stream-extraction-source.cxx39
1 files changed, 21 insertions, 18 deletions
diff --git a/xsd/cxx/tree/stream-extraction-source.cxx b/xsd/cxx/tree/stream-extraction-source.cxx
index 4704fb3..05e47b5 100644
--- a/xsd/cxx/tree/stream-extraction-source.cxx
+++ b/xsd/cxx/tree/stream-extraction-source.cxx
@@ -337,6 +337,11 @@ namespace CXX
//
bool poly (polymorphic && polymorphic_p (t) && !anonymous_p (t));
+ char const* r (
+ (poly || !fund) && std >= cxx_version::cxx11
+ ? "::std::move (r)"
+ : "r");
+
if (max (e) != 1)
{
// sequence
@@ -358,14 +363,14 @@ namespace CXX
if (poly)
{
os << "bool d;"
- << "::std::auto_ptr< " << type << " > r;"
+ << auto_ptr << "< " << type << " > r;"
<< "s >> d;"
<< endl
<< "if (!d)" << endl
<< "r.reset (new " << type << " (s, f, this));"
<< "else"
<< "{"
- << "::std::auto_ptr< ::xsd::cxx::tree::type > tmp (" << endl
+ << auto_ptr << "< ::xsd::cxx::tree::type > tmp (" << endl
<< "::xsd::cxx::tree::stream_extraction_map_instance< " <<
poly_plate << ", " << stream << ", " << char_type <<
" > ().extract (" << endl
@@ -385,11 +390,11 @@ namespace CXX
}
else
{
- os << "::std::auto_ptr< " << type << " > r (new " << type <<
+ os << auto_ptr << "< " << type << " > r (new " << type <<
" (s, f, this));";
}
- os << "c.push_back (r);"
+ os << "c.push_back (" << r << ");"
<< "}" // while
<< "}" // if
<< "}";
@@ -407,14 +412,14 @@ namespace CXX
if (poly)
{
os << "bool d;"
- << "::std::auto_ptr< " << type << " > r;"
+ << auto_ptr << "< " << type << " > r;"
<< "s >> d;"
<< endl
<< "if (!d)" << endl
<< "r.reset (new " << type << " (s, f, this));"
<< "else"
<< "{"
- << "::std::auto_ptr< ::xsd::cxx::tree::type > tmp (" << endl
+ << auto_ptr << "< ::xsd::cxx::tree::type > tmp (" << endl
<< "::xsd::cxx::tree::stream_extraction_map_instance< " <<
poly_plate << ", " << stream << ", " << char_type <<
" > ().extract (" << endl
@@ -434,11 +439,11 @@ namespace CXX
}
else
{
- os << "::std::auto_ptr< " << type << " > r (new " << type <<
+ os << auto_ptr << "< " << type << " > r (new " << type <<
" (s, f, this));";
}
- os << "this->" << member << ".set (r);"
+ os << "this->" << member << ".set (" << r << ");"
<< "}" // if (p)
<< "}";
}
@@ -451,14 +456,14 @@ namespace CXX
if (poly)
{
os << "bool d;"
- << "::std::auto_ptr< " << type << " > r;"
+ << auto_ptr << "< " << type << " > r;"
<< "s >> d;"
<< endl
<< "if (!d)" << endl
<< "r.reset (new " << type << " (s, f, this));"
<< "else"
<< "{"
- << "::std::auto_ptr< ::xsd::cxx::tree::type > tmp (" << endl
+ << auto_ptr << "< ::xsd::cxx::tree::type > tmp (" << endl
<< "::xsd::cxx::tree::stream_extraction_map_instance< " <<
poly_plate << ", " << stream << ", " << char_type <<
" > ().extract (" << endl
@@ -478,11 +483,11 @@ namespace CXX
}
else
{
- os << "::std::auto_ptr< " << type << " > r (new " << type <<
+ os << auto_ptr << "< " << type << " > r (new " << type <<
" (s, f, this));";
}
- os << "this->" << member << ".set (r);"
+ os << "this->" << member << ".set (" << r << ");"
<< "}";
}
}
@@ -526,9 +531,8 @@ namespace CXX
}
else
{
- os << "::std::auto_ptr< " << type << " > r (new " << type <<
- " (s, f, this));"
- << "this->" << member << ".set (r);";
+ os << "this->" << member << ".set (" << auto_ptr << "< " <<
+ type << " > (new " << type << " (s, f, this)));";
}
os << "}" // if (p)
@@ -546,9 +550,8 @@ namespace CXX
}
else
{
- os << "::std::auto_ptr< " << type << " > r (new " << type <<
- " (s, f, this));"
- << "this->" << member << ".set (r);";
+ os << "this->" << member << ".set (" << auto_ptr << "< " <<
+ type << " > (new " << type << " (s, f, this)));";
}
os << "}";