From 0fdf19714613a82a184f4f6e75fb9a4f9b62f18a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 19 Jan 2014 10:05:08 +0200 Subject: Use std::unique_ptr instead of std::auto_ptr in C++11 mode --- NEWS | 7 + doc/cxx/parser/guide/index.xhtml | 83 +++--- doc/cxx/tree/guide/index.xhtml | 80 +++-- doc/cxx/tree/manual/index.xhtml | 228 ++++++++++----- doc/cxx/tree/reference/libxsd.doxygen | 12 +- libxsd/xsd/cxx/auto-array.hxx | 22 +- libxsd/xsd/cxx/config.hxx | 35 ++- libxsd/xsd/cxx/parser/expat/elements.hxx | 25 +- libxsd/xsd/cxx/parser/expat/elements.txx | 8 +- .../cxx/parser/non-validating/xml-schema-pimpl.hxx | 6 +- .../cxx/parser/non-validating/xml-schema-pimpl.txx | 8 +- .../cxx/parser/non-validating/xml-schema-pskel.hxx | 8 +- .../xsd/cxx/parser/validating/xml-schema-pimpl.hxx | 10 +- .../xsd/cxx/parser/validating/xml-schema-pimpl.txx | 16 +- .../xsd/cxx/parser/validating/xml-schema-pskel.hxx | 8 +- libxsd/xsd/cxx/parser/xerces/elements.hxx | 6 +- libxsd/xsd/cxx/parser/xerces/elements.txx | 16 +- libxsd/xsd/cxx/tree/ace-cdr-stream-extraction.hxx | 38 ++- libxsd/xsd/cxx/tree/containers.hxx | 33 ++- libxsd/xsd/cxx/tree/containers.txx | 21 +- libxsd/xsd/cxx/tree/element-map.hxx | 10 +- libxsd/xsd/cxx/tree/elements.hxx | 131 ++++----- libxsd/xsd/cxx/tree/istream.hxx | 6 +- libxsd/xsd/cxx/tree/ostream.hxx | 6 +- libxsd/xsd/cxx/tree/parsing.txx | 18 +- libxsd/xsd/cxx/tree/parsing/element-map.txx | 6 +- libxsd/xsd/cxx/tree/stream-extraction-map.hxx | 10 +- libxsd/xsd/cxx/tree/stream-extraction-map.txx | 6 +- libxsd/xsd/cxx/tree/stream-extraction.hxx | 3 +- libxsd/xsd/cxx/tree/type-factory-map.hxx | 16 +- libxsd/xsd/cxx/tree/type-factory-map.txx | 13 +- libxsd/xsd/cxx/tree/type-serializer-map.hxx | 3 +- libxsd/xsd/cxx/tree/type-serializer-map.txx | 2 +- libxsd/xsd/cxx/tree/types.txx | 20 +- libxsd/xsd/cxx/xml/char-iso8859-1.txx | 15 +- libxsd/xsd/cxx/xml/char-lcp.txx | 24 +- libxsd/xsd/cxx/xml/char-utf8.txx | 15 +- libxsd/xsd/cxx/xml/dom/auto-ptr.hxx | 80 ++++- libxsd/xsd/cxx/xml/dom/parsing-source.hxx | 9 +- libxsd/xsd/cxx/xml/dom/parsing-source.txx | 16 +- libxsd/xsd/cxx/xml/dom/serialization-source.hxx | 4 +- libxsd/xsd/cxx/xml/dom/serialization-source.txx | 8 +- libxsd/xsd/cxx/xml/dom/wildcard-source.hxx | 2 +- libxsd/xsd/cxx/xml/dom/wildcard-source.txx | 4 +- libxsd/xsd/cxx/xml/std-memory-manager.hxx | 11 + libxsd/xsd/cxx/xml/string.hxx | 13 +- libxsd/xsd/cxx/xml/string.txx | 16 +- tests/cxx/parser/built-in/driver.cxx | 6 +- tests/cxx/parser/built-in/makefile | 5 + tests/cxx/parser/enumeration/makefile | 5 + tests/cxx/parser/generated-impl/makefile | 5 + tests/cxx/parser/list/makefile | 5 + tests/cxx/parser/name-clash/inheritance/makefile | 5 + tests/cxx/parser/polymorphism/recursive/makefile | 5 + tests/cxx/parser/polymorphism/same-type/makefile | 5 + tests/cxx/parser/recursive/makefile | 5 + tests/cxx/parser/test-template/makefile | 5 + tests/cxx/parser/union/makefile | 5 + tests/cxx/parser/validation/all/makefile | 5 + tests/cxx/parser/validation/any/makefile | 5 + tests/cxx/parser/validation/attribute/makefile | 5 + .../parser/validation/built-in/any-type/makefile | 5 + .../cxx/parser/validation/built-in/binary/makefile | 7 + .../parser/validation/built-in/boolean/makefile | 7 + tests/cxx/parser/validation/built-in/byte/makefile | 7 + .../parser/validation/built-in/date-time/makefile | 7 + .../cxx/parser/validation/built-in/float/makefile | 7 + tests/cxx/parser/validation/built-in/int/makefile | 7 + .../parser/validation/built-in/integer/makefile | 7 + tests/cxx/parser/validation/built-in/long/makefile | 7 + .../cxx/parser/validation/built-in/qname/makefile | 7 + .../cxx/parser/validation/built-in/short/makefile | 7 + .../cxx/parser/validation/built-in/string/makefile | 7 + tests/cxx/parser/validation/built-in/uri/makefile | 7 + tests/cxx/parser/validation/choice/makefile | 5 + tests/cxx/parser/validation/restriction/makefile | 5 + tests/cxx/parser/validation/sequence/makefile | 5 + tests/cxx/tree/binary/cdr/driver.cxx | 6 +- tests/cxx/tree/binary/cdr/makefile | 5 + tests/cxx/tree/binary/polymorphic/driver.cxx | 6 +- tests/cxx/tree/binary/polymorphic/makefile | 5 + tests/cxx/tree/binary/xdr/driver.cxx | 6 +- tests/cxx/tree/binary/xdr/makefile | 5 + tests/cxx/tree/built-in/driver.cxx | 19 +- tests/cxx/tree/built-in/makefile | 5 + tests/cxx/tree/chameleon/driver.cxx | 4 +- tests/cxx/tree/chameleon/makefile | 5 + tests/cxx/tree/comparison/driver.cxx | 4 +- tests/cxx/tree/comparison/makefile | 5 + tests/cxx/tree/compilation/driver.cxx | 1 - tests/cxx/tree/compilation/makefile | 5 + tests/cxx/tree/complex/ctor/driver.cxx | 50 ++-- tests/cxx/tree/complex/ctor/makefile | 6 +- tests/cxx/tree/containment/driver.cxx | 45 +-- tests/cxx/tree/containment/makefile | 5 + tests/cxx/tree/default/general/driver.cxx | 4 +- tests/cxx/tree/default/general/makefile | 5 + tests/cxx/tree/default/omit/driver.cxx | 4 +- tests/cxx/tree/default/omit/makefile | 5 + tests/cxx/tree/detach/driver.cxx | 23 +- tests/cxx/tree/detach/makefile | 5 + tests/cxx/tree/dom-association/dom-parse.cxx | 97 ++++++ tests/cxx/tree/dom-association/dom-parse.hxx | 25 ++ tests/cxx/tree/dom-association/driver.cxx | 73 +++++ tests/cxx/tree/dom-association/makefile | 93 ++++++ tests/cxx/tree/dom-association/output | 0 tests/cxx/tree/dom-association/test.xml | 7 + tests/cxx/tree/dom-association/test.xsd | 12 + tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx | 4 +- tests/cxx/tree/encoding/char/iso-8859-1/makefile | 5 + tests/cxx/tree/encoding/char/lcp/driver.cxx | 4 +- tests/cxx/tree/encoding/char/lcp/makefile | 5 + tests/cxx/tree/encoding/char/utf-8/driver.cxx | 4 +- tests/cxx/tree/encoding/char/utf-8/makefile | 5 + tests/cxx/tree/encoding/wchar/driver.cxx | 4 +- tests/cxx/tree/encoding/wchar/makefile | 5 + tests/cxx/tree/enumeration/ctor/makefile | 5 + tests/cxx/tree/enumeration/inheritance/driver.cxx | 4 +- tests/cxx/tree/enumeration/inheritance/makefile | 5 + tests/cxx/tree/float/driver.cxx | 4 +- tests/cxx/tree/float/makefile | 5 + tests/cxx/tree/list/ctor/makefile | 5 + tests/cxx/tree/makefile | 41 +-- tests/cxx/tree/name-clash/inheritance/driver.cxx | 4 +- tests/cxx/tree/name-clash/inheritance/makefile | 5 + tests/cxx/tree/naming/camel/driver.cxx | 1 - tests/cxx/tree/naming/camel/makefile | 5 + tests/cxx/tree/naming/java/driver.cxx | 1 - tests/cxx/tree/naming/java/makefile | 5 + tests/cxx/tree/naming/knr/driver.cxx | 1 - tests/cxx/tree/naming/knr/makefile | 5 + tests/cxx/tree/polymorphism/comparison/driver.cxx | 4 +- tests/cxx/tree/polymorphism/comparison/makefile | 5 + tests/cxx/tree/polymorphism/ostream/driver.cxx | 4 +- tests/cxx/tree/polymorphism/ostream/makefile | 5 + tests/cxx/tree/polymorphism/same-type/driver.cxx | 4 +- tests/cxx/tree/polymorphism/same-type/makefile | 5 + tests/cxx/tree/prefix/driver.cxx | 4 +- tests/cxx/tree/prefix/makefile | 5 + tests/cxx/tree/test-template/driver.cxx | 4 +- tests/cxx/tree/test-template/makefile | 5 + tests/cxx/tree/types-only/driver.cxx | 1 - tests/cxx/tree/types-only/makefile | 5 + tests/cxx/tree/union/ctor/makefile | 5 + tests/cxx/tree/wildcard/driver.cxx | 10 +- tests/cxx/tree/wildcard/makefile | 5 + xsd/cxx/elements.cxx | 15 +- xsd/cxx/elements.hxx | 9 + xsd/cxx/options.cli | 18 +- xsd/cxx/parser/attribute-validation-source.cxx | 2 +- xsd/cxx/parser/element-validation-source.cxx | 2 +- xsd/cxx/parser/generator.cxx | 12 +- xsd/cxx/parser/parser-header.cxx | 4 +- xsd/cxx/parser/print-impl-common.hxx | 2 +- xsd/cxx/tree/elements.cxx | 61 ++-- xsd/cxx/tree/elements.hxx | 53 ++-- xsd/cxx/tree/fundamental-header.hxx | 11 +- xsd/cxx/tree/generator.cxx | 111 ++++--- xsd/cxx/tree/parser-header.cxx | 30 +- xsd/cxx/tree/parser-source.cxx | 102 +++---- xsd/cxx/tree/stream-extraction-source.cxx | 39 +-- xsd/cxx/tree/tree-header.cxx | 63 ++-- xsd/cxx/tree/tree-inline.cxx | 21 +- xsd/cxx/tree/tree-source.cxx | 324 +++++++++++++-------- 164 files changed, 2078 insertions(+), 856 deletions(-) create mode 100644 tests/cxx/tree/dom-association/dom-parse.cxx create mode 100644 tests/cxx/tree/dom-association/dom-parse.hxx create mode 100644 tests/cxx/tree/dom-association/driver.cxx create mode 100644 tests/cxx/tree/dom-association/makefile create mode 100644 tests/cxx/tree/dom-association/output create mode 100644 tests/cxx/tree/dom-association/test.xml create mode 100644 tests/cxx/tree/dom-association/test.xsd diff --git a/NEWS b/NEWS index e5d63ba..54a956b 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,13 @@ Version 4.0.0 * New option, --std, specifies the C++ standard that the generated code should conform to. Valid values are c++98 (default) and c++11. + The C++ standard affects various aspects of the generated code that + are discussed in more detail in various mapping-specific documentation. + Overall, when C++11 is selected, the generated code relies on the move + semantics and uses std::unique_ptr instead of deprecated std::auto_ptr. + See also the documentation for the --std option in the XSD compiler + command line manual (man pages). + * New option, --fat-type-file, triggers the generation of code corresponding to global elements into type files instead of schema files in the file-per-type mode. This option is primarily useful diff --git a/doc/cxx/parser/guide/index.xhtml b/doc/cxx/parser/guide/index.xhtml index a01b9a7..fff36cb 100644 --- a/doc/cxx/parser/guide/index.xhtml +++ b/doc/cxx/parser/guide/index.xhtml @@ -280,10 +280,11 @@ 5Mapping Configuration - - - - + + + + +
5.1Character Type and Encoding
5.2Underlying XML Parser
5.3XML Schema Validation
5.4Support for Polymorphism
5.1C++ Standard
5.2Character Type and Encoding
5.3Underlying XML Parser
5.4XML Schema Validation
5.5Support for Polymorphism
@@ -553,8 +554,8 @@ $ xsd cxx-parser --xml-parser expat hello.xsd

The --xml-parser option indicates that we want to - use Expat as the underlying XML parser (see Section - 5.2, "Underlying XML Parser"). The XSD compiler produces two + use Expat as the underlying XML parser (see Section + 5.3, "Underlying XML Parser"). The XSD compiler produces two C++ files: hello-pskel.hxx and hello-pskel.cxx. The following code fragment is taken from hello-pskel.hxx; it should give you an idea about what gets generated: @@ -1615,8 +1616,13 @@ namespace http://www.example.com/xmlns/my following map files. The string-based XML Schema types are mapped to either std::string or std::wstring depending on the character type - selected (see Section 5.1, "Character Type and - Encoding" for more information).

+ selected (see Section 5.2, "Character Type and + Encoding" for more information). The binary XML Schema + types are mapped to either std::auto_ptr<xml_schema::buffer> + or std::unique_ptr<xml_schema::buffer> + depending on the C++ standard selected (C++98 or C++11, + respectively; refer to the --std XSD compiler + command line option for details).

 namespace http://www.w3.org/2001/XMLSchema
@@ -1663,10 +1669,10 @@ namespace http://www.w3.org/2001/XMLSchema
 
   QName xml_schema::qname;
 
-  base64Binary std::auto_ptr<xml_schema::buffer>
-               std::auto_ptr<xml_schema::buffer>;
-  hexBinary std::auto_ptr<xml_schema::buffer>
-            std::auto_ptr<xml_schema::buffer>;
+  base64Binary std::[auto|unique]_ptr<xml_schema::buffer>
+               std::[auto|unique]_ptr<xml_schema::buffer>;
+  hexBinary std::[auto|unique]_ptr<xml_schema::buffer>
+            std::[auto|unique]_ptr<xml_schema::buffer>;
 
   date xml_schema::date;
   dateTime xml_schema::date_time;
@@ -1899,9 +1905,9 @@ age:    28
   

The C++/Parser mapping has a number of configuration parameters that determine the overall properties and behavior of the generated code. Configuration parameters are specified with the XSD command line - options and include the character type that is used by the generated - code, the underlying XML parser, whether the XML Schema validation - is performed in the generated code, and support for XML Schema + options and include the C++ standard, the character type that is used + by the generated code, the underlying XML parser, whether the XML Schema + validation is performed in the generated code, and support for XML Schema polymorphism. This chapter describes these configuration parameters in more detail. For more ways to configure the generated code refer to the @@ -1909,7 +1915,16 @@ age: 28 Compiler Command Line Manual.

-

5.1 Character Type and Encoding

+

5.1 C++ Standard

+ +

The C++/Parser mapping provides support for ISO/IEC C++ 1998/2003 (C++98) + and ISO/IEC C++ 2011 (C++11). To select the C++ standard for the + generated code we use the --std XSD compiler command + line option. While the majority of the examples in this guide use + C++98, support for the new functionality and library components + introduced in C++11 are discussed throughout the document.

+ +

5.2 Character Type and Encoding

The C++/Parser mapping has built-in support for two character types: char and wchar_t. You can select the @@ -1940,7 +1955,7 @@ age: 28 all three (object mode, input XML, and output XML) can have different encodings.

-

5.2 Underlying XML Parser

+

5.3 Underlying XML Parser

The C++/Parser mapping can be used with either Xerces-C++ or Expat as the underlying XML parser. You can select the XML parser with @@ -1954,7 +1969,7 @@ age: 28 in Chapter 7, "Document Parser and Error Handling".

-

5.3 XML Schema Validation

+

5.4 XML Schema Validation

The C++/Parser mapping provides support for validating a commonly-used subset of W3C XML Schema in the generated code. @@ -1963,14 +1978,14 @@ age: 28

By default validation in the generated code is disabled if the underlying XML parser is validating (Xerces-C++) and - enabled otherwise (Expat). See Section 5.2, + enabled otherwise (Expat). See Section 5.3, "Underlying XML Parser" for more information about the underlying XML parser. You can override the default behavior with the --generate-validation and --suppress-validation command line options.

-

5.4 Support for Polymorphism

+

5.5 Support for Polymorphism

By default the XSD compiler generates non-polymorphic code. If your vocabulary uses XML Schema polymorphism in the form of xsi:type @@ -2587,14 +2602,14 @@ private: base64Binary base64_binary_pimpl - std::auto_ptr<xml_schema::buffer>
+ std::[auto|unique]_ptr< xml_schema::buffer>
Section 6.3, "base64Binary and hexBinary Parsers" hexBinary hex_binary_pimpl - std::auto_ptr<xml_schema::buffer>
+ std::[auto|unique]_ptr< xml_schema::buffer>
Section 6.3, "base64Binary and hexBinary Parsers" @@ -2738,10 +2753,12 @@ namespace xml_schema

6.3 base64Binary and hexBinary Parsers

The return type of the base64_binary_pimpl and - hex_binary_pimpl parser implementations is - std::auto_ptr<xml_schema::buffer>. The - xml_schema::buffer type represents a binary buffer - and its interface is presented below.

+ hex_binary_pimpl parser implementations is either + std::auto_ptr<xml_schema::buffer> (C++98) or + std::unique_ptr<xml_schema::buffer> (C++11), + depending on the C++ standard selected (--std XSD + compiler option). The xml_schema::buffer type + represents a binary buffer and its interface is presented below.

 namespace xml_schema
@@ -3304,7 +3321,7 @@ namespace xml_schema
      in more detail. As mentioned in Section 3.4,
      "Connecting the Parsers Together", the interface of
      xml_schema::document depends on the underlying XML
-     parser selected (Section 5.2, "Underlying XML
+     parser selected (Section 5.3, "Underlying XML
      Parser"). The following sections describe the
      document type interface for Xerces-C++ and
      Expat as underlying parsers.

@@ -3315,7 +3332,7 @@ namespace xml_schema document type has the following interface. Note that if the character type is wchar_t, then the string type in the interface becomes std::wstring - (see Section 5.1, "Character Type and Encoding").

+ (see Section 5.2, "Character Type and Encoding").

 namespace xml_schema
@@ -3577,7 +3594,7 @@ namespace xml_schema
      polymorphic, specifies whether the XML documents
      being parsed use polymorphism. For more information on support
      for XML Schema polymorphism in the C++/Parser mapping refer
-     to Section 5.4, "Support for Polymorphism".

+ to Section 5.5, "Support for Polymorphism".

The rest of the document interface consists of overloaded parse() functions. The last two arguments in each of these @@ -3610,7 +3627,7 @@ namespace xml_schema document type has the following interface. Note that if the character type is wchar_t, then the string type in the interface becomes std::wstring - (see Section 5.1, "Character Type and Encoding").

+ (see Section 5.2, "Character Type and Encoding").

 namespace xml_schema
@@ -3747,7 +3764,7 @@ namespace xml_schema
      polymorphic, specifies whether the XML documents
      being parsed use polymorphism. For more information on support
      for XML Schema polymorphism in the C++/Parser mapping refer
-     to Section 5.4, "Support for Polymorphism".

+ to Section 5.5, "Support for Polymorphism".

A number of overloaded parse() functions have the system_id and public_id arguments. The @@ -3895,7 +3912,7 @@ main (int argc, char* argv[]) character type is wchar_t, then the string type and output stream type in the definition become std::wstring and std::wostream, - respectively (see Section 5.1, "Character Type + respectively (see Section 5.2, "Character Type and Encoding").

@@ -4008,7 +4025,7 @@ main (int argc, char* argv[])
      listing presents the definition of the error_handler
      interface. Note that if the character type is wchar_t,
      then the string type in the interface becomes std::wstring
-     (see Section 5.1, "Character Type and Encoding").

+ (see Section 5.2, "Character Type and Encoding").

 namespace xml_schema
diff --git a/doc/cxx/tree/guide/index.xhtml b/doc/cxx/tree/guide/index.xhtml
index 7d2ac54..df54d1f 100644
--- a/doc/cxx/tree/guide/index.xhtml
+++ b/doc/cxx/tree/guide/index.xhtml
@@ -226,10 +226,11 @@
     
       3Overall Mapping Configuration
         
-          
-          
-          
-          
+	  
+          
+          
+          
+          
3.1Character Type and Encoding
3.2Support for Polymorphism
3.3Namespace Mapping
3.4Thread Safety
3.1C++ Standard
3.2Character Type and Encoding
3.3Support for Polymorphism
3.4Namespace Mapping
3.5Thread Safety
@@ -621,8 +622,29 @@ hello (std::istream&); global element in XML Schema is a valid document root. By default XSD generated a set of parsing functions for each global element defined in XML Schema (this can be overridden - with the --root-element-* options). For more - information on parsing functions see Chapter 5, + with the --root-element-* options). Parsing + functions return a dynamically allocated object model as an + automatic pointer. The actual pointer used depends on the + C++ standard selected. For C++98 it is std::auto_ptr + as shown above. For C++11 it is std::unique_ptr. + For example, if we modify our XSD compiler invocation to + select C++11:

+ +
+$ xsd cxx-tree --std c++11 hello.xsd
+  
+ +

Then the parsing function signatures will become:

+ +
+std::unique_ptr<hello_t>
+hello (const std::string& uri);
+
+std::unique_ptr<hello_t>
+hello (std::istream&);
+  
+ +

For more information on parsing functions see Chapter 5, "Parsing".

2.3 Implementing Application Logic

@@ -1134,16 +1156,25 @@ $ doxygen hello.doxygen determine the overall properties and behavior of the generated code. Configuration parameters are specified with the XSD command line options. This chapter describes configuration aspects that are most - commonly encountered by application developers. These include: - the character type that is used by the generated code, handling of - vocabularies that use XML Schema polymorphism, XML Schema to C++ - namespace mapping, and thread safety. For more ways to configure + commonly encountered by application developers. These include: the + C++ standard, the character type that is used by the generated code, + handling of vocabularies that use XML Schema polymorphism, XML Schema + to C++ namespace mapping, and thread safety. For more ways to configure the generated code refer to the XSD Compiler Command Line Manual.

-

3.1 Character Type and Encoding

+

3.1 C++ Standard

+ +

The C++/Tree mapping provides support for ISO/IEC C++ 1998/2003 (C++98) + and ISO/IEC C++ 2011 (C++11). To select the C++ standard for the + generated code we use the --std XSD compiler command + line option. While the majority of the examples in this guide use + C++98, support for the new functionality and library components + introduced in C++11 are discussed throughout the document.

+ +

3.2 Character Type and Encoding

The C++/Tree mapping has built-in support for two character types: char and wchar_t. You can select the @@ -1174,7 +1205,7 @@ $ doxygen hello.doxygen all three (object mode, input XML, and output XML) can have different encodings.

-

3.2 Support for Polymorphism

+

3.3 Support for Polymorphism

By default XSD generates non-polymorphic code. If your vocabulary uses XML Schema polymorphism in the form of xsi:type @@ -1186,7 +1217,7 @@ $ doxygen hello.doxygen "Mapping for xsi:type and Substitution Groups" in the C++/Tree Mapping User Manual.

-

3.3 Namespace Mapping

+

3.4 Namespace Mapping

XSD maps XML namespaces specified in the targetNamespace attribute in XML Schema to one or more nested C++ namespaces. By @@ -1213,7 +1244,7 @@ $ doxygen hello.doxygen --namespace-map =cs

-

3.4 Thread Safety

+

3.5 Thread Safety

XSD-generated code is thread-safe in the sense that you can use different instantiations of the object model in several @@ -1829,7 +1860,7 @@ ps.push_back (jane); of the passed objects:

-// Add the John Doe record.
+// Add the John Doe record. C++98 version.
 //
 auto_ptr<person_t> john_p (
   new person_t ("John",           // first-name
@@ -1839,15 +1870,15 @@ auto_ptr<person_t> john_p (
                 1));
 ps.push_back (john_p); // assumes ownership
 
-// Add the Jane Doe record.
+// Add the Jane Doe record. C++11 version
 //
-auto_ptr<person_t> jane_p (
+unique_ptr<person_t> jane_p (
   new person_t ("Jane",           // first-name
                 "Doe",            // last-name
                 gender_t::female, // gender
                 28,               // age
                 2));              // id
-ps.push_back (jane_p); // assumes ownership
+ps.push_back (std::move (jane_p)); // assumes ownership
   

For more information on the non-copying modifier functions refer to @@ -2221,17 +2252,17 @@ ps.push_back (jane_p); // assumes ownership on the following three parsing functions:

-std::auto_ptr<people_t>
+std::[auto|unique]_ptr<people_t>
 people (const std::string& uri,
 	xml_schema::flags f = 0,
 	const xml_schema::properties& p = xml_schema::properties ());
 
-std::auto_ptr<people_t>
+std::[auto|unique]_ptr<people_t>
 people (std::istream& is,
         xml_schema::flags f = 0,
         const xml_schema::properties& p = xml_schema::properties ());
 
-std::auto_ptr<people_t>
+std::[auto|unique]_ptr<people_t>
 people (std::istream& is,
         const std::string& resource_id,
         xml_schema::flags f = 0,
@@ -2251,8 +2282,11 @@ people (std::istream& is,
      to fine-tune the parsing process. The properties argument allows
      to pass additional information to the parsing functions. We will
      use these two arguments in Section 5.1, "XML Schema
-     Validation and Searching" below. The following example shows
-     how we can use the above parsing functions:

+ Validation and Searching" below. All three functions return + the object model as either std::auto_ptr (C++98) or + std::unique_ptr (C++11), depending on the C++ standard + selected (--std XSD compiler option). The following + example shows how we can use the above parsing functions:

 using std::auto_ptr;
diff --git a/doc/cxx/tree/manual/index.xhtml b/doc/cxx/tree/manual/index.xhtml
index d022919..05e1bef 100644
--- a/doc/cxx/tree/manual/index.xhtml
+++ b/doc/cxx/tree/manual/index.xhtml
@@ -225,10 +225,11 @@
           
             2.1Preliminary Information
               
-                
-                
-                
-		
+		
+                
+                
+                
+		
2.1.1Identifiers
2.1.2Character Type and Encoding
2.1.3XML Schema Namespace
2.1.4Anonymous Types
2.1.1C++ Standard
2.1.2Identifiers
2.1.3Character Type and Encoding
2.1.4XML Schema Namespace
2.1.5Anonymous Types
@@ -517,7 +518,16 @@

2.1 Preliminary Information

-

2.1.1 Identifiers

+

2.1.1 C++ Standard

+ +

The C++/Tree mapping provides support for ISO/IEC C++ 1998/2003 (C++98) + and ISO/IEC C++ 2011 (C++11). To select the C++ standard for the + generated code we use the --std XSD compiler command + line option. While the majority of the examples in this manual use + C++98, support for the new functionality and library components + introduced in C++11 are discussed throughout the document.

+ +

2.1.2 Identifiers

XML Schema names may happen to be reserved C++ keywords or contain characters that are illegal in C++ identifiers. To avoid C++ compilation @@ -563,7 +573,7 @@ CONVENTION section in the XSD Compiler Command Line Manual.

-

2.1.2 Character Type and Encoding

+

2.1.3 Character Type and Encoding

The code that implements the mapping, depending on the --char-type option, is generated using either @@ -588,7 +598,7 @@ encoding is UTF-16. On other platforms wchar_t is 4 bytes long and UTF-32/UCS-4 is used.

-

2.1.3 XML Schema Namespace

+

2.1.4 XML Schema Namespace

The mapping relies on some predefined types, classes, and functions that are logically defined in the XML Schema namespace reserved for @@ -605,7 +615,7 @@

-

2.1.4 Anonymous Types

+

2.1.5 Anonymous Types

For the purpose of code generation, anonymous types defined in XML Schema are automatically assigned names that are derived @@ -1132,9 +1142,10 @@ namespace system sequences of non-fundamental C++ types is the addition of the overloaded push_back and insert member functions which instead of the constant reference - to the element type accept automatic pointer to the element - type. These functions assume ownership of the pointed to - object and resets the passed automatic pointer. + to the element type accept automatic pointer (std::auto_ptr + or std::unique_ptr, depending on the C++ standard + selected) to the element type. These functions assume ownership + of the pointed to object and reset the passed automatic pointer.

2.5.1 Inheritance from Built-in Data Types

@@ -2317,9 +2328,10 @@ public: sequences of non-fundamental C++ types is the addition of the overloaded push_back and insert member functions which instead of the constant reference - to the element type accept automatic pointer to the element - type. These functions assume ownership of the pointed to - object and resets the passed automatic pointer. + to the element type accept automatic pointer (std::auto_ptr + or std::unique_ptr, depending on the C++ standard + selected) to the element type. These functions assume ownership + of the pointed to object and reset the passed automatic pointer.

2.6.4 Mapping for Derivation by Union

@@ -2384,10 +2396,11 @@ public: instance is initialized with copies of the passed objects. In the second constructor, arguments that are complex types (that is, they themselves contain elements or attributes) are passed as - references to std::auto_ptr. In this case the newly + either std::auto_ptr (C++98) or std::unique_ptr + (C++11), depending on the C++ standard selected. In this case the newly created instance is directly initialized with and assumes ownership - of the pointed to objects and the std::auto_ptr arguments - are reset to 0. For instance:

+ of the pointed to objects and the std::[auto|unique]_ptr + arguments are reset to 0. For instance:

 <complexType name="complex">
@@ -2432,7 +2445,7 @@ class object: xml_schema::type
 {
 public:
   object (const bool& s_one, const complex& c_one);
-  object (const bool& s_one, std::auto_ptr<complex>& c_one);
+  object (const bool& s_one, std::[auto|unique]_ptr<complex> c_one);
   object (const object&);
 
 public:
@@ -2449,7 +2462,7 @@ public:
   

Notice that the generated complex class does not - have the second (std::auto_ptr) version of the + have the second (std::[auto|unique]_ptr) version of the constructor since all its required members are of simple types.

If an XML Schema complex type has an ultimate base which is an XML @@ -2720,9 +2733,10 @@ public: constant of the member's type. It makes a deep copy of its argument. Except for member's types that are mapped to fundamental C++ types, the second modifier function is provided that expects an argument - of type automatic pointer to the member's type. It assumes ownership - of the pointed to object and resets the passed automatic pointer. - For instance:

+ of type automatic pointer (std::auto_ptr or + std::unique_ptr, depending on the C++ standard selected) + to the member's type. It assumes ownership of the pointed to object + and resets the passed automatic pointer. For instance:

 <complexType name="object">
@@ -2756,7 +2770,7 @@ public:
   member (const member_type&);
 
   void
-  member (std::auto_ptr<member_type>);
+  member (std::[auto|unique]_ptr<member_type>);
   ...
 
 };
@@ -2773,7 +2787,7 @@ class object: xml_schema::type
 public:
   ...
 
-  std::auto_ptr<member_type>
+  std::[auto|unique]_ptr<member_type>
   detach_member ();
   ...
 
@@ -2798,10 +2812,19 @@ f (object& o)
   o.member ("hello");           // set, deep copy
   o.member () = "hello";        // set, deep copy
 
+  // C++98 version.
+  //
   std::auto_ptr<string> p (new string ("hello"));
   o.member (p);                 // set, assumes ownership
   p = o.detach_member ();       // detach, member is uninitialized
   o.member (p);                 // re-attach
+
+  // C++11 version.
+  //
+  std::unique_ptr<string> p (new string ("hello"));
+  o.member (std::move (p));     // set, assumes ownership
+  p = o.detach_member ();       // detach, member is uninitialized
+  o.member (std::move (p));     // re-attach
 }
   
@@ -2831,11 +2854,12 @@ f (object& o) member's type. It makes a deep copy of its argument. Except for member's types that are mapped to fundamental C++ types, the second modifier function is provided that expects an argument - of type automatic pointer to the member's type. It assumes ownership - of the pointed to object and resets the passed automatic pointer. - The last modifier function expects an argument of type reference - to constant of the container type. It makes a deep copy of its - argument. For instance: + of type automatic pointer (std::auto_ptr or + std::unique_ptr, depending on the C++ standard selected) + to the member's type. It assumes ownership of the pointed to object + and resets the passed automatic pointer. The last modifier function + expects an argument of type reference to constant of the container + type. It makes a deep copy of its argument. For instance:

@@ -2871,7 +2895,7 @@ public:
   member (const member_type&);
 
   void
-  member (std::auto_ptr<member_type>);
+  member (std::[auto|unique]_ptr<member_type>);
 
   void
   member (const member_optional&);
@@ -2884,7 +2908,7 @@ public:
 
   

The optional class template is defined in an implementation-specific namespace and has the following - interface. The auto_ptr-based constructor + interface. The [auto|unique]_ptr-based constructor and modifier function are only available if the template argument is not a fundamental C++ type.

@@ -2904,7 +2928,7 @@ public: // Assumes ownership. // explicit - optional (std::auto_ptr<X>); + optional (std::[auto|unique]_ptr<X>); optional (const optional&); @@ -2953,11 +2977,11 @@ public: // Assumes ownership. // void - set (std::auto_ptr<X>); + set (std::[auto|unique]_ptr<X>); // Detach and return the contained value. // - std::auto_ptr<X> + std::[auto|unique]_ptr<X> detach (); void @@ -3016,6 +3040,8 @@ f (object& o) o.member ().reset (); // reset } + // C++98 version. + // std::auto_ptr<string> p (new string ("hello")); o.member (p); // set, assumes ownership @@ -3024,6 +3050,17 @@ f (object& o) p = o.member ().detach (); // detach, member is reset o.member ().set (p); // re-attach + + // C++11 version. + // + std::unique_ptr<string> p (new string ("hello")); + o.member (std::move (p)); // set, assumes ownership + + p.reset (new string ("hello")); + o.member ().set (std::move (p)); // set, assumes ownership + + p = o.member ().detach (); // detach, member is reset + o.member ().set (std::move (p)); // re-attach }
@@ -3104,9 +3141,11 @@ public: the overloaded push_back and insert as well as the detach_back and detach member functions. The additional push_back and - insert functions accept an automatic pointer to the + insert functions accept an automatic pointer + (std::auto_ptr or std::unique_ptr, + depending on the C++ standard selected) to the element type instead of the constant reference. They assume - ownership of the pointed to object and resets the passed + ownership of the pointed to object and reset the passed automatic pointer. The detach_back and detach functions detach the element value from the sequence container and, by default, remove @@ -3121,17 +3160,17 @@ public: ... void - push_back (std::auto_ptr<X>) + push_back (std::[auto|unique]_ptr<X>) iterator - insert (iterator position, std::auto_ptr<X>) + insert (iterator position, std::[auto|unique]_ptr<X>) - std::auto_ptr<X> + std::[auto|unique]_ptr<X> detach_back (bool pop = true); iterator detach (iterator position, - std::auto_ptr<X>& result, + std::[auto|unique]_ptr<X>& result, bool erase = true) ... @@ -3159,11 +3198,20 @@ f (object& o) // s.push_back ("hello"); // deep copy + // C++98 version. + // std::auto_ptr<string> p (new string ("hello")); s.push_back (p); // assumes ownership p = s.detach_back (); // detach and pop s.push_back (p); // re-append + // C++11 version. + // + std::unique_ptr<string> p (new string ("hello")); + s.push_back (std::move (p)); // assumes ownership + p = s.detach_back (); // detach and pop + s.push_back (std::move (p)); // re-append + // Setting a new container. // object::member_sequence n; @@ -3192,14 +3240,16 @@ f (object& o)

The parsing functions read XML instance documents and return - corresponding object models. Their signatures + corresponding object models as an automatic pointer + (std::auto_ptr or std::unique_ptr, + depending on the C++ standard selected). Their signatures have the following pattern (type denotes element's type and name denotes element's name):

-std::auto_ptr<type>
+std::[auto|unique]_ptr<type>
 name (....);
   
@@ -3207,9 +3257,8 @@ name (....); functions, is the subject of Chapter 3, "Parsing".

-

The serialization functions write object models - back to XML instance documents. Their signatures - have the following pattern: +

The serialization functions write object models back to XML instance + documents. Their signatures have the following pattern:

@@ -3272,13 +3321,13 @@ public:
   value (const value_type&);
 
   void
-  value (std::auto_ptr<value_type>);
+  value (std::[auto|unique]_ptr<value_type>);
 
   // Constructors.
   //
   root (const value_type&);
 
-  root (std::auto_ptr<value_type>);
+  root (std::[auto|unique]_ptr<value_type>);
 
   root (const xercesc::DOMElement&, xml_schema::flags = 0);
 
@@ -3374,7 +3423,7 @@ namespace xml_schema
   class element_map
   {
   public:
-    static std::auto_ptr<xml_schema::element_type>
+    static std::[auto|unique]_ptr<xml_schema::element_type>
     parse (const xercesc::DOMElement&, flags = 0);
 
     static void
@@ -3385,7 +3434,9 @@ namespace xml_schema
 
   

The parse() function creates the corresponding element type object based on the element name and namespace - and returns it as a pointer to xml_schema::element_type. + and returns it as an automatic pointer (std::auto_ptr + or std::unique_ptr, depending on the C++ standard + selected) to xml_schema::element_type. The serialize() function serializes the passed element object to DOMElement. Note that in case of serialize(), the DOMElement object @@ -4574,18 +4625,18 @@ f (object& o, const xercesc::DOMAttr& a) // Read from a URI or a local file. // -std::auto_ptr<type> +std::[auto|unique]_ptr<type> name (const std::basic_string<C>& uri, xml_schema::flags = 0, const xml_schema::properties& = xml_schema::properties ()); -std::auto_ptr<type> +std::[auto|unique]_ptr<type> name (const std::basic_string<C>& uri, xml_schema::error_handler&, xml_schema::flags = 0, const xml_schema::properties& = xml_schema::properties ()); -std::auto_ptr<type> +std::[auto|unique]_ptr<type> name (const std::basic_string<C>& uri, xercesc::DOMErrorHandler&, xml_schema::flags = 0, @@ -4595,38 +4646,38 @@ name (const std::basic_string<C>& uri, // Read from std::istream. // -std::auto_ptr<type> +std::[auto|unique]_ptr<type> name (std::istream&, xml_schema::flags = 0, const xml_schema::properties& = xml_schema::properties ()); -std::auto_ptr<type> +std::[auto|unique]_ptr<type> name (std::istream&, xml_schema::error_handler&, xml_schema::flags = 0, const xml_schema::properties& = xml_schema::properties ()); -std::auto_ptr<type> +std::[auto|unique]_ptr<type> name (std::istream&, xercesc::DOMErrorHandler&, xml_schema::flags = 0, const xml_schema::properties& = xml_schema::properties ()); -std::auto_ptr<type> +std::[auto|unique]_ptr<type> name (std::istream&, const std::basic_string<C>& id, xml_schema::flags = 0, const xml_schema::properties& = xml_schema::properties ()); -std::auto_ptr<type> +std::[auto|unique]_ptr<type> name (std::istream&, const std::basic_string<C>& id, xml_schema::error_handler&, xml_schema::flags = 0, const xml_schema::properties& = xml_schema::properties ()); -std::auto_ptr<type> +std::[auto|unique]_ptr<type> name (std::istream&, const std::basic_string<C>& id, xercesc::DOMErrorHandler&, @@ -4637,18 +4688,18 @@ name (std::istream&, // Read from InputSource. // -std::auto_ptr<type> +std::[auto|unique]_ptr<type> name (xercesc::InputSource&, xml_schema::flags = 0, const xml_schema::properties& = xml_schema::properties ()); -std::auto_ptr<type> +std::[auto|unique]_ptr<type> name (xercesc::InputSource&, xml_schema::error_handler&, xml_schema::flags = 0, const xml_schema::properties& = xml_schema::properties ()); -std::auto_ptr<type> +std::[auto|unique]_ptr<type> name (xercesc::InputSource&, xercesc::DOMErrorHandler&, xml_schema::flags = 0, @@ -4658,13 +4709,13 @@ name (xercesc::InputSource&, // Read from DOM. // -std::auto_ptr<type> +std::[auto|unique]_ptr<type> name (const xercesc::DOMDocument&, xml_schema::flags = 0, const xml_schema::properties& = xml_schema::properties ()); -std::auto_ptr<type> -name (xml_schema::dom::auto_ptr<xercesc::DOMDocument>&, +std::[auto|unique]_ptr<type> +name (xml_schema::dom::[auto|unique]_ptr<xercesc::DOMDocument>, xml_schema::flags = 0, const xml_schema::properties& = xml_schema::properties ());

@@ -4672,8 +4723,11 @@ name (xml_schema::dom::auto_ptr<xercesc::DOMDocument>&,

You can choose between reading an XML instance from a local file, URI, std::istream, xercesc::InputSource, or a pre-parsed DOM instance in the form of - xercesc::DOMDocument. Each of these parsing functions - is discussed in more detail in the following sections. + xercesc::DOMDocument. All the parsing functions + return a dynamically allocated object model as either + std::auto_ptr or std::unique_ptr, + depending on the C++ standard selected. Each of these parsing + functions is discussed in more detail in the following sections.

3.1 Initializing the Xerces-C++ Runtime

@@ -4715,7 +4769,7 @@ name (xml_schema::dom::auto_ptr<xercesc::DOMDocument>&,
Assume ownership of the DOM document passed. This flag only makes sense together with the keep_dom flag in the call to the parsing function with the - xml_schema::dom::auto_ptr<DOMDocument> + xml_schema::dom::[auto|unique]_ptr<DOMDocument> argument.
xml_schema::flags::dont_validate
@@ -5171,6 +5225,15 @@ auto_ptr<type> r1 (name ("test.xml")); auto_ptr<type> r2 (name ("http://www.codesynthesis.com/test.xml"));
+

Or, in the C++11 mode:

+ +
+using std::unique_ptr;
+
+unique_ptr<type> r1 (name ("test.xml"));
+unique_ptr<type> r2 (name ("http://www.codesynthesis.com/test.xml"));
+  
+

3.5 Reading from std::istream

When using an std::istream instance, you may also @@ -5220,21 +5283,30 @@ std::auto_ptr<type> r (name (is));

The last parsing function is useful when you would like to perform your own XML-to-DOM parsing and associate the resulting DOM document - with the object model nodes. If parsing is successeful, the - automatic DOMDocument pointer is reset and the - resulting object model assumes ownership of the DOM document - passed. For example:

+ with the object model nodes. The automatic DOMDocument + pointer is reset and the resulting object model assumes ownership + of the DOM document passed. For example:

+// C++98 version.
+//
 xml_schema::dom::auto_ptr<xercesc::DOMDocument> doc = ...
 
 std::auto_ptr<type> r (
   name (doc, xml_schema::flags::keep_dom | xml_schema::flags::own_dom));
 
 // At this point doc is reset to 0.
-  
+// C++11 version. +// +xml_schema::dom::unique_ptr<xercesc::DOMDocument> doc = ... + +std::unique_ptr<type> r ( + name (std::move (doc), + xml_schema::flags::keep_dom | xml_schema::flags::own_dom)); +// At this point doc is reset to 0. +

4 Serialization

@@ -5321,7 +5393,7 @@ name (xercesc::XMLFormatTarget&, // Serialize to DOM. // -xml_schema::dom::auto_ptr<xercesc::DOMDocument> +xml_schema::dom::[auto|unique]_ptr<xercesc::DOMDocument> name (const type&, const xml_schema::namespace_infomap& xml_schema::namespace_infomap (), @@ -5800,10 +5872,10 @@ XMLPlatformUtils::Initialize (); { // Parse XML to object model. // - std::auto_ptr<type> r = root ( + std::auto_ptr<type> r (root ( "root.xml", xml_schema::flags::keep_dom | - xml_schema::flags::dont_initialize); + xml_schema::flags::dont_initialize)); // Copy without DOM association. // @@ -5847,10 +5919,10 @@ XMLPlatformUtils::Initialize (); { // Parse XML to object model. // - std::auto_ptr<type> r = root ( + std::auto_ptr<type> r (root ( "root.xml", xml_schema::flags::keep_dom | - xml_schema::flags::dont_initialize); + xml_schema::flags::dont_initialize)); DOMNode* n = root->_node (); assert (n->getNodeType () == DOMNode::ELEMENT_NODE); @@ -5938,7 +6010,7 @@ XMLPlatformUtils::Terminate ();
 // Parse XML to object model.
 //
-std::auto_ptr<type> r = root ("root.xml");
+std::auto_ptr<type> r (root ("root.xml"));
 
 // Save to a CDR stream.
 //
diff --git a/doc/cxx/tree/reference/libxsd.doxygen b/doc/cxx/tree/reference/libxsd.doxygen
index 3f524d1..376d34a 100644
--- a/doc/cxx/tree/reference/libxsd.doxygen
+++ b/doc/cxx/tree/reference/libxsd.doxygen
@@ -1042,13 +1042,13 @@ ENABLE_PREPROCESSING   = YES
 # compilation will be performed. Macro expansion can be done in a controlled 
 # way by setting EXPAND_ONLY_PREDEF to YES.
 
-MACRO_EXPANSION        = NO
+MACRO_EXPANSION        = YES
 
 # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
 # then the macro expansion is limited to the macros specified with the 
 # PREDEFINED and EXPAND_AS_DEFINED tags.
 
-EXPAND_ONLY_PREDEF     = NO
+EXPAND_ONLY_PREDEF     = YES
 
 # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
 # in the INCLUDE_PATH (see below) will be search if a #include is found.
@@ -1076,7 +1076,13 @@ INCLUDE_FILE_PATTERNS  =
 # undefined via #undef or recursively expanded use the := operator 
 # instead of the = operator.
 
-PREDEFINED             = 
+# C++98 version.
+#
+PREDEFINED             = XSD_AUTO_PTR=std::auto_ptr
+
+# C++11 version.
+#
+# PREDEFINED             = XSD_AUTO_PTR=std::unique_ptr
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
 # this tag can be used to specify a list of macro names that should be expanded. 
diff --git a/libxsd/xsd/cxx/auto-array.hxx b/libxsd/xsd/cxx/auto-array.hxx
index e309603..64c454a 100644
--- a/libxsd/xsd/cxx/auto-array.hxx
+++ b/libxsd/xsd/cxx/auto-array.hxx
@@ -6,6 +6,12 @@
 #ifndef XSD_CXX_AUTO_ARRAY_HXX
 #define XSD_CXX_AUTO_ARRAY_HXX
 
+#include  // XSD_CXX11
+
+#ifdef XSD_CXX11
+#  error use std::unique_ptr instead of non-standard auto_array
+#endif
+
 #include  // std::size_t
 
 namespace xsd
@@ -13,20 +19,20 @@ namespace xsd
   namespace cxx
   {
     template 
-    struct std_deallocator
+    struct std_array_deleter
     {
       void
-      deallocate (T* p)
+      operator() (T* p) const
       {
         delete[] p;
       }
     };
 
     // Simple automatic array. The second template parameter is
-    // an optional deallocator type. If not specified, delete[]
+    // an optional deleter type. If not specified, delete[]
     // is used.
     //
-    template  >
+    template  >
     struct auto_array
     {
       auto_array (T a[])
@@ -34,7 +40,7 @@ namespace xsd
       {
       }
 
-      auto_array (T a[], D& d)
+      auto_array (T a[], const D& d)
           : a_ (a), d_ (&d)
       {
       }
@@ -42,7 +48,7 @@ namespace xsd
       ~auto_array ()
       {
         if (d_ != 0)
-          d_->deallocate (a_);
+          (*d_) (a_);
         else
           delete[] a_;
       }
@@ -73,7 +79,7 @@ namespace xsd
         if (a_ != a)
         {
           if (d_ != 0)
-            d_->deallocate (a_);
+            (*d_) (a_);
           else
             delete[] a_;
 
@@ -100,7 +106,7 @@ namespace xsd
 
     private:
       T* a_;
-      D* d_;
+      const D* d_;
     };
 
     template 
diff --git a/libxsd/xsd/cxx/config.hxx b/libxsd/xsd/cxx/config.hxx
index 1c214fc..e4d6a48 100644
--- a/libxsd/xsd/cxx/config.hxx
+++ b/libxsd/xsd/cxx/config.hxx
@@ -8,7 +8,40 @@
 
 #include 
 
-// Macro to suppress unused variable warning.
+// Available C++11 features.
+//
+#ifdef XSD_CXX11
+#ifdef _MSC_VER
+#  if _MSC_VER >= 1600
+#    define XSD_CXX11_NULLPTR
+#    if _MSC_VER >= 1800
+#      define XSD_CXX11_TEMPLATE_ALIAS
+#    endif
+#  endif
+#else
+#  if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
+#    ifdef __GNUC__
+#      if (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4
+#        define XSD_CXX11_NULLPTR
+#      endif
+#      if (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || __GNUC__ > 4
+#        define XSD_CXX11_TEMPLATE_ALIAS
+#      endif
+#    else
+#      define XSD_CXX11_NULLPTR
+#      define XSD_CXX11_TEMPLATE_ALIAS
+#    endif
+#  endif
+#endif
+#endif // XSD_CXX11
+
+#ifdef XSD_CXX11
+#  define XSD_AUTO_PTR std::unique_ptr
+#else
+#  define XSD_AUTO_PTR std::auto_ptr
+#endif
+
+// Macro to suppress the unused variable warning.
 //
 #define XSD_UNUSED(x) (void)x
 
diff --git a/libxsd/xsd/cxx/parser/expat/elements.hxx b/libxsd/xsd/cxx/parser/expat/elements.hxx
index 706b6a3..d47106b 100644
--- a/libxsd/xsd/cxx/parser/expat/elements.hxx
+++ b/libxsd/xsd/cxx/parser/expat/elements.hxx
@@ -6,11 +6,17 @@
 #ifndef XSD_CXX_PARSER_EXPAT_ELEMENTS_HXX
 #define XSD_CXX_PARSER_EXPAT_ELEMENTS_HXX
 
+#include  // XSD_CXX11
+
 #include 
 #include 
 #include  // std::size_t
 #include 
 
+#ifdef XSD_CXX11
+#  include  // std::unique_ptr
+#endif
+
 #include 
 
 // We only support UTF-8 expat for now.
@@ -35,6 +41,19 @@ namespace xsd
     {
       namespace expat
       {
+#ifdef XSD_CXX11
+        struct parser_deleter
+        {
+          void
+          operator() (XML_Parser p) const
+          {
+            if (p != 0)
+              XML_ParserFree (p);
+          }
+        };
+
+        typedef std::unique_ptr parser_auto_ptr;
+#else
         // Simple auto pointer for Expat's XML_Parser object.
         //
         struct parser_auto_ptr
@@ -61,8 +80,8 @@ namespace xsd
             return *this;
           }
 
-        public:
-          operator XML_Parser ()
+          XML_Parser
+          get () const
           {
             return parser_;
           }
@@ -76,7 +95,7 @@ namespace xsd
         private:
           XML_Parser parser_;
         };
-
+#endif // XSD_CXX11
 
         //
         //
diff --git a/libxsd/xsd/cxx/parser/expat/elements.txx b/libxsd/xsd/cxx/parser/expat/elements.txx
index 21dff58..f3df667 100644
--- a/libxsd/xsd/cxx/parser/expat/elements.txx
+++ b/libxsd/xsd/cxx/parser/expat/elements.txx
@@ -334,18 +334,18 @@ namespace xsd
         {
           // First call.
           //
-          if (auto_xml_parser_ == 0)
+          if (auto_xml_parser_.get () == 0)
           {
             auto_xml_parser_ = XML_ParserCreateNS (0, XML_Char (' '));
 
-            if (auto_xml_parser_ == 0)
+            if (auto_xml_parser_.get () == 0)
               throw std::bad_alloc ();
 
             if (system_id || public_id)
-              parse_begin (auto_xml_parser_,
+              parse_begin (auto_xml_parser_.get (),
                            system_id ? *system_id : *public_id, eh);
             else
-              parse_begin (auto_xml_parser_, eh);
+              parse_begin (auto_xml_parser_.get (), eh);
           }
 
           bool r (XML_Parse (xml_parser_,
diff --git a/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.hxx b/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.hxx
index 26c77a6..0e05e42 100644
--- a/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.hxx
+++ b/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.hxx
@@ -8,6 +8,8 @@
 
 #include 
 
+#include  // XSD_AUTO_PTR
+
 #include 
 
 namespace xsd
@@ -564,7 +566,7 @@ namespace xsd
           virtual void
           _characters (const ro_string&);
 
-          virtual std::auto_ptr
+          virtual XSD_AUTO_PTR
           post_base64_binary ();
 
         protected:
@@ -582,7 +584,7 @@ namespace xsd
           virtual void
           _characters (const ro_string&);
 
-          virtual std::auto_ptr
+          virtual XSD_AUTO_PTR
           post_hex_binary ();
 
         protected:
diff --git a/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.txx b/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.txx
index 2c46874..77b1423 100644
--- a/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.txx
+++ b/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.txx
@@ -1157,7 +1157,7 @@ namespace xsd
         }
 
         template 
-        std::auto_ptr base64_binary_pimpl::
+        XSD_AUTO_PTR base64_binary_pimpl::
         post_base64_binary ()
         {
           typedef typename std::basic_string::size_type size_type;
@@ -1199,7 +1199,7 @@ namespace xsd
           size_type quad_count (size / 4);
           size_type capacity (quad_count * 3 + 1);
 
-          std::auto_ptr buf (new buffer (capacity, capacity));
+          XSD_AUTO_PTR buf (new buffer (capacity, capacity));
           char* dst (buf->data ());
 
           size_type si (0), di (0); // Source and destination indexes.
@@ -1309,7 +1309,7 @@ namespace xsd
         }
 
         template 
-        std::auto_ptr hex_binary_pimpl::
+        XSD_AUTO_PTR hex_binary_pimpl::
         post_hex_binary ()
         {
           typedef typename ro_string::size_type size_type;
@@ -1318,7 +1318,7 @@ namespace xsd
           size_type size (trim_right (tmp));
 
           buffer::size_t n (size / 2);
-          std::auto_ptr buf (new buffer (n));
+          XSD_AUTO_PTR buf (new buffer (n));
 
           const C* src (tmp.data ());
           char* dst (buf->data ());
diff --git a/libxsd/xsd/cxx/parser/non-validating/xml-schema-pskel.hxx b/libxsd/xsd/cxx/parser/non-validating/xml-schema-pskel.hxx
index 7d0dd00..aae157e 100644
--- a/libxsd/xsd/cxx/parser/non-validating/xml-schema-pskel.hxx
+++ b/libxsd/xsd/cxx/parser/non-validating/xml-schema-pskel.hxx
@@ -7,7 +7,9 @@
 #define XSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PSKEL_HXX
 
 #include 
-#include  // auto_ptr
+#include  // std::auto_ptr/unique_ptr
+
+#include  // XSD_AUTO_PTR
 
 #include 
 #include 
@@ -494,7 +496,7 @@ namespace xsd
         template 
         struct base64_binary_pskel: simple_content
         {
-          virtual std::auto_ptr
+          virtual XSD_AUTO_PTR
           post_base64_binary () = 0;
 
           static const C*
@@ -507,7 +509,7 @@ namespace xsd
         template 
         struct hex_binary_pskel: simple_content
         {
-          virtual std::auto_ptr
+          virtual XSD_AUTO_PTR
           post_hex_binary () = 0;
 
           static const C*
diff --git a/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.hxx b/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.hxx
index 0df1c4f..09194e4 100644
--- a/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.hxx
+++ b/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.hxx
@@ -8,6 +8,8 @@
 
 #include 
 
+#include  // XSD_AUTO_PTR
+
 #include 
 
 namespace xsd
@@ -664,12 +666,12 @@ namespace xsd
           virtual void
           _post ();
 
-          virtual std::auto_ptr
+          virtual XSD_AUTO_PTR
           post_base64_binary ();
 
         protected:
           std::basic_string str_;
-          std::auto_ptr buf_;
+          XSD_AUTO_PTR buf_;
         };
 
         // hexBinary
@@ -686,12 +688,12 @@ namespace xsd
           virtual void
           _post ();
 
-          virtual std::auto_ptr
+          virtual XSD_AUTO_PTR
           post_hex_binary ();
 
         protected:
           std::basic_string str_;
-          std::auto_ptr buf_;
+          XSD_AUTO_PTR buf_;
         };
 
         // gday
diff --git a/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.txx b/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.txx
index 021cca8..6631dd2 100644
--- a/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.txx
+++ b/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.txx
@@ -6,6 +6,10 @@
 #include 
 #include 
 
+#ifdef XSD_CXX11
+#  include  // std::move
+#endif
+
 #include 
 #include 
 
@@ -1634,10 +1638,14 @@ namespace xsd
         }
 
         template 
-        std::auto_ptr base64_binary_pimpl::
+        XSD_AUTO_PTR base64_binary_pimpl::
         post_base64_binary ()
         {
+#ifdef XSD_CXX11
+          return std::move (buf_);
+#else
           return buf_;
+#endif
         }
 
         // hex_binary
@@ -1721,10 +1729,14 @@ namespace xsd
         }
 
         template 
-        std::auto_ptr hex_binary_pimpl::
+        XSD_AUTO_PTR hex_binary_pimpl::
         post_hex_binary ()
         {
+#ifdef XSD_CXX11
+          return std::move (buf_);
+#else
           return buf_;
+#endif
         }
 
         // time_zone
diff --git a/libxsd/xsd/cxx/parser/validating/xml-schema-pskel.hxx b/libxsd/xsd/cxx/parser/validating/xml-schema-pskel.hxx
index 4641fe9..88cc3ab 100644
--- a/libxsd/xsd/cxx/parser/validating/xml-schema-pskel.hxx
+++ b/libxsd/xsd/cxx/parser/validating/xml-schema-pskel.hxx
@@ -7,7 +7,9 @@
 #define XSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PSKEL_HXX
 
 #include 
-#include  // auto_ptr
+#include  // std::auto_ptr/unique_ptr
+
+#include  // XSD_AUTO_PTR
 
 #include 
 #include 
@@ -494,7 +496,7 @@ namespace xsd
         template 
         struct base64_binary_pskel: simple_content
         {
-          virtual std::auto_ptr
+          virtual XSD_AUTO_PTR
           post_base64_binary () = 0;
 
           static const C*
@@ -507,7 +509,7 @@ namespace xsd
         template 
         struct hex_binary_pskel: simple_content
         {
-          virtual std::auto_ptr
+          virtual XSD_AUTO_PTR
           post_hex_binary () = 0;
 
           static const C*
diff --git a/libxsd/xsd/cxx/parser/xerces/elements.hxx b/libxsd/xsd/cxx/parser/xerces/elements.hxx
index 5fe3688..35920a4 100644
--- a/libxsd/xsd/cxx/parser/xerces/elements.hxx
+++ b/libxsd/xsd/cxx/parser/xerces/elements.hxx
@@ -6,7 +6,7 @@
 #ifndef XSD_CXX_PARSER_XERCES_ELEMENTS_HXX
 #define XSD_CXX_PARSER_XERCES_ELEMENTS_HXX
 
-#include   // std::auto_ptr
+#include   // std::auto_ptr/unique_ptr
 #include 
 #include 
 #include 
@@ -18,6 +18,8 @@
 
 #include 
 
+#include  // XSD_AUTO_PTR
+
 #include 
 #include 
 
@@ -377,7 +379,7 @@ namespace xsd
                  const properties&);
 
         private:
-          std::auto_ptr
+          XSD_AUTO_PTR
           create_sax_ (flags, const properties&);
 
         private:
diff --git a/libxsd/xsd/cxx/parser/xerces/elements.txx b/libxsd/xsd/cxx/parser/xerces/elements.txx
index 60b6c6d..2324b0c 100644
--- a/libxsd/xsd/cxx/parser/xerces/elements.txx
+++ b/libxsd/xsd/cxx/parser/xerces/elements.txx
@@ -95,7 +95,7 @@ namespace xsd
 
           error_handler eh;
           xml::sax::bits::error_handler_proxy eh_proxy (eh);
-          std::auto_ptr sax (create_sax_ (f, p));
+          XSD_AUTO_PTR sax (create_sax_ (f, p));
 
           parse (uri, eh_proxy, *sax, f, p);
 
@@ -124,7 +124,7 @@ namespace xsd
           xml::auto_initializer init ((f & flags::dont_initialize) == 0);
 
           xml::sax::bits::error_handler_proxy eh_proxy (eh);
-          std::auto_ptr sax (create_sax_ (f, p));
+          XSD_AUTO_PTR sax (create_sax_ (f, p));
 
           parse (uri, eh_proxy, *sax, f, p);
 
@@ -153,7 +153,7 @@ namespace xsd
                const properties& p)
         {
           xml::sax::bits::error_handler_proxy eh_proxy (eh);
-          std::auto_ptr sax (create_sax_ (f, p));
+          XSD_AUTO_PTR sax (create_sax_ (f, p));
 
           parse (uri, eh_proxy, *sax, f, p);
 
@@ -390,7 +390,7 @@ namespace xsd
         {
           error_handler eh;
           xml::sax::bits::error_handler_proxy eh_proxy (eh);
-          std::auto_ptr sax (create_sax_ (f, p));
+          XSD_AUTO_PTR sax (create_sax_ (f, p));
 
           parse (is, eh_proxy, *sax, f, p);
 
@@ -405,7 +405,7 @@ namespace xsd
                const properties& p)
         {
           xml::sax::bits::error_handler_proxy eh_proxy (eh);
-          std::auto_ptr sax (create_sax_ (f, p));
+          XSD_AUTO_PTR sax (create_sax_ (f, p));
 
           parse (is, eh_proxy, *sax, f, p);
 
@@ -421,7 +421,7 @@ namespace xsd
                const properties& p)
         {
           xml::sax::bits::error_handler_proxy eh_proxy (eh);
-          std::auto_ptr sax (create_sax_ (f, p));
+          XSD_AUTO_PTR sax (create_sax_ (f, p));
 
           parse (is, eh_proxy, *sax, f, p);
 
@@ -569,12 +569,12 @@ namespace xsd
 
 
         template 
-        std::auto_ptr document::
+        XSD_AUTO_PTR document::
         create_sax_ (flags f, const properties& p)
         {
           using namespace xercesc;
 
-          std::auto_ptr sax (
+          XSD_AUTO_PTR sax (
             XMLReaderFactory::createXMLReader ());
 
           sax->setFeature (XMLUni::fgSAX2CoreNameSpaces, true);
diff --git a/libxsd/xsd/cxx/tree/ace-cdr-stream-extraction.hxx b/libxsd/xsd/cxx/tree/ace-cdr-stream-extraction.hxx
index 50c19d6..03e2409 100644
--- a/libxsd/xsd/cxx/tree/ace-cdr-stream-extraction.hxx
+++ b/libxsd/xsd/cxx/tree/ace-cdr-stream-extraction.hxx
@@ -12,7 +12,13 @@
 #include  // ACE::strdelete
 #include 
 
-#include 
+#include  // XSD_CXX11
+
+#ifdef XSD_CXX11
+#  include  // std::unique_ptr
+#else
+#  include 
+#endif
 
 #include 
 #include 
@@ -258,11 +264,11 @@ namespace xsd
 
       namespace bits
       {
-        template
-        struct ace_str_deallocator
+        template 
+        struct ace_str_deleter
         {
           void
-          deallocate (C* s)
+          operator() (C* s) const
           {
             ACE::strdelete (s);
           }
@@ -272,18 +278,22 @@ namespace xsd
       inline istream&
       operator>> (istream& s, std::basic_string& x)
       {
-        typedef bits::ace_str_deallocator deallocator;
+        typedef bits::ace_str_deleter deleter;
 
-        deallocator d;
+        deleter d;
         char* r;
 
         if (!s.impl ().read_string (r))
           throw ace_cdr_stream_extraction ();
 
-        auto_array ar (r, d);
+#ifdef XSD_CXX11
+        std::unique_ptr ar (
+#else
+        auto_array ar (
+#endif
+          r, d);
 
         x = r;
-
         return s;
       }
 
@@ -291,18 +301,22 @@ namespace xsd
       inline istream&
       operator>> (istream& s, std::basic_string& x)
       {
-        typedef bits::ace_str_deallocator deallocator;
+        typedef bits::ace_str_deleter deleter;
 
-        deallocator d;
+        deleter d;
         wchar_t* r;
 
         if (!s.impl ().read_wstring (r))
           throw ace_cdr_stream_extraction ();
 
-        auto_array ar (r, d);
+#ifdef XSD_CXX11
+        std::unique_ptr ar (
+#else
+        auto_array ar (
+#endif
+          r, d);
 
         x = r;
-
         return s;
       }
 #endif
diff --git a/libxsd/xsd/cxx/tree/containers.hxx b/libxsd/xsd/cxx/tree/containers.hxx
index e6b9f88..1b959cb 100644
--- a/libxsd/xsd/cxx/tree/containers.hxx
+++ b/libxsd/xsd/cxx/tree/containers.hxx
@@ -9,11 +9,13 @@
 #include    // std::ptrdiff_t
 #include 
 #include 
-#include     // std::auto_ptr
+#include     // std::auto_ptr/unique_ptr
 #include   // std::iterator_traits
 #include  // std::equal, std::lexicographical_compare
 #include 
 
+#include  // XSD_AUTO_PTR
+
 #include 
 
 namespace xsd
@@ -136,7 +138,7 @@ namespace xsd
 
         one (const T&, container*);
 
-        one (std::auto_ptr, container*);
+        one (XSD_AUTO_PTR, container*);
 
         one (const one&, flags, container*);
 
@@ -163,7 +165,7 @@ namespace xsd
         }
 
         void
-        set (std::auto_ptr);
+        set (XSD_AUTO_PTR);
 
         bool
         present () const
@@ -171,13 +173,13 @@ namespace xsd
           return x_ != 0;
         }
 
-        std::auto_ptr
+        XSD_AUTO_PTR
         detach ()
         {
           T* x (x_);
           x->_container (0);
           x_ = 0;
-          return std::auto_ptr (x);
+          return XSD_AUTO_PTR (x);
         }
 
       protected:
@@ -268,7 +270,7 @@ namespace xsd
         optional (const T&, container* = 0);
 
         explicit
-        optional (std::auto_ptr, container* = 0);
+        optional (XSD_AUTO_PTR, container* = 0);
 
         optional (const optional&, flags = 0, container* = 0);
 
@@ -341,18 +343,18 @@ namespace xsd
         }
 
         void
-        set (std::auto_ptr);
+        set (XSD_AUTO_PTR);
 
         void
         reset ();
 
-        std::auto_ptr
+        XSD_AUTO_PTR
         detach ()
         {
           T* x (x_);
           x->_container (0);
           x_ = 0;
-          return std::auto_ptr (x);
+          return XSD_AUTO_PTR (x);
         }
 
       protected:
@@ -1266,7 +1268,7 @@ namespace xsd
         }
 
         void
-        push_back (std::auto_ptr x)
+        push_back (XSD_AUTO_PTR x)
         {
           if (x->_container () != container_)
             x->_container (container_);
@@ -1280,7 +1282,7 @@ namespace xsd
           v_.pop_back ();
         }
 
-        std::auto_ptr
+        XSD_AUTO_PTR
         detach_back (bool pop = true)
         {
           ptr& p (v_.back ());
@@ -1290,7 +1292,7 @@ namespace xsd
           if (pop)
             v_.pop_back ();
 
-          return std::auto_ptr (x);
+          return XSD_AUTO_PTR (x);
         }
 
         iterator
@@ -1302,7 +1304,7 @@ namespace xsd
         }
 
         iterator
-        insert (iterator position, std::auto_ptr x)
+        insert (iterator position, XSD_AUTO_PTR x)
         {
           if (x->_container () != container_)
             x->_container (container_);
@@ -1336,12 +1338,11 @@ namespace xsd
         }
 
         iterator
-        detach (iterator position, std::auto_ptr& r, bool erase = true)
+        detach (iterator position, XSD_AUTO_PTR& r, bool erase = true)
         {
           ptr& p (*position.base ());
           p->_container (0);
-          std::auto_ptr tmp (static_cast (p.release ()));
-          r = tmp;
+          r.reset (static_cast (p.release ()));
 
           if (erase)
             return iterator (v_.erase (position.base ()));
diff --git a/libxsd/xsd/cxx/tree/containers.txx b/libxsd/xsd/cxx/tree/containers.txx
index a27af48..7e45a02 100644
--- a/libxsd/xsd/cxx/tree/containers.txx
+++ b/libxsd/xsd/cxx/tree/containers.txx
@@ -4,6 +4,11 @@
 // license   : GNU GPL v2 + exceptions; see accompanying LICENSE file
 
 #include 
+
+#ifdef XSD_CXX11
+#  include  // std::move
+#endif
+
 #include 
 
 namespace xsd
@@ -38,10 +43,14 @@ namespace xsd
 
       template
       one::
-      one (std::auto_ptr x, container* c)
+      one (XSD_AUTO_PTR x, container* c)
           : x_ (0), container_ (c)
       {
+#ifdef XSD_CXX11
+        set (std::move (x));
+#else
         set (x);
+#endif
       }
 
       template
@@ -86,7 +95,7 @@ namespace xsd
 
       template
       void one::
-      set (std::auto_ptr x)
+      set (XSD_AUTO_PTR x)
       {
         T* r (0);
 
@@ -128,10 +137,14 @@ namespace xsd
 
       template 
       optional::
-      optional (std::auto_ptr x, container* c)
+      optional (XSD_AUTO_PTR x, container* c)
           : x_ (0), container_ (c)
       {
+#ifdef XSD_CXX11
+        set (std::move (x));
+#else
         set (x);
+#endif
       }
 
       template 
@@ -185,7 +198,7 @@ namespace xsd
 
       template 
       void optional::
-      set (std::auto_ptr x)
+      set (XSD_AUTO_PTR x)
       {
         T* r (0);
 
diff --git a/libxsd/xsd/cxx/tree/element-map.hxx b/libxsd/xsd/cxx/tree/element-map.hxx
index debfaed..b00bdbd 100644
--- a/libxsd/xsd/cxx/tree/element-map.hxx
+++ b/libxsd/xsd/cxx/tree/element-map.hxx
@@ -7,10 +7,12 @@
 #define XSD_CXX_TREE_ELEMENT_MAP_HXX
 
 #include 
-#include    // std::auto_ptr
+#include    // std::auto_ptr/unique_ptr
 #include   // std::size_t
 #include 
 
+#include  // XSD_AUTO_PTR
+
 #include 
 #include 
 
@@ -44,7 +46,7 @@ namespace xsd
          * @param f Flags to create the new element object with.
          * @return An automatic pointer to the new element object.
          */
-        static std::auto_ptr
+        static XSD_AUTO_PTR
         parse (const xercesc::DOMElement& e, flags f = 0);
 
         /**
@@ -61,7 +63,7 @@ namespace xsd
 
         typedef xml::qualified_name qualified_name;
 
-        typedef std::auto_ptr
+        typedef XSD_AUTO_PTR
         (*parser) (const xercesc::DOMElement&, flags f);
 
         typedef void
@@ -113,7 +115,7 @@ namespace xsd
       //
       //
       template
-      std::auto_ptr >
+      XSD_AUTO_PTR >
       parser_impl (const xercesc::DOMElement&, flags);
 
       template
diff --git a/libxsd/xsd/cxx/tree/elements.hxx b/libxsd/xsd/cxx/tree/elements.hxx
index 17ad70c..396e880 100644
--- a/libxsd/xsd/cxx/tree/elements.hxx
+++ b/libxsd/xsd/cxx/tree/elements.hxx
@@ -17,13 +17,19 @@
 #ifndef XSD_CXX_TREE_ELEMENTS_HXX
 #define XSD_CXX_TREE_ELEMENTS_HXX
 
+#include  // XSD_AUTO_PTR, XSD_CXX11
+
 #include 
 #include 
-#include   // std::auto_ptr
+#include   // std::auto_ptr/unique_ptr
 #include 
 #include 
 #include 
 
+#ifdef XSD_CXX11
+#  include  // std::move
+#endif
+
 #include 
 #include 
 #include 
@@ -33,7 +39,7 @@
 #include 
 
 #include  // xml::properties
-#include  // dom::auto_ptr
+#include  // dom::auto_ptr/unique_ptr
 
 #include 
 #include 
@@ -83,7 +89,7 @@ namespace xsd
          *
          * This flag only makes sense together with the @c keep_dom
          * flag in the call to the %parsing function with the
-         * @c dom::auto_ptr argument.
+         * @c dom::auto_ptr/unique_ptr argument.
          *
          */
         static const unsigned long own_dom = 0x00000200UL;
@@ -386,11 +392,7 @@ namespace xsd
           {
             // Drop DOM association.
             //
-            if (dom_info_.get ())
-            {
-              std::auto_ptr r (0);
-              dom_info_ = r;
-            }
+            dom_info_.reset ();
           }
 
           return *this;
@@ -444,7 +446,7 @@ namespace xsd
               dr = c;
           }
 
-          std::auto_ptr& m (dr ? dr->map_ : map_);
+          XSD_AUTO_PTR& m (dr ? dr->map_ : map_);
 
           if (container_ == 0)
           {
@@ -455,11 +457,16 @@ namespace xsd
               if (m.get () != 0)
               {
                 m->insert (map_->begin (), map_->end ());
-                std::auto_ptr tmp (0);
-                map_ = tmp;
+                map_.reset ();
               }
               else
+              {
+#ifdef XSD_CXX11
+                m = std::move (map_);
+#else
                 m = map_;
+#endif
+              }
             }
           }
           else
@@ -481,10 +488,7 @@ namespace xsd
                   // Part of our subtree.
                   //
                   if (m.get () == 0)
-                  {
-                    std::auto_ptr tmp (new map);
-                    m = tmp;
-                  }
+                    m.reset (new map);
 
                   m->insert (*i);
                   sr->map_->erase (i++);
@@ -599,37 +603,31 @@ namespace xsd
             {
               if (container_ != 0)
               {
-                // @@ Should be a throw.
-                //
                 assert (_root ()->_node () != 0);
                 assert (_root ()->_node ()->getOwnerDocument () ==
                         n->getOwnerDocument ());
               }
 
-              std::auto_ptr r (
+              dom_info_ =
                 dom_info_factory::create (
                   *static_cast (n),
                   *this,
-                  container_ == 0));
+                  container_ == 0);
 
-              dom_info_ = r;
               break;
             }
           case xercesc::DOMNode::ATTRIBUTE_NODE:
             {
-              //@@ Should be a throw.
-              //
               assert (container_ != 0);
               assert (_root ()->_node () != 0);
               assert (_root ()->_node ()->getOwnerDocument () ==
                       n->getOwnerDocument ());
 
-              std::auto_ptr r (
+              dom_info_ =
                 dom_info_factory::create (
                   *static_cast (n),
-                  *this));
+                  *this);
 
-              dom_info_ = r;
               break;
             }
           default:
@@ -650,10 +648,7 @@ namespace xsd
           assert (container_ == 0);
 
           if (map_.get () == 0)
-          {
-            std::auto_ptr tmp (new map);
-            map_ = tmp;
-          }
+            map_.reset (new map);
 
           if (!map_->insert (
                 std::pair (&i, t)).second)
@@ -714,7 +709,7 @@ namespace xsd
           {
           }
 
-          virtual std::auto_ptr
+          virtual XSD_AUTO_PTR
           clone (type& tree_node, container*) const = 0;
 
           virtual xercesc::DOMNode*
@@ -731,32 +726,35 @@ namespace xsd
         struct dom_element_info: public dom_info
         {
           dom_element_info (xercesc::DOMElement& e, type& n, bool root)
-              : doc_ (0), e_ (e)
+              : e_ (e)
           {
             e_.setUserData (user_data_keys::node, &n, 0);
 
             if (root)
             {
-              // The caller should have associated a dom::auto_ptr object
-              // that owns this document with the document node using the
-              // xml_schema::dom::tree_node_key key.
+              // The caller should have associated a dom::auto/unique_ptr
+              // object that owns this document with the document node
+              // using the xml_schema::dom::tree_node_key key.
               //
-              xml::dom::auto_ptr* pd (
-                reinterpret_cast*> (
+              XSD_DOM_AUTO_PTR* pd (
+                reinterpret_cast*> (
                   e.getOwnerDocument ()->getUserData (user_data_keys::node)));
 
               assert (pd != 0);
               assert (pd->get () == e.getOwnerDocument ());
 
-              doc_ = *pd; // Transfer ownership.
+              // Transfer ownership.
+#ifdef XSD_CXX11
+              doc_ = std::move (*pd);
+#else
+              doc_ = *pd;
+#endif
             }
           }
 
-          virtual std::auto_ptr
+          virtual XSD_AUTO_PTR
           clone (type& tree_node, container* c) const
           {
-            using std::auto_ptr;
-
             // Check if we are a document root.
             //
             if (c == 0)
@@ -764,11 +762,10 @@ namespace xsd
               // We preserver DOM associations only in complete
               // copies from root.
               //
-              if (doc_.get () == 0)
-                return auto_ptr (0);
-
-              return auto_ptr (
-                new dom_element_info (*doc_, tree_node));
+              return XSD_AUTO_PTR (
+                doc_.get () == 0
+                ? 0
+                : new dom_element_info (*doc_, tree_node));
             }
 
             // Check if our container does not have DOM association (e.g.,
@@ -779,8 +776,7 @@ namespace xsd
             DOMNode* cn (c->_node ());
 
             if (cn == 0)
-              return auto_ptr (0);
-
+              return XSD_AUTO_PTR ();
 
             // Now we are going to find the corresponding element in
             // the new tree.
@@ -812,7 +808,7 @@ namespace xsd
 
               assert (dn->getNodeType () == DOMNode::ELEMENT_NODE);
 
-              return auto_ptr (
+              return XSD_AUTO_PTR (
                 new dom_element_info (static_cast (*dn),
                                       tree_node,
                                       false));
@@ -835,7 +831,7 @@ namespace xsd
           }
 
         private:
-          xml::dom::auto_ptr doc_;
+          XSD_DOM_AUTO_PTR doc_;
           xercesc::DOMElement& e_;
         };
 
@@ -848,11 +844,9 @@ namespace xsd
             a_.setUserData (user_data_keys::node, &n, 0);
           }
 
-          virtual std::auto_ptr
+          virtual XSD_AUTO_PTR
           clone (type& tree_node, container* c) const
           {
-            using std::auto_ptr;
-
             // Check if we are a document root.
             //
             if (c == 0)
@@ -860,7 +854,7 @@ namespace xsd
               // We preserver DOM associations only in complete
               // copies from root.
               //
-              return auto_ptr (0);
+              return XSD_AUTO_PTR ();
             }
 
             // Check if our container does not have DOM association (e.g.,
@@ -871,7 +865,7 @@ namespace xsd
             DOMNode* cn (c->_node ());
 
             if (cn == 0)
-              return auto_ptr (0);
+              return XSD_AUTO_PTR ();
 
             // We are going to find the corresponding attribute in
             // the new tree.
@@ -898,7 +892,7 @@ namespace xsd
             DOMNode& n (*cn->getAttributes ()->item (i));
             assert (n.getNodeType () == DOMNode::ATTRIBUTE_NODE);
 
-            return auto_ptr (
+            return XSD_AUTO_PTR (
               new dom_attribute_info (static_cast (n), tree_node));
           }
 
@@ -919,18 +913,18 @@ namespace xsd
 
         struct dom_info_factory
         {
-          static std::auto_ptr
+          static XSD_AUTO_PTR
           create (const xercesc::DOMElement& e, type& n, bool root)
           {
-            return std::auto_ptr (
+            return XSD_AUTO_PTR (
               new dom_element_info (
                 const_cast (e), n, root));
           }
 
-          static std::auto_ptr
+          static XSD_AUTO_PTR
           create (const xercesc::DOMAttr& a, type& n)
           {
-            return std::auto_ptr (
+            return XSD_AUTO_PTR (
               new dom_attribute_info (
                 const_cast (a), n));
           }
@@ -938,7 +932,7 @@ namespace xsd
 
         //@endcond
 
-        std::auto_ptr dom_info_;
+        XSD_AUTO_PTR dom_info_;
 
 
         // ID/IDREF map.
@@ -961,7 +955,7 @@ namespace xsd
         std::map
         map;
 
-        std::auto_ptr map_;
+        XSD_AUTO_PTR map_;
 
       private:
         container* container_;
@@ -973,8 +967,7 @@ namespace xsd
       {
         if (x.dom_info_.get () != 0 && (f & flags::keep_dom))
         {
-          std::auto_ptr r (x.dom_info_->clone (*this, c));
-          dom_info_ = r;
+          dom_info_ = x.dom_info_->clone (*this, c);
         }
       }
 
@@ -1183,25 +1176,25 @@ namespace xsd
       {
         typedef T type;
 
-        static std::auto_ptr
+        static XSD_AUTO_PTR
         create (const xercesc::DOMElement& e, flags f, container* c)
         {
-          return std::auto_ptr (new T (e, f, c));
+          return XSD_AUTO_PTR (new T (e, f, c));
         }
 
-        static std::auto_ptr
+        static XSD_AUTO_PTR
         create (const xercesc::DOMAttr& a, flags f, container* c)
         {
-          return std::auto_ptr (new T (a, f, c));
+          return XSD_AUTO_PTR (new T (a, f, c));
         }
 
-        static std::auto_ptr
+        static XSD_AUTO_PTR
         create (const std::basic_string& s,
                 const xercesc::DOMElement* e,
                 flags f,
                 container* c)
         {
-          return std::auto_ptr (new T (s, e, f, c));
+          return XSD_AUTO_PTR (new T (s, e, f, c));
         }
       };
 
diff --git a/libxsd/xsd/cxx/tree/istream.hxx b/libxsd/xsd/cxx/tree/istream.hxx
index b76fdcb..1ff2bd8 100644
--- a/libxsd/xsd/cxx/tree/istream.hxx
+++ b/libxsd/xsd/cxx/tree/istream.hxx
@@ -8,9 +8,11 @@
 
 #include 
 #include 
-#include   // std::auto_ptr
+#include   // std::auto_ptr/unique_ptr
 #include  // std::size_t
 
+#include  // XSD_AUTO_PTR
+
 #include 
 
 namespace xsd
@@ -236,7 +238,7 @@ namespace xsd
 
         S& s_;
         std::size_t seq_;
-        std::auto_ptr pool_;
+        XSD_AUTO_PTR pool_;
       };
 
 
diff --git a/libxsd/xsd/cxx/tree/ostream.hxx b/libxsd/xsd/cxx/tree/ostream.hxx
index 7d8711e..fde681e 100644
--- a/libxsd/xsd/cxx/tree/ostream.hxx
+++ b/libxsd/xsd/cxx/tree/ostream.hxx
@@ -8,9 +8,11 @@
 
 #include 
 #include 
-#include   // std::auto_ptr
+#include   // std::auto_ptr/unique_ptr
 #include  // std::size_t
 
+#include  // XSD_AUTO_PTR
+
 namespace xsd
 {
   namespace cxx
@@ -187,7 +189,7 @@ namespace xsd
 
         S& s_;
         std::size_t seq_;
-        std::auto_ptr pool_;
+        XSD_AUTO_PTR pool_;
       };
 
 
diff --git a/libxsd/xsd/cxx/tree/parsing.txx b/libxsd/xsd/cxx/tree/parsing.txx
index e8bca99..14af025 100644
--- a/libxsd/xsd/cxx/tree/parsing.txx
+++ b/libxsd/xsd/cxx/tree/parsing.txx
@@ -35,25 +35,18 @@ namespace xsd
       //
       inline _type::
       _type (const xercesc::DOMElement& e, flags f, container* c)
-          : dom_info_ (0), container_ (c)
+          : container_ (c)
       {
         if (f & flags::keep_dom)
-        {
-          std::auto_ptr r (
-            dom_info_factory::create (e, *this, c == 0));
-          dom_info_ = r;
-        }
+          dom_info_ = dom_info_factory::create (e, *this, c == 0);
       }
 
       inline _type::
       _type (const xercesc::DOMAttr& a, flags f, container* c)
-          : dom_info_ (0), container_ (c)
+          : container_ (c)
       {
         if (f & flags::keep_dom)
-        {
-          std::auto_ptr r (dom_info_factory::create (a, *this));
-          dom_info_ = r;
-        }
+          dom_info_ = dom_info_factory::create (a, *this);
       }
 
       template 
@@ -62,8 +55,7 @@ namespace xsd
              const xercesc::DOMElement*,
              flags,
              container* c)
-          : dom_info_ (0), // List elements don't have associated DOM nodes.
-            container_ (c)
+          : container_ (c) // List elements don't have associated DOM nodes.
       {
       }
 
diff --git a/libxsd/xsd/cxx/tree/parsing/element-map.txx b/libxsd/xsd/cxx/tree/parsing/element-map.txx
index 71f23a8..a284c39 100644
--- a/libxsd/xsd/cxx/tree/parsing/element-map.txx
+++ b/libxsd/xsd/cxx/tree/parsing/element-map.txx
@@ -17,7 +17,7 @@ namespace xsd
     namespace tree
     {
       template 
-      std::auto_ptr > element_map::
+      XSD_AUTO_PTR > element_map::
       parse (const xercesc::DOMElement& e, flags f)
       {
         const qualified_name n (xml::dom::name (e));
@@ -30,10 +30,10 @@ namespace xsd
       }
 
       template
-      std::auto_ptr >
+      XSD_AUTO_PTR >
       parser_impl (const xercesc::DOMElement& e, flags f)
       {
-        return std::auto_ptr > (new T (e, f));
+        return XSD_AUTO_PTR > (new T (e, f));
       }
     }
   }
diff --git a/libxsd/xsd/cxx/tree/stream-extraction-map.hxx b/libxsd/xsd/cxx/tree/stream-extraction-map.hxx
index 1c18d51..245d786 100644
--- a/libxsd/xsd/cxx/tree/stream-extraction-map.hxx
+++ b/libxsd/xsd/cxx/tree/stream-extraction-map.hxx
@@ -7,9 +7,11 @@
 #define XSD_CXX_TREE_STREAM_EXTRACTION_MAP_HXX
 
 #include 
-#include   // std::auto_ptr
+#include   // std::auto_ptr/unique_ptr
 #include  // std::size_t
 
+#include  // XSD_AUTO_PTR
+
 #include 
 #include 
 #include 
@@ -24,7 +26,7 @@ namespace xsd
       struct stream_extraction_map
       {
         typedef xml::qualified_name qualified_name;
-        typedef std::auto_ptr (*extractor) (
+        typedef XSD_AUTO_PTR (*extractor) (
           istream&, flags, container*);
 
       public:
@@ -38,7 +40,7 @@ namespace xsd
         void
         unregister_type (const qualified_name& name);
 
-        std::auto_ptr
+        XSD_AUTO_PTR
         extract (istream&, flags, container*);
 
       public:
@@ -82,7 +84,7 @@ namespace xsd
       //
       //
       template
-      std::auto_ptr
+      XSD_AUTO_PTR
       extractor_impl (istream&, flags, container*);
 
 
diff --git a/libxsd/xsd/cxx/tree/stream-extraction-map.txx b/libxsd/xsd/cxx/tree/stream-extraction-map.txx
index 17b3fc5..156f9c0 100644
--- a/libxsd/xsd/cxx/tree/stream-extraction-map.txx
+++ b/libxsd/xsd/cxx/tree/stream-extraction-map.txx
@@ -233,7 +233,7 @@ namespace xsd
       }
 
       template 
-      std::auto_ptr stream_extraction_map::
+      XSD_AUTO_PTR stream_extraction_map::
       extract (istream& s, flags f, container* c)
       {
         std::basic_string ns, name;
@@ -303,10 +303,10 @@ namespace xsd
       //
       //
       template
-      std::auto_ptr
+      XSD_AUTO_PTR
       extractor_impl (istream& s, flags f, container* c)
       {
-        return std::auto_ptr (new T (s, f, c));
+        return XSD_AUTO_PTR (new T (s, f, c));
       }
 
 
diff --git a/libxsd/xsd/cxx/tree/stream-extraction.hxx b/libxsd/xsd/cxx/tree/stream-extraction.hxx
index eef60ca..e4a1740 100644
--- a/libxsd/xsd/cxx/tree/stream-extraction.hxx
+++ b/libxsd/xsd/cxx/tree/stream-extraction.hxx
@@ -67,8 +67,7 @@ namespace xsd
 
           while (size--)
           {
-            std::auto_ptr p (new T (s, f, c));
-            this->push_back (p);
+            this->push_back (XSD_AUTO_PTR (new T (s, f, c)));
           }
         }
       }
diff --git a/libxsd/xsd/cxx/tree/type-factory-map.hxx b/libxsd/xsd/cxx/tree/type-factory-map.hxx
index a42ef96..ea173cc 100644
--- a/libxsd/xsd/cxx/tree/type-factory-map.hxx
+++ b/libxsd/xsd/cxx/tree/type-factory-map.hxx
@@ -8,11 +8,13 @@
 
 #include 
 #include 
-#include   // std::auto_ptr
+#include   // std::auto_ptr/unique_ptr
 #include  // std::size_t
 
 #include 
 
+#include  // XSD_AUTO_PTR
+
 #include 
 #include 
 
@@ -26,9 +28,9 @@ namespace xsd
       struct type_factory_map
       {
         typedef xml::qualified_name qualified_name;
-        typedef std::auto_ptr (*factory) (const xercesc::DOMElement&,
-                                                flags,
-                                                container*);
+        typedef XSD_AUTO_PTR (*factory) (const xercesc::DOMElement&,
+                                               flags,
+                                               container*);
       public:
         type_factory_map ();
 
@@ -49,7 +51,7 @@ namespace xsd
         unregister_element (const qualified_name& root,
                             const qualified_name& subst);
 
-        std::auto_ptr
+        XSD_AUTO_PTR
         create (const C* name, // element name
                 const C* ns,   // element namespace
                 factory static_type,
@@ -66,7 +68,7 @@ namespace xsd
 
       private:
         template 
-        static std::auto_ptr
+        static XSD_AUTO_PTR
         traits_adapter (const xercesc::DOMElement&, flags, container*);
 
       private:
@@ -132,7 +134,7 @@ namespace xsd
       //
       //
       template
-      std::auto_ptr
+      XSD_AUTO_PTR
       factory_impl (const xercesc::DOMElement&, flags, container*);
 
       //
diff --git a/libxsd/xsd/cxx/tree/type-factory-map.txx b/libxsd/xsd/cxx/tree/type-factory-map.txx
index 998fb7b..174147c 100644
--- a/libxsd/xsd/cxx/tree/type-factory-map.txx
+++ b/libxsd/xsd/cxx/tree/type-factory-map.txx
@@ -273,7 +273,7 @@ namespace xsd
       }
 
       template 
-      std::auto_ptr type_factory_map::
+      XSD_AUTO_PTR type_factory_map::
       create (const C* name,
               const C* ns,
               factory static_type,
@@ -307,7 +307,7 @@ namespace xsd
         }
 
         if (f == 0)
-          return std::auto_ptr (0); // No match.
+          return XSD_AUTO_PTR (); // No match.
 
         // Check for xsi:type
         //
@@ -326,11 +326,10 @@ namespace xsd
 
       template 
       template 
-      std::auto_ptr type_factory_map::
+      XSD_AUTO_PTR type_factory_map::
       traits_adapter (const xercesc::DOMElement& e, flags f, container* c)
       {
-        std::auto_ptr r (traits::create (e, f, c));
-        return std::auto_ptr (r.release ());
+        return XSD_AUTO_PTR (traits::create (e, f, c));
       }
 
       template 
@@ -428,10 +427,10 @@ namespace xsd
       //
       //
       template
-      std::auto_ptr
+      XSD_AUTO_PTR
       factory_impl (const xercesc::DOMElement& e, flags f, container* c)
       {
-        return std::auto_ptr (new T (e, f, c));
+        return XSD_AUTO_PTR (new T (e, f, c));
       }
 
       //
diff --git a/libxsd/xsd/cxx/tree/type-serializer-map.hxx b/libxsd/xsd/cxx/tree/type-serializer-map.hxx
index 0ac9299..ca52129 100644
--- a/libxsd/xsd/cxx/tree/type-serializer-map.hxx
+++ b/libxsd/xsd/cxx/tree/type-serializer-map.hxx
@@ -16,6 +16,7 @@
 #include 
 
 #include 
+#include 
 #include  // namespace_infomap
 
 namespace xsd
@@ -70,7 +71,7 @@ namespace xsd
         // Create DOMDocument with root element suitable for serializing
         // x into it.
         //
-        xml::dom::auto_ptr
+        XSD_DOM_AUTO_PTR
         serialize (const C* name, // element name
                    const C* ns,   // element namespace
                    const xml::dom::namespace_infomap&,
diff --git a/libxsd/xsd/cxx/tree/type-serializer-map.txx b/libxsd/xsd/cxx/tree/type-serializer-map.txx
index 1dd1e52..454282e 100644
--- a/libxsd/xsd/cxx/tree/type-serializer-map.txx
+++ b/libxsd/xsd/cxx/tree/type-serializer-map.txx
@@ -399,7 +399,7 @@ namespace xsd
       }
 
       template 
-      xml::dom::auto_ptr type_serializer_map::
+      XSD_DOM_AUTO_PTR type_serializer_map::
       serialize (const C* name,
                  const C* ns,
                  const xml::dom::namespace_infomap& m,
diff --git a/libxsd/xsd/cxx/tree/types.txx b/libxsd/xsd/cxx/tree/types.txx
index 98fcf81..61cb419 100644
--- a/libxsd/xsd/cxx/tree/types.txx
+++ b/libxsd/xsd/cxx/tree/types.txx
@@ -6,7 +6,13 @@
 #include 
 #include 
 
-#include 
+#include  // XSD_CXX11
+
+#ifdef XSD_CXX11
+#  include  // std::unique_ptr
+#else
+#  include 
+#endif
 
 #include 
 
@@ -318,9 +324,13 @@ namespace xsd
         std::basic_string str;
 
         XMLSize_t n;
-
         xml::std_memory_manager mm;
+
+#ifdef XSD_CXX11
+        std::unique_ptr r (
+#else
         auto_array r (
+#endif
           Base64::encode (
             reinterpret_cast (this->data ()),
             static_cast (this->size ()),
@@ -353,9 +363,13 @@ namespace xsd
         xml::std_memory_manager mm;
         XMLSize_t size;
 
+#ifdef XSD_CXX11
+        std::unique_ptr data (
+#else
         auto_array data (
+#endif
           Base64::decodeToXMLByte (src, &size, &mm, Base64::Conf_RFC2045),
-	  mm);
+          mm);
 
         if (data)
         {
diff --git a/libxsd/xsd/cxx/xml/char-iso8859-1.txx b/libxsd/xsd/cxx/xml/char-iso8859-1.txx
index ff82963..3ce88ad 100644
--- a/libxsd/xsd/cxx/xml/char-iso8859-1.txx
+++ b/libxsd/xsd/cxx/xml/char-iso8859-1.txx
@@ -3,7 +3,13 @@
 // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
 // license   : GNU GPL v2 + exceptions; see accompanying LICENSE file
 
-#include 
+#include  // XSD_CXX11
+
+#ifdef XSD_CXX11
+#  include  // std::unique_ptr
+#else
+#  include 
+#endif
 
 namespace xsd
 {
@@ -87,7 +93,12 @@ namespace xsd
       {
         const C* end (s + len);
 
-        auto_array r (new XMLCh[len + 1]);
+#ifdef XSD_CXX11
+        std::unique_ptr r (
+#else
+        auto_array r (
+#endif
+          new XMLCh[len + 1]);
         XMLCh* ir (r.get ());
 
         for (const C* p (s); p < end; ++p)
diff --git a/libxsd/xsd/cxx/xml/char-lcp.txx b/libxsd/xsd/cxx/xml/char-lcp.txx
index 7bd8862..21c85d0 100644
--- a/libxsd/xsd/cxx/xml/char-lcp.txx
+++ b/libxsd/xsd/cxx/xml/char-lcp.txx
@@ -7,7 +7,14 @@
 
 #include 
 
-#include 
+#include  // XSD_CXX11
+
+#ifdef XSD_CXX11
+#  include  // std::unique_ptr
+#else
+#  include 
+#endif
+
 #include 
 
 namespace xsd
@@ -21,7 +28,11 @@ namespace xsd
       to (const XMLCh* s)
       {
         std_memory_manager mm;
+#ifdef XSD_CXX11
+        std::unique_ptr r (
+#else
         auto_array r (
+#endif
           xercesc::XMLString::transcode (s, &mm), mm);
         return std::basic_string (r.get ());
       }
@@ -30,12 +41,21 @@ namespace xsd
       std::basic_string char_lcp_transcoder::
       to (const XMLCh* s, std::size_t len)
       {
-        auto_array tmp (new XMLCh[len + 1]);
+#ifdef XSD_CXX11
+        std::unique_ptr tmp (
+#else
+        auto_array tmp (
+#endif
+          new XMLCh[len + 1]);
         std::memcpy (tmp.get (), s, len * sizeof (XMLCh));
         tmp[len] = XMLCh (0);
 
         std_memory_manager mm;
+#ifdef XSD_CXX11
+        std::unique_ptr r (
+#else
         auto_array r (
+#endif
           xercesc::XMLString::transcode (tmp.get (), &mm), mm);
 
         tmp.reset ();
diff --git a/libxsd/xsd/cxx/xml/char-utf8.txx b/libxsd/xsd/cxx/xml/char-utf8.txx
index ff3f9e0..7dc0ac9 100644
--- a/libxsd/xsd/cxx/xml/char-utf8.txx
+++ b/libxsd/xsd/cxx/xml/char-utf8.txx
@@ -3,7 +3,13 @@
 // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
 // license   : GNU GPL v2 + exceptions; see accompanying LICENSE file
 
-#include 
+#include  // XSD_CXX11
+
+#ifdef XSD_CXX11
+#  include  // std::unique_ptr
+#else
+#  include 
+#endif
 
 namespace xsd
 {
@@ -184,7 +190,12 @@ namespace xsd
         if (!valid)
           throw invalid_utf8_string ();
 
-        auto_array r (new XMLCh[rl + 1]);
+#ifdef XSD_CXX11
+        std::unique_ptr r (
+#else
+        auto_array r (
+#endif
+          new XMLCh[rl + 1]);
         XMLCh* ir (r.get ());
 
         unsigned int u (0); // Four byte UCS-4 char.
diff --git a/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx b/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx
index d94ba13..b8c9aa3 100644
--- a/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx
+++ b/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx
@@ -6,6 +6,14 @@
 #ifndef XSD_CXX_XML_DOM_AUTO_PTR_HXX
 #define XSD_CXX_XML_DOM_AUTO_PTR_HXX
 
+#include  // XSD_CXX11_*
+
+#ifdef XSD_CXX11
+#  include       // std::unique_ptr
+#  include      // std::move
+#  include  // std::remove_const
+#endif
+
 namespace xsd
 {
   namespace cxx
@@ -14,9 +22,73 @@ namespace xsd
     {
       namespace dom
       {
-        // Simple auto_ptr version that calls release() instead of delete.
-        //
+#ifdef XSD_CXX11
+        template 
+        struct deleter
+        {
+          void
+          operator() (T* p) const
+          {
+            if (p != 0)
+              const_cast::type*> (p)->release ();
+          }
+        };
+
+#ifdef XSD_CXX11_TEMPLATE_ALIAS
+        template 
+        using unique_ptr = std::unique_ptr>;
+#else
+        template 
+        class unique_ptr: public std::unique_ptr>
+        {
+        public:
+          typedef std::unique_ptr> base;
+
+          typedef typename base::pointer pointer;
+          typedef T element_type;
+          typedef deleter deleter_type;
+
+          unique_ptr (): base () {}
+          explicit unique_ptr (pointer p): base (p) {}
+          unique_ptr (pointer p, const deleter_type& d): base (p, d) {}
+          unique_ptr (pointer p, deleter_type&& d): base (p, std::move (d)) {}
+          unique_ptr (unique_ptr&& p): base (std::move (p)) {}
+          template 
+          unique_ptr (unique_ptr&& p): base (std::move (p)) {}
+          template 
+          unique_ptr (std::auto_ptr&& p): base (std::move (p)) {}
+
+          unique_ptr& operator= (unique_ptr&& p)
+          {
+            static_cast (*this) = std::move (p);
+            return *this;
+          }
 
+          template 
+          unique_ptr& operator= (unique_ptr&& p)
+          {
+            static_cast (*this) = std::move (p);
+            return *this;
+          }
+
+#ifdef XSD_CXX11_NULLPTR
+          unique_ptr (std::nullptr_t p): base (p) {}
+
+          unique_ptr& operator= (std::nullptr_t p)
+          {
+            static_cast (*this) = p;
+            return *this;
+          }
+#endif
+        };
+#endif // XSD_CXX11_TEMPLATE_ALIAS
+
+#define XSD_DOM_AUTO_PTR xsd::cxx::xml::dom::unique_ptr
+
+#else
+        // Simple auto_ptr version for C++98 that calls release() instead
+        // of delete.
+        //
         template 
         struct remove_c
         {
@@ -150,6 +222,10 @@ namespace xsd
         private:
           T* x_;
         };
+
+#define XSD_DOM_AUTO_PTR xsd::cxx::xml::dom::auto_ptr
+
+#endif // XSD_CXX11
       }
     }
   }
diff --git a/libxsd/xsd/cxx/xml/dom/parsing-source.hxx b/libxsd/xsd/cxx/xml/dom/parsing-source.hxx
index f35f99d..1daac34 100644
--- a/libxsd/xsd/cxx/xml/dom/parsing-source.hxx
+++ b/libxsd/xsd/cxx/xml/dom/parsing-source.hxx
@@ -19,7 +19,6 @@
 
 #include       // properies
 #include 
-
 #include 
 #include   // name
 #include 
@@ -102,28 +101,28 @@ namespace xsd
         const unsigned long no_muliple_imports = 0x00000800UL;
 
         template 
-        xml::dom::auto_ptr
+        XSD_DOM_AUTO_PTR
         parse (xercesc::InputSource&,
                error_handler&,
                const properties&,
                unsigned long flags);
 
         template 
-        xml::dom::auto_ptr
+        XSD_DOM_AUTO_PTR
         parse (xercesc::InputSource&,
                xercesc::DOMErrorHandler&,
                const properties&,
                unsigned long flags);
 
         template 
-        xml::dom::auto_ptr
+        XSD_DOM_AUTO_PTR
         parse (const std::basic_string& uri,
                error_handler&,
                const properties&,
                unsigned long flags);
 
         template 
-        xml::dom::auto_ptr
+        XSD_DOM_AUTO_PTR
         parse (const std::basic_string& uri,
                xercesc::DOMErrorHandler&,
                const properties&,
diff --git a/libxsd/xsd/cxx/xml/dom/parsing-source.txx b/libxsd/xsd/cxx/xml/dom/parsing-source.txx
index d2152ac..352114d 100644
--- a/libxsd/xsd/cxx/xml/dom/parsing-source.txx
+++ b/libxsd/xsd/cxx/xml/dom/parsing-source.txx
@@ -68,7 +68,7 @@ namespace xsd
         // parse()
         //
         template 
-        xml::dom::auto_ptr
+        XSD_DOM_AUTO_PTR
         parse (xercesc::InputSource& is,
                error_handler& eh,
                const properties& prop,
@@ -79,7 +79,7 @@ namespace xsd
         }
 
         template 
-        auto_ptr
+        XSD_DOM_AUTO_PTR
         parse (xercesc::InputSource& is,
                xercesc::DOMErrorHandler& eh,
                const properties& prop,
@@ -98,7 +98,7 @@ namespace xsd
           DOMImplementation* impl (
             DOMImplementationRegistry::getDOMImplementation (ls_id));
 
-          auto_ptr parser (
+          XSD_DOM_AUTO_PTR parser (
             impl->createLSParser (DOMImplementationLS::MODE_SYNCHRONOUS, 0));
 
           DOMConfiguration* conf (parser->getDomConfig ());
@@ -196,7 +196,7 @@ namespace xsd
 
           xercesc::Wrapper4InputSource wrap (&is, false);
 
-          auto_ptr doc;
+          XSD_DOM_AUTO_PTR doc;
           try
           {
             doc.reset (parser->parse (&wrap));
@@ -212,7 +212,7 @@ namespace xsd
         }
 
         template 
-        xml::dom::auto_ptr
+        XSD_DOM_AUTO_PTR
         parse (const std::basic_string& uri,
                error_handler& eh,
                const properties& prop,
@@ -223,7 +223,7 @@ namespace xsd
         }
 
         template 
-        auto_ptr
+        XSD_DOM_AUTO_PTR
         parse (const std::basic_string& uri,
                xercesc::DOMErrorHandler& eh,
                const properties& prop,
@@ -242,7 +242,7 @@ namespace xsd
           DOMImplementation* impl (
             DOMImplementationRegistry::getDOMImplementation (ls_id));
 
-          auto_ptr parser (
+          XSD_DOM_AUTO_PTR parser (
             impl->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0));
 
           DOMConfiguration* conf (parser->getDomConfig ());
@@ -339,7 +339,7 @@ namespace xsd
           bits::error_handler_proxy ehp (eh);
           conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp);
 
-          auto_ptr doc;
+          XSD_DOM_AUTO_PTR doc;
           try
           {
             doc.reset (parser->parseURI (string (uri).c_str ()));
diff --git a/libxsd/xsd/cxx/xml/dom/serialization-source.hxx b/libxsd/xsd/cxx/xml/dom/serialization-source.hxx
index 9bfd27b..3b23220 100644
--- a/libxsd/xsd/cxx/xml/dom/serialization-source.hxx
+++ b/libxsd/xsd/cxx/xml/dom/serialization-source.hxx
@@ -53,7 +53,7 @@ namespace xsd
         const unsigned long dont_pretty_print  = 0x00020000UL;
 
         template 
-        xml::dom::auto_ptr
+        XSD_DOM_AUTO_PTR
         serialize (const std::basic_string& root_element,
                    const std::basic_string& root_element_namespace,
                    const namespace_infomap& map,
@@ -62,7 +62,7 @@ namespace xsd
         // This one helps Sun C++ to overcome its fears.
         //
         template 
-        inline xml::dom::auto_ptr
+        inline XSD_DOM_AUTO_PTR
         serialize (const C* root_element,
                    const C* root_element_namespace,
                    const namespace_infomap& map,
diff --git a/libxsd/xsd/cxx/xml/dom/serialization-source.txx b/libxsd/xsd/cxx/xml/dom/serialization-source.txx
index 7de5ca0..efd4141 100644
--- a/libxsd/xsd/cxx/xml/dom/serialization-source.txx
+++ b/libxsd/xsd/cxx/xml/dom/serialization-source.txx
@@ -110,7 +110,7 @@ namespace xsd
         //
         //
         template 
-        auto_ptr
+        XSD_DOM_AUTO_PTR
         serialize (const std::basic_string& el,
                    const std::basic_string& ns,
                    const namespace_infomap& map,
@@ -153,7 +153,7 @@ namespace xsd
           DOMImplementation* impl (
             DOMImplementationRegistry::getDOMImplementation (ls));
 
-          auto_ptr doc (
+          XSD_DOM_AUTO_PTR doc (
             impl->createDocument (
               (ns.empty () ? 0 : xml::string (ns).c_str ()),
               xml::string ((prefix.empty ()
@@ -295,7 +295,7 @@ namespace xsd
 
           bits::error_handler_proxy ehp (eh);
 
-          xml::dom::auto_ptr writer (
+          XSD_DOM_AUTO_PTR writer (
             impl->createLSSerializer ());
 
           DOMConfiguration* conf (writer->getDomConfig ());
@@ -318,7 +318,7 @@ namespace xsd
               conf->canSetParameter (XMLUni::fgDOMXMLDeclaration, false))
             conf->setParameter (XMLUni::fgDOMXMLDeclaration, false);
 
-          xml::dom::auto_ptr out (impl->createLSOutput ());
+          XSD_DOM_AUTO_PTR out (impl->createLSOutput ());
 
           out->setEncoding (xml::string (encoding).c_str ());
           out->setByteStream (&target);
diff --git a/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx b/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx
index 55d083b..225f5df 100644
--- a/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx
+++ b/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx
@@ -19,7 +19,7 @@ namespace xsd
       namespace dom
       {
         template 
-        xml::dom::auto_ptr
+        XSD_DOM_AUTO_PTR
         create_document ();
       }
     }
diff --git a/libxsd/xsd/cxx/xml/dom/wildcard-source.txx b/libxsd/xsd/cxx/xml/dom/wildcard-source.txx
index 7feb937..bd2817f 100644
--- a/libxsd/xsd/cxx/xml/dom/wildcard-source.txx
+++ b/libxsd/xsd/cxx/xml/dom/wildcard-source.txx
@@ -17,7 +17,7 @@ namespace xsd
       namespace dom
       {
         template 
-        xml::dom::auto_ptr
+        XSD_DOM_AUTO_PTR
         create_document ()
         {
           const XMLCh ls[] = {xercesc::chLatin_L,
@@ -29,7 +29,7 @@ namespace xsd
           xercesc::DOMImplementation* impl (
             xercesc::DOMImplementationRegistry::getDOMImplementation (ls));
 
-          return xml::dom::auto_ptr (
+          return XSD_DOM_AUTO_PTR (
             impl->createDocument ());
         }
       }
diff --git a/libxsd/xsd/cxx/xml/std-memory-manager.hxx b/libxsd/xsd/cxx/xml/std-memory-manager.hxx
index bd8fbab..00012fd 100644
--- a/libxsd/xsd/cxx/xml/std-memory-manager.hxx
+++ b/libxsd/xsd/cxx/xml/std-memory-manager.hxx
@@ -18,6 +18,8 @@ namespace xsd
       class std_memory_manager: public xercesc::MemoryManager
       {
       public:
+        // Xerces-C++ MemoryManager interface.
+        //
         virtual void*
         allocate(XMLSize_t size)
         {
@@ -36,6 +38,15 @@ namespace xsd
         {
           return xercesc::XMLPlatformUtils::fgMemoryManager;
         }
+
+        // Standard deleter interface.
+        //
+        void
+        operator() (void* p) const
+        {
+          if (p)
+	    operator delete (p);
+        }
       };
     }
   }
diff --git a/libxsd/xsd/cxx/xml/string.hxx b/libxsd/xsd/cxx/xml/string.hxx
index f1a907c..832e7ec 100644
--- a/libxsd/xsd/cxx/xml/string.hxx
+++ b/libxsd/xsd/cxx/xml/string.hxx
@@ -9,9 +9,16 @@
 #include 
 #include  // std::size_t
 
-#include 
 #include  // XMLCh
 
+#include  // XSD_CXX11
+
+#ifdef XSD_CXX11
+#  include  // std::unique_ptr
+#else
+#  include 
+#endif
+
 namespace xsd
 {
   namespace cxx
@@ -73,7 +80,11 @@ namespace xsd
         operator= (const string&);
 
       private:
+#ifdef XSD_CXX11
+        std::unique_ptr s_;
+#else
         auto_array s_;
+#endif
       };
     }
   }
diff --git a/libxsd/xsd/cxx/xml/string.txx b/libxsd/xsd/cxx/xml/string.txx
index 830ed92..c6f1d20 100644
--- a/libxsd/xsd/cxx/xml/string.txx
+++ b/libxsd/xsd/cxx/xml/string.txx
@@ -47,7 +47,13 @@ namespace xsd
         XMLCh* wchar_transcoder::
         from (const W* s, std::size_t length)
         {
-          auto_array r (new XMLCh[length + 1]);
+#ifdef XSD_CXX11
+          std::unique_ptr r (
+#else
+          auto_array r (
+#endif
+            new XMLCh[length + 1]);
+
           XMLCh* ir (r.get ());
 
           for (std::size_t i (0); i < length; ++ir, ++i)
@@ -120,7 +126,13 @@ namespace xsd
             rl += (*p & 0xFFFF0000) ? 2 : 1;
           }
 
-          auto_array r (new XMLCh[rl + 1]);
+#ifdef XSD_CXX11
+          std::unique_ptr r (
+#else
+          auto_array r (
+#endif
+            new XMLCh[rl + 1]);
+
           XMLCh* ir (r.get ());
 
           for (const W* p (s); p < s + length; ++p)
diff --git a/tests/cxx/parser/built-in/driver.cxx b/tests/cxx/parser/built-in/driver.cxx
index b095af0..f9497f6 100644
--- a/tests/cxx/parser/built-in/driver.cxx
+++ b/tests/cxx/parser/built-in/driver.cxx
@@ -24,7 +24,7 @@ struct any_type_pimpl: xml_schema::any_type_pimpl
   }
 
   virtual void
-  _start_any_element (ro_string const&, 
+  _start_any_element (ro_string const&,
                       ro_string const& n,
 		      ro_string const*)
   {
@@ -278,14 +278,14 @@ struct type_pimpl: type_pskel
   }
 
   virtual void
-  base64_binary (std::auto_ptr v)
+  base64_binary (XSD_AUTO_PTR v)
   {
     std::string tmp (v->data (), v->size ());
     cout << "'" << tmp << "'" << endl;
   }
 
   virtual void
-  hex_binary (std::auto_ptr v)
+  hex_binary (XSD_AUTO_PTR v)
   {
     std::string tmp (v->data (), v->size ());
     cout << "'" << tmp << "'" << endl;
diff --git a/tests/cxx/parser/built-in/makefile b/tests/cxx/parser/built-in/makefile
index 821d519..fe73631 100644
--- a/tests/cxx/parser/built-in/makefile
+++ b/tests/cxx/parser/built-in/makefile
@@ -71,7 +71,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/enumeration/makefile b/tests/cxx/parser/enumeration/makefile
index a60bb9a..af3ae5f 100644
--- a/tests/cxx/parser/enumeration/makefile
+++ b/tests/cxx/parser/enumeration/makefile
@@ -72,7 +72,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/generated-impl/makefile b/tests/cxx/parser/generated-impl/makefile
index e5714d7..8cb3998 100644
--- a/tests/cxx/parser/generated-impl/makefile
+++ b/tests/cxx/parser/generated-impl/makefile
@@ -82,7 +82,12 @@ $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
 
 xsd_parser_impl_suffix := -pimpl
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/list/makefile b/tests/cxx/parser/list/makefile
index db93e57..535f443 100644
--- a/tests/cxx/parser/list/makefile
+++ b/tests/cxx/parser/list/makefile
@@ -71,7 +71,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/name-clash/inheritance/makefile b/tests/cxx/parser/name-clash/inheritance/makefile
index 579c8e5..e574fc7 100644
--- a/tests/cxx/parser/name-clash/inheritance/makefile
+++ b/tests/cxx/parser/name-clash/inheritance/makefile
@@ -72,7 +72,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/polymorphism/recursive/makefile b/tests/cxx/parser/polymorphism/recursive/makefile
index 4baf0e7..a6def7d 100644
--- a/tests/cxx/parser/polymorphism/recursive/makefile
+++ b/tests/cxx/parser/polymorphism/recursive/makefile
@@ -72,7 +72,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/polymorphism/same-type/makefile b/tests/cxx/parser/polymorphism/same-type/makefile
index 3930e70..97379dd 100644
--- a/tests/cxx/parser/polymorphism/same-type/makefile
+++ b/tests/cxx/parser/polymorphism/same-type/makefile
@@ -72,7 +72,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/recursive/makefile b/tests/cxx/parser/recursive/makefile
index 44ef977..292ec38 100644
--- a/tests/cxx/parser/recursive/makefile
+++ b/tests/cxx/parser/recursive/makefile
@@ -72,7 +72,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/test-template/makefile b/tests/cxx/parser/test-template/makefile
index 2ed7d5c..09d8fb5 100644
--- a/tests/cxx/parser/test-template/makefile
+++ b/tests/cxx/parser/test-template/makefile
@@ -71,7 +71,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/union/makefile b/tests/cxx/parser/union/makefile
index 1878461..0215274 100644
--- a/tests/cxx/parser/union/makefile
+++ b/tests/cxx/parser/union/makefile
@@ -71,7 +71,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/validation/all/makefile b/tests/cxx/parser/validation/all/makefile
index ec737aa..9492596 100644
--- a/tests/cxx/parser/validation/all/makefile
+++ b/tests/cxx/parser/validation/all/makefile
@@ -81,7 +81,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/validation/any/makefile b/tests/cxx/parser/validation/any/makefile
index ba09d32..5255faa 100644
--- a/tests/cxx/parser/validation/any/makefile
+++ b/tests/cxx/parser/validation/any/makefile
@@ -81,7 +81,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/validation/attribute/makefile b/tests/cxx/parser/validation/attribute/makefile
index b1c0589..056f82a 100644
--- a/tests/cxx/parser/validation/attribute/makefile
+++ b/tests/cxx/parser/validation/attribute/makefile
@@ -81,7 +81,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/validation/built-in/any-type/makefile b/tests/cxx/parser/validation/built-in/any-type/makefile
index e09eea6..90c7ddd 100644
--- a/tests/cxx/parser/validation/built-in/any-type/makefile
+++ b/tests/cxx/parser/validation/built-in/any-type/makefile
@@ -81,7 +81,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/validation/built-in/binary/makefile b/tests/cxx/parser/validation/built-in/binary/makefile
index 72fe813..cd3d283 100644
--- a/tests/cxx/parser/validation/built-in/binary/makefile
+++ b/tests/cxx/parser/validation/built-in/binary/makefile
@@ -28,6 +28,13 @@ $(driver): $(obj) $(xerces_c.l)
 $(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
 $(obj) $(dep): $(xerces_c.l.cpp-options)
 
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifeq ($(cxx_standard),c++11)
+$(obj) $(dep): cpp_options += -DXSD_CXX11
+endif
+
 $(call include-dep,$(dep),$(obj),$(gen))
 
 # Convenience alias for default target.
diff --git a/tests/cxx/parser/validation/built-in/boolean/makefile b/tests/cxx/parser/validation/built-in/boolean/makefile
index c9104af..a7b13c2 100644
--- a/tests/cxx/parser/validation/built-in/boolean/makefile
+++ b/tests/cxx/parser/validation/built-in/boolean/makefile
@@ -28,6 +28,13 @@ $(driver): $(obj) $(xerces_c.l)
 $(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
 $(obj) $(dep): $(xerces_c.l.cpp-options)
 
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifeq ($(cxx_standard),c++11)
+$(obj) $(dep): cpp_options += -DXSD_CXX11
+endif
+
 $(call include-dep,$(dep),$(obj),$(gen))
 
 # Convenience alias for default target.
diff --git a/tests/cxx/parser/validation/built-in/byte/makefile b/tests/cxx/parser/validation/built-in/byte/makefile
index 6d11d98..0c7c0d9 100644
--- a/tests/cxx/parser/validation/built-in/byte/makefile
+++ b/tests/cxx/parser/validation/built-in/byte/makefile
@@ -28,6 +28,13 @@ $(driver): $(obj) $(xerces_c.l)
 $(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
 $(obj) $(dep): $(xerces_c.l.cpp-options)
 
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifeq ($(cxx_standard),c++11)
+$(obj) $(dep): cpp_options += -DXSD_CXX11
+endif
+
 $(call include-dep,$(dep),$(obj),$(gen))
 
 # Convenience alias for default target.
diff --git a/tests/cxx/parser/validation/built-in/date-time/makefile b/tests/cxx/parser/validation/built-in/date-time/makefile
index 3feb7ab..7028315 100644
--- a/tests/cxx/parser/validation/built-in/date-time/makefile
+++ b/tests/cxx/parser/validation/built-in/date-time/makefile
@@ -28,6 +28,13 @@ $(driver): $(obj) $(xerces_c.l)
 $(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
 $(obj) $(dep): $(xerces_c.l.cpp-options)
 
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifeq ($(cxx_standard),c++11)
+$(obj) $(dep): cpp_options += -DXSD_CXX11
+endif
+
 $(call include-dep,$(dep),$(obj),$(gen))
 
 # Convenience alias for default target.
diff --git a/tests/cxx/parser/validation/built-in/float/makefile b/tests/cxx/parser/validation/built-in/float/makefile
index 12ddcd4..224b101 100644
--- a/tests/cxx/parser/validation/built-in/float/makefile
+++ b/tests/cxx/parser/validation/built-in/float/makefile
@@ -28,6 +28,13 @@ $(driver): $(obj) $(xerces_c.l)
 $(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
 $(obj) $(dep): $(xerces_c.l.cpp-options)
 
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifeq ($(cxx_standard),c++11)
+$(obj) $(dep): cpp_options += -DXSD_CXX11
+endif
+
 $(call include-dep,$(dep),$(obj),$(gen))
 
 # Convenience alias for default target.
diff --git a/tests/cxx/parser/validation/built-in/int/makefile b/tests/cxx/parser/validation/built-in/int/makefile
index 2f690ea..feb5f5a 100644
--- a/tests/cxx/parser/validation/built-in/int/makefile
+++ b/tests/cxx/parser/validation/built-in/int/makefile
@@ -28,6 +28,13 @@ $(driver): $(obj) $(xerces_c.l)
 $(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
 $(obj) $(dep): $(xerces_c.l.cpp-options)
 
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifeq ($(cxx_standard),c++11)
+$(obj) $(dep): cpp_options += -DXSD_CXX11
+endif
+
 $(call include-dep,$(dep),$(obj),$(gen))
 
 # Convenience alias for default target.
diff --git a/tests/cxx/parser/validation/built-in/integer/makefile b/tests/cxx/parser/validation/built-in/integer/makefile
index caff310..ed28cbf 100644
--- a/tests/cxx/parser/validation/built-in/integer/makefile
+++ b/tests/cxx/parser/validation/built-in/integer/makefile
@@ -28,6 +28,13 @@ $(driver): $(obj) $(xerces_c.l)
 $(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
 $(obj) $(dep): $(xerces_c.l.cpp-options)
 
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifeq ($(cxx_standard),c++11)
+$(obj) $(dep): cpp_options += -DXSD_CXX11
+endif
+
 $(call include-dep,$(dep),$(obj),$(gen))
 
 # Convenience alias for default target.
diff --git a/tests/cxx/parser/validation/built-in/long/makefile b/tests/cxx/parser/validation/built-in/long/makefile
index 9a49936..e71fa57 100644
--- a/tests/cxx/parser/validation/built-in/long/makefile
+++ b/tests/cxx/parser/validation/built-in/long/makefile
@@ -28,6 +28,13 @@ $(driver): $(obj) $(xerces_c.l)
 $(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
 $(obj) $(dep): $(xerces_c.l.cpp-options)
 
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifeq ($(cxx_standard),c++11)
+$(obj) $(dep): cpp_options += -DXSD_CXX11
+endif
+
 $(call include-dep,$(dep),$(obj),$(gen))
 
 # Convenience alias for default target.
diff --git a/tests/cxx/parser/validation/built-in/qname/makefile b/tests/cxx/parser/validation/built-in/qname/makefile
index 39f06ef..27ccf3e 100644
--- a/tests/cxx/parser/validation/built-in/qname/makefile
+++ b/tests/cxx/parser/validation/built-in/qname/makefile
@@ -28,6 +28,13 @@ $(driver): $(obj) $(xerces_c.l)
 $(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
 $(obj) $(dep): $(xerces_c.l.cpp-options)
 
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifeq ($(cxx_standard),c++11)
+$(obj) $(dep): cpp_options += -DXSD_CXX11
+endif
+
 $(call include-dep,$(dep),$(obj),$(gen))
 
 # Convenience alias for default target.
diff --git a/tests/cxx/parser/validation/built-in/short/makefile b/tests/cxx/parser/validation/built-in/short/makefile
index 9e252d1..7d79212 100644
--- a/tests/cxx/parser/validation/built-in/short/makefile
+++ b/tests/cxx/parser/validation/built-in/short/makefile
@@ -28,6 +28,13 @@ $(driver): $(obj) $(xerces_c.l)
 $(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
 $(obj) $(dep): $(xerces_c.l.cpp-options)
 
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifeq ($(cxx_standard),c++11)
+$(obj) $(dep): cpp_options += -DXSD_CXX11
+endif
+
 $(call include-dep,$(dep),$(obj),$(gen))
 
 # Convenience alias for default target.
diff --git a/tests/cxx/parser/validation/built-in/string/makefile b/tests/cxx/parser/validation/built-in/string/makefile
index 29d0afc..16cbcf6 100644
--- a/tests/cxx/parser/validation/built-in/string/makefile
+++ b/tests/cxx/parser/validation/built-in/string/makefile
@@ -28,6 +28,13 @@ $(driver): $(obj) $(xerces_c.l)
 $(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
 $(obj) $(dep): $(xerces_c.l.cpp-options)
 
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifeq ($(cxx_standard),c++11)
+$(obj) $(dep): cpp_options += -DXSD_CXX11
+endif
+
 $(call include-dep,$(dep),$(obj),$(gen))
 
 # Convenience alias for default target.
diff --git a/tests/cxx/parser/validation/built-in/uri/makefile b/tests/cxx/parser/validation/built-in/uri/makefile
index abf49a8..a158a84 100644
--- a/tests/cxx/parser/validation/built-in/uri/makefile
+++ b/tests/cxx/parser/validation/built-in/uri/makefile
@@ -28,6 +28,13 @@ $(driver): $(obj) $(xerces_c.l)
 $(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
 $(obj) $(dep): $(xerces_c.l.cpp-options)
 
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifeq ($(cxx_standard),c++11)
+$(obj) $(dep): cpp_options += -DXSD_CXX11
+endif
+
 $(call include-dep,$(dep),$(obj),$(gen))
 
 # Convenience alias for default target.
diff --git a/tests/cxx/parser/validation/choice/makefile b/tests/cxx/parser/validation/choice/makefile
index 2ce866f..031aee2 100644
--- a/tests/cxx/parser/validation/choice/makefile
+++ b/tests/cxx/parser/validation/choice/makefile
@@ -81,7 +81,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/validation/restriction/makefile b/tests/cxx/parser/validation/restriction/makefile
index df31dac..2bb7969 100644
--- a/tests/cxx/parser/validation/restriction/makefile
+++ b/tests/cxx/parser/validation/restriction/makefile
@@ -81,7 +81,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/parser/validation/sequence/makefile b/tests/cxx/parser/validation/sequence/makefile
index 93dd57c..99ef63f 100644
--- a/tests/cxx/parser/validation/sequence/makefile
+++ b/tests/cxx/parser/validation/sequence/makefile
@@ -81,7 +81,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/parser/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/binary/cdr/driver.cxx b/tests/cxx/tree/binary/cdr/driver.cxx
index 012c2cf..9980579 100644
--- a/tests/cxx/tree/binary/cdr/driver.cxx
+++ b/tests/cxx/tree/binary/cdr/driver.cxx
@@ -6,7 +6,7 @@
 // Test non-polymorphic binary serialization to ACE CDR.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 #include 
 
@@ -26,7 +26,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
 
     // Save to a CDR stream.
     //
@@ -38,7 +38,7 @@ main (int argc, char* argv[])
     //
     ACE_InputCDR ace_icdr (ace_ocdr);
     xml_schema::istream icdr (ace_icdr);
-    auto_ptr c (new type (icdr));
+    XSD_AUTO_PTR c (new type (icdr));
 
     // Compare the two.
     //
diff --git a/tests/cxx/tree/binary/cdr/makefile b/tests/cxx/tree/binary/cdr/makefile
index 0fce1e9..c77a026 100644
--- a/tests/cxx/tree/binary/cdr/makefile
+++ b/tests/cxx/tree/binary/cdr/makefile
@@ -78,7 +78,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/binary/polymorphic/driver.cxx b/tests/cxx/tree/binary/polymorphic/driver.cxx
index 8aff63c..5c82b17 100644
--- a/tests/cxx/tree/binary/polymorphic/driver.cxx
+++ b/tests/cxx/tree/binary/polymorphic/driver.cxx
@@ -6,7 +6,7 @@
 // Test polymorphic binary serialization.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 #include 
 #include 
@@ -29,7 +29,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
 
     // Save to a CDR stream.
     //
@@ -54,7 +54,7 @@ main (int argc, char* argv[])
     //
     ACE_InputCDR ace_icdr (ace_ocdr);
     xml_schema::istream icdr (ace_icdr);
-    auto_ptr c (new type (icdr));
+    XSD_AUTO_PTR c (new type (icdr));
 
     // Compare the two.
     //
diff --git a/tests/cxx/tree/binary/polymorphic/makefile b/tests/cxx/tree/binary/polymorphic/makefile
index e3abe50..dc01b6a 100644
--- a/tests/cxx/tree/binary/polymorphic/makefile
+++ b/tests/cxx/tree/binary/polymorphic/makefile
@@ -78,7 +78,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/binary/xdr/driver.cxx b/tests/cxx/tree/binary/xdr/driver.cxx
index 9c1e3c2..0448240 100644
--- a/tests/cxx/tree/binary/xdr/driver.cxx
+++ b/tests/cxx/tree/binary/xdr/driver.cxx
@@ -6,7 +6,7 @@
 // Test non-polymorphic binary serialization to XDR.
 //
 
-#include   // std::auto_ptr
+#include   // std::auto_ptr/unique_ptr
 #include  // std::memcpy
 #include 
 #include 
@@ -59,7 +59,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
 
     // Save to an XDR stream.
     //
@@ -81,7 +81,7 @@ main (int argc, char* argv[])
     xdr.x_op = XDR_DECODE;
     xdrrec_skiprecord (&xdr);
     xsd::cxx::tree::istream ixdr (xdr);
-    auto_ptr c (new type (ixdr));
+    XSD_AUTO_PTR c (new type (ixdr));
     xdr_destroy (&xdr);
 
     // Compare the two.
diff --git a/tests/cxx/tree/binary/xdr/makefile b/tests/cxx/tree/binary/xdr/makefile
index 476690b..f846b66 100644
--- a/tests/cxx/tree/binary/xdr/makefile
+++ b/tests/cxx/tree/binary/xdr/makefile
@@ -73,7 +73,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/built-in/driver.cxx b/tests/cxx/tree/built-in/driver.cxx
index fee634a..f1d02a5 100644
--- a/tests/cxx/tree/built-in/driver.cxx
+++ b/tests/cxx/tree/built-in/driver.cxx
@@ -6,7 +6,7 @@
 // Test built-in type mapping.
 //
 
-#include   // std::auto_ptr
+#include   // std::auto_ptr/unique_ptr
 #include 
 #include 
 
@@ -15,7 +15,6 @@
 
 using std::cerr;
 using std::endl;
-using std::auto_ptr;
 
 int
 main (int argc, char* argv[])
@@ -26,12 +25,13 @@ main (int argc, char* argv[])
     return 1;
   }
 
-  auto_ptr elements (xmlns::test::elements (argv[1]));
+  XSD_AUTO_PTR elements (
+    xmlns::test::elements (argv[1]));
 
-  auto_ptr attributes (
+  XSD_AUTO_PTR attributes (
     xmlns::test::attributes (argv[2]));
 
-  auto_ptr inherited (
+  XSD_AUTO_PTR inherited (
     xmlns::test::inherited (argv[3]));
 
   cerr << "elements: " << *elements << endl
@@ -53,13 +53,14 @@ main (int argc, char* argv[])
     xmlns::test::elements (ostr, *elements, map);
 
     std::istringstream istr (ostr.str ());
-    auto_ptr elements1 (xmlns::test::elements (istr));
+    XSD_AUTO_PTR elements1 (
+      xmlns::test::elements (istr));
 
     std::ostringstream ostr1;
     xmlns::test::elements (ostr1, *elements1, map);
 
     if (ostr.str () != ostr1.str ())
-      return 1;     
+      return 1;
   }
 
   {
@@ -67,7 +68,7 @@ main (int argc, char* argv[])
     xmlns::test::attributes (ostr, *attributes, map);
 
     std::istringstream istr (ostr.str ());
-    auto_ptr attributes1 (
+    XSD_AUTO_PTR attributes1 (
       xmlns::test::attributes (istr));
 
     std::ostringstream ostr1;
@@ -82,7 +83,7 @@ main (int argc, char* argv[])
     xmlns::test::inherited (ostr, *inherited, map);
 
     std::istringstream istr (ostr.str ());
-    auto_ptr inherited1 (
+    XSD_AUTO_PTR inherited1 (
       xmlns::test::inherited (istr));
 
     std::ostringstream ostr1;
diff --git a/tests/cxx/tree/built-in/makefile b/tests/cxx/tree/built-in/makefile
index ad8aba1..b94930f 100644
--- a/tests/cxx/tree/built-in/makefile
+++ b/tests/cxx/tree/built-in/makefile
@@ -89,7 +89,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 # Dependencies.
 #
diff --git a/tests/cxx/tree/chameleon/driver.cxx b/tests/cxx/tree/chameleon/driver.cxx
index 1627144..8dc7bff 100644
--- a/tests/cxx/tree/chameleon/driver.cxx
+++ b/tests/cxx/tree/chameleon/driver.cxx
@@ -6,7 +6,7 @@
 // Test chameleon inclusion.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 
 #include "includer.hxx"
@@ -25,7 +25,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
 
     cout << *r << endl;
   }
diff --git a/tests/cxx/tree/chameleon/makefile b/tests/cxx/tree/chameleon/makefile
index 77eab9b..6dc2f3f 100644
--- a/tests/cxx/tree/chameleon/makefile
+++ b/tests/cxx/tree/chameleon/makefile
@@ -74,7 +74,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/comparison/driver.cxx b/tests/cxx/tree/comparison/driver.cxx
index f6480bb..41e91a9 100644
--- a/tests/cxx/tree/comparison/driver.cxx
+++ b/tests/cxx/tree/comparison/driver.cxx
@@ -6,7 +6,7 @@
 // Test generated comparison operators.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 
 #include "test.hxx"
@@ -25,7 +25,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
 
     type::complex_sequence s (r->complex ());
 
diff --git a/tests/cxx/tree/comparison/makefile b/tests/cxx/tree/comparison/makefile
index 0ed2dd7..b88389c 100644
--- a/tests/cxx/tree/comparison/makefile
+++ b/tests/cxx/tree/comparison/makefile
@@ -74,7 +74,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/compilation/driver.cxx b/tests/cxx/tree/compilation/driver.cxx
index 060bf2c..71e58bc 100644
--- a/tests/cxx/tree/compilation/driver.cxx
+++ b/tests/cxx/tree/compilation/driver.cxx
@@ -7,7 +7,6 @@
 // all the types.
 //
 
-#include  // std::auto_ptr
 #include 
 
 #include "test.hxx"
diff --git a/tests/cxx/tree/compilation/makefile b/tests/cxx/tree/compilation/makefile
index 6c4ebd8..4d3161b 100644
--- a/tests/cxx/tree/compilation/makefile
+++ b/tests/cxx/tree/compilation/makefile
@@ -74,7 +74,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/complex/ctor/driver.cxx b/tests/cxx/tree/complex/ctor/driver.cxx
index ea9695d..2adeec4 100644
--- a/tests/cxx/tree/complex/ctor/driver.cxx
+++ b/tests/cxx/tree/complex/ctor/driver.cxx
@@ -11,6 +11,13 @@
 
 #include "test.hxx"
 
+#ifdef XSD_CXX11
+#  include  // std::move
+#  define XSD_MOVE(x) std::move(x)
+#else
+#  define XSD_MOVE(x) x
+#endif
+
 using namespace std;
 using namespace test;
 
@@ -64,12 +71,12 @@ main ()
     //
     e_base b1 (1, "foo", e_complex_type ("bar"));
 
-    auto_ptr c2 (new e_complex_type ("bar"));
-    e_base b2 (1, "foo", c2);
+    XSD_AUTO_PTR c2 (new e_complex_type ("bar"));
+    e_base b2 (1, "foo", XSD_MOVE (c2));
 
-    auto_ptr s3 (new e_simple_type ("foo"));
-    auto_ptr c3 (new e_complex_type ("bar"));
-    e_base b3 (1, s3, c3);
+    XSD_AUTO_PTR s3 (new e_simple_type ("foo"));
+    XSD_AUTO_PTR c3 (new e_complex_type ("bar"));
+    e_base b3 (1, XSD_MOVE (s3), XSD_MOVE (c3));
 
     assert (b1 == b2);
     assert (b1 == b3);
@@ -79,15 +86,20 @@ main ()
     e_derived d1 (1, "foo", e_complex_type ("bar"),
                   true, "baz", e_complex_type ("biz"));
 
-    auto_ptr c2a (new e_complex_type ("bar"));
-    auto_ptr c2b (new e_complex_type ("biz"));
-    e_derived d2 (1, "foo", c2a, true, "baz", c2b);
-
-    auto_ptr s3a (new e_simple_type ("foo"));
-    auto_ptr s3b (new xml_schema::string ("baz"));
-    auto_ptr c3a (new e_complex_type ("bar"));
-    auto_ptr c3b (new e_complex_type ("biz"));
-    e_derived d3 (1, s3a, c3a, true, s3b, c3b);
+    XSD_AUTO_PTR c2a (new e_complex_type ("bar"));
+    XSD_AUTO_PTR c2b (new e_complex_type ("biz"));
+    e_derived d2 (1, "foo", XSD_MOVE (c2a), true, "baz", XSD_MOVE (c2b));
+
+    XSD_AUTO_PTR s3a (new e_simple_type ("foo"));
+    XSD_AUTO_PTR s3b (new xml_schema::string ("baz"));
+    XSD_AUTO_PTR c3a (new e_complex_type ("bar"));
+    XSD_AUTO_PTR c3b (new e_complex_type ("biz"));
+    e_derived d3 (1,
+                  XSD_MOVE (s3a),
+                  XSD_MOVE (c3a),
+                  true,
+                  XSD_MOVE (s3b),
+                  XSD_MOVE (c3b));
 
     assert (d1 == d2);
     assert (d1 == d3);
@@ -99,12 +111,12 @@ main ()
   {
     f_type f1 (xml_schema::type (), 1, "foo", f_complex_type ("bar"));
 
-    auto_ptr c2 (new f_complex_type ("bar"));
-    f_type f2 (1, "foo", c2);
+    XSD_AUTO_PTR c2 (new f_complex_type ("bar"));
+    f_type f2 (1, "foo", XSD_MOVE (c2));
 
-    auto_ptr s3 (new f_simple_type ("foo"));
-    auto_ptr c3 (new f_complex_type ("bar"));
-    f_type f3 (1, s3, c3);
+    XSD_AUTO_PTR s3 (new f_simple_type ("foo"));
+    XSD_AUTO_PTR c3 (new f_complex_type ("bar"));
+    f_type f3 (1, XSD_MOVE (s3), XSD_MOVE (c3));
 
     assert (f1 == f2);
     assert (f1 == f3);
diff --git a/tests/cxx/tree/complex/ctor/makefile b/tests/cxx/tree/complex/ctor/makefile
index 6408105..1b0bc11 100644
--- a/tests/cxx/tree/complex/ctor/makefile
+++ b/tests/cxx/tree/complex/ctor/makefile
@@ -76,8 +76,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
-$(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
 
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
+$(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 # Dependencies.
 #
diff --git a/tests/cxx/tree/containment/driver.cxx b/tests/cxx/tree/containment/driver.cxx
index ac798a6..aa701ae 100644
--- a/tests/cxx/tree/containment/driver.cxx
+++ b/tests/cxx/tree/containment/driver.cxx
@@ -6,11 +6,18 @@
 // Test tree node containment.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 
 #include "test.hxx"
 
+#ifdef XSD_CXX11
+#  include  // std::move
+#  define XSD_MOVE(x) std::move(x)
+#else
+#  define XSD_MOVE(x) x
+#endif
+
 using namespace std;
 using namespace test;
 
@@ -20,11 +27,11 @@ main ()
   // Change of a container in a sub-tree without ID.
   //
   {
-    auto_ptr i (new inner ());
+    XSD_AUTO_PTR i (new inner ());
     i->ref ("foo");
 
     outer o;
-    o.i (i);
+    o.i (XSD_MOVE (i));
     o.ref ("foo");
 
     assert (o.i ()->ref ()->get () == 0);
@@ -34,14 +41,14 @@ main ()
   // Change of container in a sub-tree with ID inside.
   //
   {
-    auto_ptr i (new inner ());
+    XSD_AUTO_PTR i (new inner ());
     inner* p (i.get ());
     i->id ("foo");
     i->ref ("foo");
     assert (i->ref ()->get () == p);
 
     outer o;
-    o.i (i);
+    o.i (XSD_MOVE (i));
     o.ref ("foo");
 
     assert (o.i ()->ref ()->get () == p);
@@ -51,10 +58,10 @@ main ()
   // Change of a container in ID.
   //
   {
-    auto_ptr id (new xml_schema::id ("foo"));
+    XSD_AUTO_PTR id (new xml_schema::id ("foo"));
 
     inner i;
-    i.id (id);
+    i.id (XSD_MOVE (id));
     i.ref ("foo");
     assert (i.ref ()->get () == &i);
   }
@@ -62,12 +69,12 @@ main ()
   // Change of a container in a type derived from ID with ID inside.
   //
   {
-    auto_ptr id (new id_ex ("foo"));
+    XSD_AUTO_PTR id (new id_ex ("foo"));
     id_ex* p (id.get ());
     id->id ("bar");
 
     inner i;
-    i.id_ex (id);
+    i.id_ex (XSD_MOVE (id));
 
     i.ref ("foo");
     assert (i.ref ()->get () == &i);
@@ -81,28 +88,28 @@ main ()
   {
     id i1 ("a"), i2 ("b");
 
-    auto_ptr ic (new ids);
+    XSD_AUTO_PTR ic (new ids);
     ic->id ().push_back (i1);
     ic->id ().push_back (i2);
 
-    auto_ptr r1 (new xml_schema::idrefs);
+    XSD_AUTO_PTR r1 (new xml_schema::idrefs);
     r1->push_back (xml_schema::idref ("a"));
     r1->push_back (xml_schema::idref ("b"));
 
-    auto_ptr r2 (new idref_list);
+    XSD_AUTO_PTR r2 (new idref_list);
     r2->push_back (xml_schema::idref ("a"));
     r2->push_back (xml_schema::idref ("b"));
 
-    auto_ptr rc1 (new idrefs1);
-    auto_ptr rc2 (new idrefs2);
+    XSD_AUTO_PTR rc1 (new idrefs1);
+    XSD_AUTO_PTR rc2 (new idrefs2);
 
-    rc1->idrefs (r1);
-    rc2->idrefs (r2);
+    rc1->idrefs (XSD_MOVE (r1));
+    rc2->idrefs (XSD_MOVE (r2));
 
     model m;
-    m.ids (ic);
-    m.idrefs1 (rc1);
-    m.idrefs2 (rc2);
+    m.ids (XSD_MOVE (ic));
+    m.idrefs1 (XSD_MOVE (rc1));
+    m.idrefs2 (XSD_MOVE (rc2));
 
     assert (m.idrefs1 ().idrefs ()[0].get () != 0);
     assert (m.idrefs1 ().idrefs ()[1].get () != 0);
diff --git a/tests/cxx/tree/containment/makefile b/tests/cxx/tree/containment/makefile
index fb239c4..ba34bdd 100644
--- a/tests/cxx/tree/containment/makefile
+++ b/tests/cxx/tree/containment/makefile
@@ -74,7 +74,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/default/general/driver.cxx b/tests/cxx/tree/default/general/driver.cxx
index e9e5528..4c9cfc4 100644
--- a/tests/cxx/tree/default/general/driver.cxx
+++ b/tests/cxx/tree/default/general/driver.cxx
@@ -6,7 +6,7 @@
 // Test default attribute/element values.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 
 #include "test.hxx"
@@ -25,7 +25,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1], xml_schema::flags::dont_validate));
+    XSD_AUTO_PTR r (root (argv[1], xml_schema::flags::dont_validate));
 
     xml_schema::namespace_infomap map;
     map["t"].name = "test";
diff --git a/tests/cxx/tree/default/general/makefile b/tests/cxx/tree/default/general/makefile
index 432c56c..045f085 100644
--- a/tests/cxx/tree/default/general/makefile
+++ b/tests/cxx/tree/default/general/makefile
@@ -75,7 +75,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/default/omit/driver.cxx b/tests/cxx/tree/default/omit/driver.cxx
index f01ce1a..84c30ce 100644
--- a/tests/cxx/tree/default/omit/driver.cxx
+++ b/tests/cxx/tree/default/omit/driver.cxx
@@ -6,7 +6,7 @@
 // Test default attribute omission from the output.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 
 #include "test.hxx"
@@ -25,7 +25,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1], xml_schema::flags::dont_validate));
+    XSD_AUTO_PTR r (root (argv[1], xml_schema::flags::dont_validate));
 
     cout << *r << endl
          << "default x: " << derived::x_default_value () << endl
diff --git a/tests/cxx/tree/default/omit/makefile b/tests/cxx/tree/default/omit/makefile
index 4b3b61e..710ab48 100644
--- a/tests/cxx/tree/default/omit/makefile
+++ b/tests/cxx/tree/default/omit/makefile
@@ -75,7 +75,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/detach/driver.cxx b/tests/cxx/tree/detach/driver.cxx
index 8317ac4..e752c13 100644
--- a/tests/cxx/tree/detach/driver.cxx
+++ b/tests/cxx/tree/detach/driver.cxx
@@ -6,17 +6,26 @@
 // Test the detach functionality.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 
 #include "test.hxx"
 
+#ifdef XSD_CXX11
+#  include  // std::move
+#  define XSD_MOVE(x) std::move(x)
+#else
+#  define XSD_MOVE(x) x
+#endif
+
 using namespace std;
 using namespace test;
 
 int
 main ()
 {
+  using test::ref;
+
   // Construct the model.
   //
   object o1 ("o1");
@@ -57,22 +66,22 @@ main ()
 
   // Detach one.
   //
-  auto_ptr p (m.detach_one ());
+  XSD_AUTO_PTR p (m.detach_one ());
   assert (p->_container () == 0);
   assert (p->r ()[0].get () == &p->o ()[1]);
   assert (m.opt ()->r ()[1].get () == 0);
 
-  m.one (p);
+  m.one (XSD_MOVE (p));
   assert (m.opt ()->r ()[1].get () == &m.one ().o ()[0]);
   p = m.detach_one ();
 
   model m1;
-  m1.one (p);
+  m1.one (XSD_MOVE (p));
   m1.opt (s2);
   assert (m1.opt ()->r ()[1].get () == &m1.one ().o ()[0]);
 
   p = m1.detach_one ();
-  m.seq ().push_back (p);
+  m.seq ().push_back (XSD_MOVE (p));
 
   // Detach opt.
   //
@@ -82,7 +91,7 @@ main ()
   assert (p->r ()[0].get () == &p->o ()[1]);
   assert (m.seq ()[0].r ()[1].get () == 0);
 
-  m.seq ().push_back (p);
+  m.seq ().push_back (XSD_MOVE (p));
 
   // Detach seq.
   //
@@ -91,7 +100,7 @@ main ()
   assert (p->r ()[0].get () == &p->o ()[1]);
   assert (m.seq ()[0].r ()[1].get () == 0);
 
-  m.seq ().push_back (p);
+  m.seq ().push_back (XSD_MOVE (p));
   assert (m.seq ()[0].r ()[1].get () == &m.seq ()[1].o ()[0]);
 
   m.seq ().detach (m.seq ().begin (), p);
diff --git a/tests/cxx/tree/detach/makefile b/tests/cxx/tree/detach/makefile
index 7689898..cf85a7a 100644
--- a/tests/cxx/tree/detach/makefile
+++ b/tests/cxx/tree/detach/makefile
@@ -74,7 +74,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/dom-association/dom-parse.cxx b/tests/cxx/tree/dom-association/dom-parse.cxx
new file mode 100644
index 0000000..c21a47f
--- /dev/null
+++ b/tests/cxx/tree/dom-association/dom-parse.cxx
@@ -0,0 +1,97 @@
+// file      : tests/cxx/tree/dom-association/dom-parse.cxx
+// author    : Boris Kolpackov 
+// copyright : Copyright (c) 2006-2011 Code Synthesis Tools CC
+// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include "dom-parse.hxx"
+
+#include 
+
+#include 
+#include  // chLatin_*
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+using namespace xercesc;
+namespace xml = xsd::cxx::xml;
+namespace tree = xsd::cxx::tree;
+
+XSD_DOM_AUTO_PTR
+parse (std::istream& is,
+       const std::string& id,
+       bool validate)
+{
+  const XMLCh ls_id [] = {chLatin_L, chLatin_S, chNull};
+
+  // Get an implementation of the Load-Store (LS) interface.
+  //
+  DOMImplementation* impl (
+    DOMImplementationRegistry::getDOMImplementation (ls_id));
+
+  XSD_DOM_AUTO_PTR parser (
+    impl->createLSParser (DOMImplementationLS::MODE_SYNCHRONOUS, 0));
+
+  DOMConfiguration* conf (parser->getDomConfig ());
+
+  // Discard comment nodes in the document.
+  //
+  conf->setParameter (XMLUni::fgDOMComments, false);
+
+  // Enable datatype normalization.
+  //
+  conf->setParameter (XMLUni::fgDOMDatatypeNormalization, true);
+
+  // Do not create EntityReference nodes in the DOM tree. No
+  // EntityReference nodes will be created, only the nodes
+  // corresponding to their fully expanded substitution text
+  // will be created.
+  //
+  conf->setParameter (XMLUni::fgDOMEntities, false);
+
+  // Perform namespace processing.
+  //
+  conf->setParameter (XMLUni::fgDOMNamespaces, true);
+
+  // Do not include ignorable whitespace in the DOM tree.
+  //
+  conf->setParameter (XMLUni::fgDOMElementContentWhitespace, false);
+
+  // Enable/Disable validation.
+  //
+  conf->setParameter (XMLUni::fgDOMValidate, validate);
+  conf->setParameter (XMLUni::fgXercesSchema, validate);
+  conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false);
+
+  // Xerces-C++ 3.1.0 is the first version with working multi import
+  // support.
+  //
+#if _XERCES_VERSION >= 30100
+  conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true);
+#endif
+
+  // We will release the DOM document ourselves.
+  //
+  conf->setParameter (XMLUni::fgXercesUserAdoptsDOMDocument, true);
+
+  // Set error handler.
+  //
+  tree::error_handler eh;
+  xml::dom::bits::error_handler_proxy ehp (eh);
+  conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp);
+
+  // Prepare input stream.
+  //
+  xml::sax::std_input_source isrc (is, id);
+  Wrapper4InputSource wrap (&isrc, false);
+
+  XSD_DOM_AUTO_PTR doc (parser->parse (&wrap));
+
+  eh.throw_if_failed > ();
+
+  return doc;
+}
diff --git a/tests/cxx/tree/dom-association/dom-parse.hxx b/tests/cxx/tree/dom-association/dom-parse.hxx
new file mode 100644
index 0000000..75a5e8b
--- /dev/null
+++ b/tests/cxx/tree/dom-association/dom-parse.hxx
@@ -0,0 +1,25 @@
+// file      : tests/cxx/tree/dom-association/dom-parse.hxx
+// author    : Boris Kolpackov 
+// copyright : Copyright (c) 2006-2011 Code Synthesis Tools CC
+// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef DOM_PARSE
+#define DOM_PARSE
+
+#include 
+#include 
+
+#include 
+
+#include 
+
+// Parse an XML document from the standard input stream with an
+// optional resource id. Resource id is used in diagnostics as
+// well as to locate schemas referenced from inside the document.
+//
+XSD_DOM_AUTO_PTR
+parse (std::istream& is,
+       const std::string& id,
+       bool validate);
+
+#endif // DOM_PARSE
diff --git a/tests/cxx/tree/dom-association/driver.cxx b/tests/cxx/tree/dom-association/driver.cxx
new file mode 100644
index 0000000..d0fd33b
--- /dev/null
+++ b/tests/cxx/tree/dom-association/driver.cxx
@@ -0,0 +1,73 @@
+// file      : tests/cxx/tree/dom-association/driver.cxx
+// author    : Boris Kolpackov 
+// copyright : Copyright (c) 2006-2011 Code Synthesis Tools CC
+// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test DOM association/ownership.
+//
+
+#include  // std::auto_ptr/unique_ptr
+#include 
+#include 
+
+#include 
+
+#include "dom-parse.hxx"
+#include "test.hxx"
+
+using namespace std;
+using namespace test;
+using namespace xercesc;
+
+int
+main (int argc, char* argv[])
+{
+  if (argc != 2)
+  {
+    cerr << "usage: " << argv[0] << " test.xml" << endl;
+    return 1;
+  }
+
+  int r (0);
+
+  XMLPlatformUtils::Initialize ();
+
+  try
+  {
+    ifstream ifs;
+    ifs.exceptions (ifstream::badbit | ifstream::failbit);
+    ifs.open (argv[1]);
+
+    DOMDocument* ptr;
+
+#ifdef XSD_CXX11
+    xml_schema::dom::unique_ptr doc (parse (ifs, argv[1], true));
+    ptr = doc.get ();
+    unique_ptr r (
+      root (std::move (doc),
+            xml_schema::flags::keep_dom | xml_schema::flags::own_dom));
+#else
+    xml_schema::dom::auto_ptr doc (parse (ifs, argv[1], true));
+    ptr = doc.get ();
+    auto_ptr r (
+      root (doc,
+            xml_schema::flags::keep_dom | xml_schema::flags::own_dom));
+#endif
+
+    assert (doc.get () == 0);
+    assert (r->_node ()->getOwnerDocument () == ptr);
+  }
+  catch (xml_schema::exception const& e)
+  {
+    cerr << e << endl;
+    r = 1;
+  }
+  catch (const std::ios_base::failure&)
+  {
+    cerr << argv[1] << ": unable to open or read failure" << endl;
+    r = 1;
+  }
+
+  XMLPlatformUtils::Terminate ();
+  return r;
+}
diff --git a/tests/cxx/tree/dom-association/makefile b/tests/cxx/tree/dom-association/makefile
new file mode 100644
index 0000000..a57e5b1
--- /dev/null
+++ b/tests/cxx/tree/dom-association/makefile
@@ -0,0 +1,93 @@
+# file      : tests/cxx/tree/dom-association/makefile
+# author    : Boris Kolpackov 
+# copyright : Copyright (c) 2006-2011 Code Synthesis Tools CC
+# license   : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
+
+xsd := test.xsd
+cxx := driver.cxx dom-parse.cxx
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o))
+dep := $(obj:.o=.o.d)
+
+driver := $(out_base)/driver
+test   := $(out_base)/.test
+clean  := $(out_base)/.clean
+
+
+# Import.
+#
+$(call import,\
+  $(scf_root)/import/libxerces-c/stub.make,\
+  l: xerces_c.l,cpp-options: xerces_c.l.cpp-options)
+
+
+# Build.
+#
+$(driver): $(obj) $(xerces_c.l)
+
+$(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
+$(obj) $(dep): $(xerces_c.l.cpp-options)
+
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifeq ($(cxx_standard),c++11)
+$(obj) $(dep): cpp_options += -DXSD_CXX11
+endif
+
+genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.ixx) $(xsd:.xsd=.cxx)
+gen  := $(addprefix $(out_base)/,$(genf))
+
+$(gen): xsd := $(out_root)/xsd/xsd
+$(gen): xsd_options += --generate-ostream
+$(gen): $(out_root)/xsd/xsd
+
+$(call include-dep,$(dep),$(obj),$(gen))
+
+# Convenience alias for default target.
+#
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+$(test): driver := $(driver)
+$(test): $(driver) $(src_base)/test.xml $(src_base)/output
+	$(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver))
+
+# Clean.
+#
+$(clean): $(driver).o.clean                                \
+  $(addsuffix .cxx.clean,$(obj))                           \
+  $(addsuffix .cxx.clean,$(dep))                           \
+  $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(gen): | $(out_base)/.gitignore
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
+$(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsd/makefile)
diff --git a/tests/cxx/tree/dom-association/output b/tests/cxx/tree/dom-association/output
new file mode 100644
index 0000000..e69de29
diff --git a/tests/cxx/tree/dom-association/test.xml b/tests/cxx/tree/dom-association/test.xml
new file mode 100644
index 0000000..624a80c
--- /dev/null
+++ b/tests/cxx/tree/dom-association/test.xml
@@ -0,0 +1,7 @@
+
+		
+  a	
+  
+
diff --git a/tests/cxx/tree/dom-association/test.xsd b/tests/cxx/tree/dom-association/test.xsd
new file mode 100644
index 0000000..07bebc7
--- /dev/null
+++ b/tests/cxx/tree/dom-association/test.xsd
@@ -0,0 +1,12 @@
+
+
+
+  
+    
+      
+    
+  
+
+  
+
+
diff --git a/tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx b/tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx
index b134da2..591d73f 100644
--- a/tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx
+++ b/tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx
@@ -6,7 +6,7 @@
 // Test ISO-8859-1 encoding.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 #include 
 
@@ -36,7 +36,7 @@ main (int argc, char* argv[])
     }
 
     xsd::cxx::xml::char_transcoder::unrep_char ('?');
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
 
     {
       type::a_sequence const& s (r->a ());
diff --git a/tests/cxx/tree/encoding/char/iso-8859-1/makefile b/tests/cxx/tree/encoding/char/iso-8859-1/makefile
index 00257fd..8708b49 100644
--- a/tests/cxx/tree/encoding/char/iso-8859-1/makefile
+++ b/tests/cxx/tree/encoding/char/iso-8859-1/makefile
@@ -75,7 +75,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/encoding/char/lcp/driver.cxx b/tests/cxx/tree/encoding/char/lcp/driver.cxx
index c33ba27..456dc09 100644
--- a/tests/cxx/tree/encoding/char/lcp/driver.cxx
+++ b/tests/cxx/tree/encoding/char/lcp/driver.cxx
@@ -7,7 +7,7 @@
 // The test just makes sure it still compiles and works.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 #include 
 
@@ -27,7 +27,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
 
     xml_schema::namespace_infomap map;
     map["t"].name = "test";
diff --git a/tests/cxx/tree/encoding/char/lcp/makefile b/tests/cxx/tree/encoding/char/lcp/makefile
index 627ddb3..37511e0 100644
--- a/tests/cxx/tree/encoding/char/lcp/makefile
+++ b/tests/cxx/tree/encoding/char/lcp/makefile
@@ -74,7 +74,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/encoding/char/utf-8/driver.cxx b/tests/cxx/tree/encoding/char/utf-8/driver.cxx
index 5da863c..f580f51 100644
--- a/tests/cxx/tree/encoding/char/utf-8/driver.cxx
+++ b/tests/cxx/tree/encoding/char/utf-8/driver.cxx
@@ -6,7 +6,7 @@
 // Test UTF-8 encoding.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 #include 
 
@@ -26,7 +26,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
 
     {
       type::a_sequence const& s (r->a ());
diff --git a/tests/cxx/tree/encoding/char/utf-8/makefile b/tests/cxx/tree/encoding/char/utf-8/makefile
index 9e51cf0..a7e94bf 100644
--- a/tests/cxx/tree/encoding/char/utf-8/makefile
+++ b/tests/cxx/tree/encoding/char/utf-8/makefile
@@ -74,7 +74,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/encoding/wchar/driver.cxx b/tests/cxx/tree/encoding/wchar/driver.cxx
index fde45fa..b3316d2 100644
--- a/tests/cxx/tree/encoding/wchar/driver.cxx
+++ b/tests/cxx/tree/encoding/wchar/driver.cxx
@@ -6,7 +6,7 @@
 // Test the wide character mapping.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 #include 
 
@@ -29,7 +29,7 @@ main (int argc, char* argv[])
     // Use dont_validate because we do not have instance's system id (path).
     //
     std::ifstream ifs (argv[1]);
-    auto_ptr r (root (ifs, xml_schema::flags::dont_validate));
+    XSD_AUTO_PTR r (root (ifs, xml_schema::flags::dont_validate));
 
     {
       type::b_sequence const& s (r->b ());
diff --git a/tests/cxx/tree/encoding/wchar/makefile b/tests/cxx/tree/encoding/wchar/makefile
index af7f034..d2ce82b 100644
--- a/tests/cxx/tree/encoding/wchar/makefile
+++ b/tests/cxx/tree/encoding/wchar/makefile
@@ -75,7 +75,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/enumeration/ctor/makefile b/tests/cxx/tree/enumeration/ctor/makefile
index 947bdfc..9f6162c 100644
--- a/tests/cxx/tree/enumeration/ctor/makefile
+++ b/tests/cxx/tree/enumeration/ctor/makefile
@@ -75,7 +75,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/enumeration/inheritance/driver.cxx b/tests/cxx/tree/enumeration/inheritance/driver.cxx
index 1842982..4fb05a1 100644
--- a/tests/cxx/tree/enumeration/inheritance/driver.cxx
+++ b/tests/cxx/tree/enumeration/inheritance/driver.cxx
@@ -6,7 +6,7 @@
 // Insert test description here.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 #include 
 
@@ -26,7 +26,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
 
     switch (*r)
     {
diff --git a/tests/cxx/tree/enumeration/inheritance/makefile b/tests/cxx/tree/enumeration/inheritance/makefile
index 54f9a3c..cdce770 100644
--- a/tests/cxx/tree/enumeration/inheritance/makefile
+++ b/tests/cxx/tree/enumeration/inheritance/makefile
@@ -74,7 +74,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/float/driver.cxx b/tests/cxx/tree/float/driver.cxx
index 1c073d8..1277275 100644
--- a/tests/cxx/tree/float/driver.cxx
+++ b/tests/cxx/tree/float/driver.cxx
@@ -7,7 +7,7 @@
 // and serialization.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 
 #include "test.hxx"
@@ -26,7 +26,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
 
     r->simple ().push_back (12.129456);
     r->simple ().push_back (123.129456);
diff --git a/tests/cxx/tree/float/makefile b/tests/cxx/tree/float/makefile
index 03e0201..ebfbc7e 100644
--- a/tests/cxx/tree/float/makefile
+++ b/tests/cxx/tree/float/makefile
@@ -74,7 +74,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/list/ctor/makefile b/tests/cxx/tree/list/ctor/makefile
index 6b3c5e0..6131287 100644
--- a/tests/cxx/tree/list/ctor/makefile
+++ b/tests/cxx/tree/list/ctor/makefile
@@ -75,7 +75,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/makefile b/tests/cxx/tree/makefile
index 9825601..cfc0847 100644
--- a/tests/cxx/tree/makefile
+++ b/tests/cxx/tree/makefile
@@ -5,26 +5,27 @@
 
 include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make
 
-tests :=      \
-built-in      \
-chameleon     \
-comparison    \
-compilation   \
-complex       \
-containment   \
-default       \
-detach        \
-encoding      \
-enumeration   \
-float         \
-list          \
-name-clash    \
-naming        \
-polymorphism  \
-prefix        \
-test-template \
-types-only    \
-union         \
+tests :=        \
+built-in        \
+chameleon       \
+comparison      \
+compilation     \
+complex         \
+containment     \
+default         \
+detach          \
+dom-association \
+encoding        \
+enumeration     \
+float           \
+list            \
+name-clash      \
+naming          \
+polymorphism    \
+prefix          \
+test-template   \
+types-only      \
+union           \
 wildcard
 
 ifeq ($(xsd_with_ace),y)
diff --git a/tests/cxx/tree/name-clash/inheritance/driver.cxx b/tests/cxx/tree/name-clash/inheritance/driver.cxx
index 611d145..2ff5763 100644
--- a/tests/cxx/tree/name-clash/inheritance/driver.cxx
+++ b/tests/cxx/tree/name-clash/inheritance/driver.cxx
@@ -6,7 +6,7 @@
 // Test for name clashes across inheritance hierarchy.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 
 #include "test.hxx"
@@ -25,7 +25,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
 
     cout << *r << endl;
   }
diff --git a/tests/cxx/tree/name-clash/inheritance/makefile b/tests/cxx/tree/name-clash/inheritance/makefile
index d45cf9c..972de44 100644
--- a/tests/cxx/tree/name-clash/inheritance/makefile
+++ b/tests/cxx/tree/name-clash/inheritance/makefile
@@ -74,7 +74,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/naming/camel/driver.cxx b/tests/cxx/tree/naming/camel/driver.cxx
index d3ea320..fa174d4 100644
--- a/tests/cxx/tree/naming/camel/driver.cxx
+++ b/tests/cxx/tree/naming/camel/driver.cxx
@@ -6,7 +6,6 @@
 // Test camel case (upper for types, lower for functions) naming style.
 //
 
-#include  // std::auto_ptr
 #include 
 #include 
 
diff --git a/tests/cxx/tree/naming/camel/makefile b/tests/cxx/tree/naming/camel/makefile
index 78162db..b6c9498 100644
--- a/tests/cxx/tree/naming/camel/makefile
+++ b/tests/cxx/tree/naming/camel/makefile
@@ -82,7 +82,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/naming/java/driver.cxx b/tests/cxx/tree/naming/java/driver.cxx
index 1c4bfdd..1e4adde 100644
--- a/tests/cxx/tree/naming/java/driver.cxx
+++ b/tests/cxx/tree/naming/java/driver.cxx
@@ -6,7 +6,6 @@
 // Test Java naming style.
 //
 
-#include  // std::auto_ptr
 #include 
 #include 
 
diff --git a/tests/cxx/tree/naming/java/makefile b/tests/cxx/tree/naming/java/makefile
index 9cda154..41c5afd 100644
--- a/tests/cxx/tree/naming/java/makefile
+++ b/tests/cxx/tree/naming/java/makefile
@@ -82,7 +82,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/naming/knr/driver.cxx b/tests/cxx/tree/naming/knr/driver.cxx
index 4960e04..bb980fc 100644
--- a/tests/cxx/tree/naming/knr/driver.cxx
+++ b/tests/cxx/tree/naming/knr/driver.cxx
@@ -6,7 +6,6 @@
 // Test K&R naming style.
 //
 
-#include  // std::auto_ptr
 #include 
 #include 
 
diff --git a/tests/cxx/tree/naming/knr/makefile b/tests/cxx/tree/naming/knr/makefile
index 31836de..370055a 100644
--- a/tests/cxx/tree/naming/knr/makefile
+++ b/tests/cxx/tree/naming/knr/makefile
@@ -82,7 +82,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/polymorphism/comparison/driver.cxx b/tests/cxx/tree/polymorphism/comparison/driver.cxx
index 049cc45..9a2f222 100644
--- a/tests/cxx/tree/polymorphism/comparison/driver.cxx
+++ b/tests/cxx/tree/polymorphism/comparison/driver.cxx
@@ -6,7 +6,7 @@
 // Test comparison of polymorphic object models.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 
 #include "test.hxx"
@@ -25,7 +25,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
 
     // Equals.
     //
diff --git a/tests/cxx/tree/polymorphism/comparison/makefile b/tests/cxx/tree/polymorphism/comparison/makefile
index 91e541a..3ce8cc9 100644
--- a/tests/cxx/tree/polymorphism/comparison/makefile
+++ b/tests/cxx/tree/polymorphism/comparison/makefile
@@ -75,7 +75,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/polymorphism/ostream/driver.cxx b/tests/cxx/tree/polymorphism/ostream/driver.cxx
index 836c329..9ff8a5f 100644
--- a/tests/cxx/tree/polymorphism/ostream/driver.cxx
+++ b/tests/cxx/tree/polymorphism/ostream/driver.cxx
@@ -6,7 +6,7 @@
 // Test printing of polymorphic object models.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 
 #include "test.hxx"
@@ -25,7 +25,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
     cout << *r << endl;
   }
   catch (xml_schema::exception const& e)
diff --git a/tests/cxx/tree/polymorphism/ostream/makefile b/tests/cxx/tree/polymorphism/ostream/makefile
index 4512023..2f429db 100644
--- a/tests/cxx/tree/polymorphism/ostream/makefile
+++ b/tests/cxx/tree/polymorphism/ostream/makefile
@@ -76,7 +76,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/polymorphism/same-type/driver.cxx b/tests/cxx/tree/polymorphism/same-type/driver.cxx
index 59ca905..162d397 100644
--- a/tests/cxx/tree/polymorphism/same-type/driver.cxx
+++ b/tests/cxx/tree/polymorphism/same-type/driver.cxx
@@ -6,7 +6,7 @@
 // Test substitution group and xsi:type that don't change the type.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 
 #include "test.hxx"
@@ -25,7 +25,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
 
     cout << *r << endl;
   }
diff --git a/tests/cxx/tree/polymorphism/same-type/makefile b/tests/cxx/tree/polymorphism/same-type/makefile
index 88a7f3d..407fc07 100644
--- a/tests/cxx/tree/polymorphism/same-type/makefile
+++ b/tests/cxx/tree/polymorphism/same-type/makefile
@@ -75,7 +75,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/prefix/driver.cxx b/tests/cxx/tree/prefix/driver.cxx
index 08c416c..5a5bfee 100644
--- a/tests/cxx/tree/prefix/driver.cxx
+++ b/tests/cxx/tree/prefix/driver.cxx
@@ -6,7 +6,7 @@
 // Test automatic prefix assignment.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 
 #include "test.hxx"
@@ -25,7 +25,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
     root (std::cout, *r);
   }
   catch (xml_schema::exception const& e)
diff --git a/tests/cxx/tree/prefix/makefile b/tests/cxx/tree/prefix/makefile
index 815a970..c1a4703 100644
--- a/tests/cxx/tree/prefix/makefile
+++ b/tests/cxx/tree/prefix/makefile
@@ -75,7 +75,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/test-template/driver.cxx b/tests/cxx/tree/test-template/driver.cxx
index 1bb06cb..0cdb0e4 100644
--- a/tests/cxx/tree/test-template/driver.cxx
+++ b/tests/cxx/tree/test-template/driver.cxx
@@ -6,7 +6,7 @@
 // Insert test description here.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 
 #include "test.hxx"
@@ -25,7 +25,7 @@ main (int argc, char* argv[])
 
   try
   {
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
 
     cout << *r << endl;
   }
diff --git a/tests/cxx/tree/test-template/makefile b/tests/cxx/tree/test-template/makefile
index 77c83e1..734b705 100644
--- a/tests/cxx/tree/test-template/makefile
+++ b/tests/cxx/tree/test-template/makefile
@@ -74,7 +74,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/types-only/driver.cxx b/tests/cxx/tree/types-only/driver.cxx
index 198d8ca..414012e 100644
--- a/tests/cxx/tree/types-only/driver.cxx
+++ b/tests/cxx/tree/types-only/driver.cxx
@@ -7,7 +7,6 @@
 // still compiles.
 //
 
-#include  // std::auto_ptr
 #include 
 
 #include "test.hxx"
diff --git a/tests/cxx/tree/types-only/makefile b/tests/cxx/tree/types-only/makefile
index 9cca14a..66c7a95 100644
--- a/tests/cxx/tree/types-only/makefile
+++ b/tests/cxx/tree/types-only/makefile
@@ -74,7 +74,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/union/ctor/makefile b/tests/cxx/tree/union/ctor/makefile
index 6bb4887..38b4354 100644
--- a/tests/cxx/tree/union/ctor/makefile
+++ b/tests/cxx/tree/union/ctor/makefile
@@ -75,7 +75,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/tests/cxx/tree/wildcard/driver.cxx b/tests/cxx/tree/wildcard/driver.cxx
index d784a97..9798159 100644
--- a/tests/cxx/tree/wildcard/driver.cxx
+++ b/tests/cxx/tree/wildcard/driver.cxx
@@ -6,13 +6,13 @@
 // Test wildcard (any & anyAttribute) mapping.
 //
 
-#include  // std::auto_ptr
+#include  // std::auto_ptr/unique_ptr
 #include 
 #include 
 
-#include 
+#include "test.hxx" // Get XSD_CXX11 defined.
 
-#include "test.hxx"
+#include 
 
 using namespace std;
 using namespace test;
@@ -170,7 +170,7 @@ main (int argc, char* argv[])
 
     // Test parsing
     //
-    auto_ptr r (root (argv[1]));
+    XSD_AUTO_PTR r (root (argv[1]));
     print (*r);
 
     // Test serialization.
@@ -187,7 +187,7 @@ main (int argc, char* argv[])
     // cout << iostr.str () << endl
     //      << endl;
 
-    auto_ptr copy (root (iostr, argv[1]));
+    XSD_AUTO_PTR copy (root (iostr, argv[1]));
     assert (*copy == *r);
 
     print (*copy);
diff --git a/tests/cxx/tree/wildcard/makefile b/tests/cxx/tree/wildcard/makefile
index 9b6a994..4adc8b9 100644
--- a/tests/cxx/tree/wildcard/makefile
+++ b/tests/cxx/tree/wildcard/makefile
@@ -75,7 +75,12 @@ endif
 $(call include,$(bld_root)/cxx/o-e.make)
 $(call include,$(bld_root)/cxx/cxx-o.make)
 $(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
 $(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
 
 
 # Dependencies.
diff --git a/xsd/cxx/elements.cxx b/xsd/cxx/elements.cxx
index 4a76444..5ee1f28 100644
--- a/xsd/cxx/elements.cxx
+++ b/xsd/cxx/elements.cxx
@@ -118,10 +118,12 @@ namespace CXX
         schema_root (root),
         schema_path (schema_path_),
         options (ops),
+        std (ops.std ()),
         char_type (char_type_),
         char_encoding (char_encoding_),
         L (L_),
         string_type (string_type_),
+        auto_ptr (auto_ptr_),
         string_literal_map (string_literal_map_),
         type_exp (type_exp_),
         inst_exp (inst_exp_),
@@ -184,6 +186,12 @@ namespace CXX
     else
       string_type_ = L"::std::basic_string< " + char_type + L" >";
 
+    // Automatic pointer type.
+    //
+    auto_ptr_ = std >= cxx_version::cxx11
+      ? "::std::unique_ptr"
+      : "::std::auto_ptr";
+
     // Default encoding.
     //
     if (!char_encoding)
@@ -197,7 +205,7 @@ namespace CXX
     // Default mapping.
     //
     nsr_mapping_.push_back (
-      Regex (L"#^.* (.*?/)??"L"(([a-zA-Z_]\\w*)(/[a-zA-Z_]\\w*)*)/?$#$2#"));
+      Regex (L"#^.* (.*?/)??" L"(([a-zA-Z_]\\w*)(/[a-zA-Z_]\\w*)*)/?$#$2#"));
     nsr_mapping_.push_back (
       Regex (L"#^.* http://www\\.w3\\.org/2001/XMLSchema$#xml_schema#"));
 
@@ -1093,9 +1101,10 @@ namespace CXX
       {
         if (escape)
         {
-          // Close and open the string so there are no clashes.
+          // Close and open the string so there are no clashes. C++11
+          // requires a space between " and L.
           //
-          r += L"\"L\"";
+          r += L"\" L\"";
           escape = false;
         }
 
diff --git a/xsd/cxx/elements.hxx b/xsd/cxx/elements.hxx
index f978f51..d0d07e7 100644
--- a/xsd/cxx/elements.hxx
+++ b/xsd/cxx/elements.hxx
@@ -159,10 +159,12 @@ namespace CXX
           schema_root (c.schema_root),
           schema_path (c.schema_path),
           options (c.options),
+          std (c.std),
           char_type (c.char_type),
           char_encoding (c.char_encoding),
           L (c.L),
           string_type (c.string_type),
+          auto_ptr (c.auto_ptr),
           string_literal_map (c.string_literal_map),
           type_exp (c.type_exp),
           inst_exp (c.inst_exp),
@@ -184,10 +186,12 @@ namespace CXX
           schema_root (c.schema_root),
           schema_path (c.schema_path),
           options (c.options),
+          std (c.std),
           char_type (c.char_type),
           char_encoding (c.char_encoding),
           L (c.L),
           string_type (c.string_type),
+          auto_ptr (c.auto_ptr),
           string_literal_map (c.string_literal_map),
           type_exp (c.type_exp),
           inst_exp (c.inst_exp),
@@ -328,10 +332,14 @@ namespace CXX
 
     options_type const& options;
 
+    cxx_version std;
+
     String& char_type;
     String& char_encoding;
     String& L;                  // string literal prefix
     String& string_type;
+    String& auto_ptr;
+
     StringLiteralMap const* string_literal_map;
 
     String& type_exp;
@@ -350,6 +358,7 @@ namespace CXX
     String char_encoding_;
     String L_;
     String string_type_;
+    String auto_ptr_;
 
     String type_exp_;
     String inst_exp_;
diff --git a/xsd/cxx/options.cli b/xsd/cxx/options.cli
index 2203188..78fd587 100644
--- a/xsd/cxx/options.cli
+++ b/xsd/cxx/options.cli
@@ -21,7 +21,23 @@ namespace CXX
     {
       "",
       "Specify the C++ standard that the generated code should conform to.
-       Valid values are \cb{c++98} (default) and \cb{c++11}."
+       Valid values are \cb{c++98} (default) and \cb{c++11}.
+
+       The C++ standard affects various aspects of the generated code that
+       are discussed in more detail in various mapping-specific
+       documentation. Overall, when C++11 is selected, the generated
+       code relies on the move semantics and uses \cb{std::unique_ptr}
+       instead of deprecated \cb{std::auto_ptr}.
+
+       When the C++11 mode is selected, you normally don't need to
+       perform any extra steps other than enable C++11 in your C++
+       compiler, if required. The XSD compiler will automatically
+       add the necessary macro defines to the generated header files
+       that will switch the header-only XSD runtime library (\cb{libxsd})
+       to the C++11 mode. However, if you include any of the XSD runtime
+       headers directly in your application (normally you just include
+       the generated headers), then you will need to define the
+       \cb{XSD_CXX11} macro for your entire project."
     };
 
     // Character type and encoding.
diff --git a/xsd/cxx/parser/attribute-validation-source.cxx b/xsd/cxx/parser/attribute-validation-source.cxx
index c4fe5ad..ba412b0 100644
--- a/xsd/cxx/parser/attribute-validation-source.cxx
+++ b/xsd/cxx/parser/attribute-validation-source.cxx
@@ -126,7 +126,7 @@ namespace CXX
             // compilers (e.g., IBM xlC that needs an lvalue to pass
             // std::auto_ptr).
             //
-            if (options.std () == cxx_version::cxx98)
+            if (std == cxx_version::cxx98)
               os << arg_type (type) << " tmp (this->" << inst << "->" <<
                 post << " ());"
                  << "this->" << name << " (tmp);";
diff --git a/xsd/cxx/parser/element-validation-source.cxx b/xsd/cxx/parser/element-validation-source.cxx
index 310ea27..1bc506a 100644
--- a/xsd/cxx/parser/element-validation-source.cxx
+++ b/xsd/cxx/parser/element-validation-source.cxx
@@ -314,7 +314,7 @@ namespace CXX
               // compilers (e.g., IBM xlC that needs an lvalue to pass
               // std::auto_ptr).
               //
-              if (options.std () == cxx_version::cxx98)
+              if (std == cxx_version::cxx98)
                 os << arg_type (type) << " tmp (" << inst << "->" <<
                   post << " ());"
                    << "this->" << name << " (tmp);";
diff --git a/xsd/cxx/parser/generator.cxx b/xsd/cxx/parser/generator.cxx
index a262004..46a0687 100644
--- a/xsd/cxx/parser/generator.cxx
+++ b/xsd/cxx/parser/generator.cxx
@@ -290,12 +290,14 @@ namespace CXX
           string_type = L"::std::basic_string< " + char_type + L" >";
 
         String xns;
+        String auto_ptr;
         {
           Context ctx (std::wcerr, schema, file_path, ops, 0, 0, 0, 0);
           xns = ctx.xs_ns_name ();
+          auto_ptr = ctx.auto_ptr;
         }
 
-        String buffer (L"::std::auto_ptr< " + xns + L"::buffer >");
+        String buffer (auto_ptr + L"< " + xns + L"::buffer >");
         TypeMap::Namespace xsd ("http://www\\.w3\\.org/2001/XMLSchema");
 
         xsd.types_push_back ("string", string_type);
@@ -777,6 +779,14 @@ namespace CXX
             << "#define " << guard << endl
             << endl;
 
+        if (ctx.std >= cxx_version::cxx11)
+        {
+          hxx << "#ifndef XSD_CXX11" << endl
+              << "#define XSD_CXX11" << endl
+              << "#endif" << endl
+              << endl;
+        }
+
         // Version check.
         //
         hxx << "#include " << endl
diff --git a/xsd/cxx/parser/parser-header.cxx b/xsd/cxx/parser/parser-header.cxx
index 5db1ef4..cd266ae 100644
--- a/xsd/cxx/parser/parser-header.cxx
+++ b/xsd/cxx/parser/parser-header.cxx
@@ -1008,7 +1008,7 @@ namespace CXX
         virtual void
         traverse (SemanticGraph::Fundamental::Base64Binary& t)
         {
-          String buffer (L"::std::auto_ptr< " + xs_ns_ + L"::buffer >");
+          String buffer (auto_ptr + L"< " + xs_ns_ + L"::buffer >");
           gen_typedef (t, buffer,
                        "base64_binary_pskel", "base64_binary_pimpl");
         }
@@ -1016,7 +1016,7 @@ namespace CXX
         virtual void
         traverse (SemanticGraph::Fundamental::HexBinary& t)
         {
-          String buffer (L"::std::auto_ptr< " + xs_ns_ + L"::buffer >");
+          String buffer (auto_ptr + L"< " + xs_ns_ + L"::buffer >");
           gen_typedef (t, buffer, "hex_binary_pskel", "hex_binary_pimpl");
         }
 
diff --git a/xsd/cxx/parser/print-impl-common.hxx b/xsd/cxx/parser/print-impl-common.hxx
index db26ea8..ab38ea4 100644
--- a/xsd/cxx/parser/print-impl-common.hxx
+++ b/xsd/cxx/parser/print-impl-common.hxx
@@ -605,7 +605,7 @@ namespace CXX
       void
       gen_buffer (SemanticGraph::Type& t)
       {
-        String type (L"::std::auto_ptr< " + xs_ns_name () + L"::buffer >");
+        String type (auto_ptr + L"< " + xs_ns_name () + L"::buffer >");
 
         if (default_type (t, type))
         {
diff --git a/xsd/cxx/tree/elements.cxx b/xsd/cxx/tree/elements.cxx
index 8021287..10bf999 100644
--- a/xsd/cxx/tree/elements.cxx
+++ b/xsd/cxx/tree/elements.cxx
@@ -93,7 +93,10 @@ namespace CXX
             xsc.get ("error-handler");
         }
 
-        dom_auto_ptr_ = xs_name + L"::dom::auto_ptr";
+        dom_auto_ptr_ = xs_name + (std >= cxx_version::cxx11
+                                   ? L"::dom::unique_ptr"
+                                   : L"::dom::auto_ptr");
+
         dom_node_key_ = xs_name + L"::dom::" +
           xsc.get ("tree-node-key");
 
@@ -828,7 +831,7 @@ namespace CXX
     // FromBaseCtorArg
     //
     FromBaseCtorArg::
-    FromBaseCtorArg (Context& c, ArgType at, bool arg)
+    FromBaseCtorArg (Context& c, CtorArgType at, bool arg)
         : Context (c), arg_type_ (at), arg_ (arg)
     {
     }
@@ -863,29 +866,29 @@ namespace CXX
 
         os << "," << endl;
 
-        bool auto_ptr (false);
+        bool ptr (false);
 
         switch (arg_type_)
         {
-        case arg_complex_auto_ptr:
+        case CtorArgType::complex_auto_ptr:
           {
             bool simple (true);
             IsSimpleType t (simple);
             t.dispatch (e.type ());
-            auto_ptr = !simple;
+            ptr = !simple;
             break;
           }
-        case arg_poly_auto_ptr:
+        case CtorArgType::poly_auto_ptr:
           {
-            auto_ptr = polymorphic && polymorphic_p (e.type ());
+            ptr = polymorphic && polymorphic_p (e.type ());
             break;
           }
-        case arg_type:
+        case CtorArgType::type:
           break;
         }
 
-        if (auto_ptr)
-          os << "::std::auto_ptr< " << etype (e) << " >&";
+        if (ptr)
+          os << auto_ptr << "< " << etype (e) << " >";
         else
           os << "const " << etype (e) << "&";
 
@@ -916,7 +919,7 @@ namespace CXX
     // CtorArgs
     //
     CtorArgs::
-    CtorArgs (Context& c, ArgType at)
+    CtorArgs (Context& c, CtorArgType at)
         : Context (c),
           arg_type_ (at),
           base_arg_ (0),
@@ -928,7 +931,7 @@ namespace CXX
     }
 
     CtorArgs::
-    CtorArgs (Context& c, ArgType at, String& base_arg)
+    CtorArgs (Context& c, CtorArgType at, String& base_arg)
         : Context (c),
           arg_type_ (at),
           base_arg_ (&base_arg),
@@ -1000,29 +1003,29 @@ namespace CXX
 
       if (min (e) == 1 && max (e) == 1)
       {
-        bool auto_ptr (false);
+        bool ptr (false);
 
         switch (arg_type_)
         {
-        case arg_complex_auto_ptr:
+        case CtorArgType::complex_auto_ptr:
           {
             bool simple (true);
             IsSimpleType t (simple);
             t.dispatch (e.type ());
-            auto_ptr = !simple;
+            ptr = !simple;
             break;
           }
-        case arg_poly_auto_ptr:
+        case CtorArgType::poly_auto_ptr:
           {
-            auto_ptr = polymorphic && polymorphic_p (e.type ());
+            ptr = polymorphic && polymorphic_p (e.type ());
             break;
           }
-        case arg_type:
+        case CtorArgType::type:
           break;
         }
 
-        if (auto_ptr)
-          os << comma () << "::std::auto_ptr< " << etype (e) << " >&";
+        if (ptr)
+          os << comma () << auto_ptr << "< " << etype (e) << " >";
         else
           os << comma () << "const " << etype (e) << "&";
 
@@ -1059,7 +1062,7 @@ namespace CXX
     // CtorArgsWithoutBase
     //
     CtorArgsWithoutBase::
-    CtorArgsWithoutBase (Context& c, ArgType at, bool arg, bool first)
+    CtorArgsWithoutBase (Context& c, CtorArgType at, bool arg, bool first)
         : Context (c), arg_type_ (at), arg_ (arg), first_ (first)
     {
       *this >> inherits_ >> *this;
@@ -1089,29 +1092,29 @@ namespace CXX
 
       if (min (e) == 1 && max (e) == 1)
       {
-        bool auto_ptr (false);
+        bool ptr (false);
 
         switch (arg_type_)
         {
-        case arg_complex_auto_ptr:
+        case CtorArgType::complex_auto_ptr:
           {
             bool simple (true);
             IsSimpleType t (simple);
             t.dispatch (e.type ());
-            auto_ptr = !simple;
+            ptr = !simple;
             break;
           }
-        case arg_poly_auto_ptr:
+        case CtorArgType::poly_auto_ptr:
           {
-            auto_ptr = polymorphic && polymorphic_p (e.type ());
+            ptr = polymorphic && polymorphic_p (e.type ());
             break;
           }
-        case arg_type:
+        case CtorArgType::type:
           break;
         }
 
-        if (auto_ptr)
-          os << comma () << "::std::auto_ptr< " << etype (e) << " >&";
+        if (ptr)
+          os << comma () << auto_ptr << "< " << etype (e) << " >";
         else
           os << comma () << "const " << etype (e) << "&";
 
diff --git a/xsd/cxx/tree/elements.hxx b/xsd/cxx/tree/elements.hxx
index b7d6626..deb3a5e 100644
--- a/xsd/cxx/tree/elements.hxx
+++ b/xsd/cxx/tree/elements.hxx
@@ -1496,6 +1496,24 @@ namespace CXX
       Traversal::Names names_;
     };
 
+    // Contructor argument types.
+    //
+    struct CtorArgType
+    {
+      enum Value
+      {
+        type,
+        complex_auto_ptr,
+        poly_auto_ptr
+      };
+
+      CtorArgType (Value v = Value (0)) : v_ (v) {}
+      operator Value () const {return v_;}
+
+    private:
+      Value v_;
+    };
+
     // Immediate non-optional member. Note that AnyAttribute is always
     // mapped to a sequence.
     //
@@ -1504,14 +1522,7 @@ namespace CXX
                             Traversal::Attribute,
                             Context
     {
-      enum ArgType
-      {
-        arg_type,
-        arg_complex_auto_ptr,
-        arg_poly_auto_ptr
-      };
-
-      FromBaseCtorArg (Context& c, ArgType, bool arg);
+      FromBaseCtorArg (Context& c, CtorArgType, bool arg);
 
       virtual void
       traverse (SemanticGraph::Any&);
@@ -1523,7 +1534,7 @@ namespace CXX
       traverse (SemanticGraph::Element&);
 
     private:
-      ArgType arg_type_;
+      CtorArgType arg_type_;
       bool arg_;
     };
 
@@ -1538,18 +1549,11 @@ namespace CXX
                      Traversal::Attribute,
                      Context
     {
-      enum ArgType
-      {
-        arg_type,
-        arg_complex_auto_ptr,
-        arg_poly_auto_ptr
-      };
-
       // The second version outputs the argument name and stores
       // in in the base_arg string.
       //
-      CtorArgs (Context&, ArgType);
-      CtorArgs (Context&, ArgType, String& base_arg);
+      CtorArgs (Context&, CtorArgType);
+      CtorArgs (Context&, CtorArgType, String& base_arg);
 
       virtual void
       traverse (SemanticGraph::Type&);
@@ -1571,7 +1575,7 @@ namespace CXX
       comma ();
 
     private:
-      ArgType arg_type_;
+      CtorArgType arg_type_;
       String base_;
       String* base_arg_;
       bool first_;
@@ -1705,14 +1709,7 @@ namespace CXX
                                 Traversal::Attribute,
                                 Context
     {
-      enum ArgType
-      {
-        arg_type,
-        arg_complex_auto_ptr,
-        arg_poly_auto_ptr
-      };
-
-      CtorArgsWithoutBase (Context& c, ArgType, bool arg, bool first);
+      CtorArgsWithoutBase (Context& c, CtorArgType, bool arg, bool first);
 
       virtual void
       traverse (SemanticGraph::Any&);
@@ -1728,7 +1725,7 @@ namespace CXX
       comma ();
 
     private:
-      ArgType arg_type_;
+      CtorArgType arg_type_;
       bool arg_;
       bool first_;
 
diff --git a/xsd/cxx/tree/fundamental-header.hxx b/xsd/cxx/tree/fundamental-header.hxx
index 2171de4..18a5e61 100644
--- a/xsd/cxx/tree/fundamental-header.hxx
+++ b/xsd/cxx/tree/fundamental-header.hxx
@@ -1146,7 +1146,8 @@ namespace CXX
              << "{";
 
           // @@ Disregarding current naming convention by using the
-          //    fixed name (no template typedef).
+          //    fixed name (even in C++11, template alias is not yet
+          //    widely supported).
           //
           if (doxygen)
             os << "/**" << endl
@@ -1156,8 +1157,12 @@ namespace CXX
             os << "// Automatic pointer for DOMDocument." << endl
                << "//" << endl;
 
-          os << "using ::xsd::cxx::xml::dom::auto_ptr;"
-             << endl;
+          if (std >= cxx_version::cxx11)
+            os << "using ::xsd::cxx::xml::dom::unique_ptr;";
+          else
+            os << "using ::xsd::cxx::xml::dom::auto_ptr;";
+
+          os << endl;
 
           if (parsing)
           {
diff --git a/xsd/cxx/tree/generator.cxx b/xsd/cxx/tree/generator.cxx
index b373d31..35c53bc 100644
--- a/xsd/cxx/tree/generator.cxx
+++ b/xsd/cxx/tree/generator.cxx
@@ -188,6 +188,7 @@ namespace CXX
             FileList& file_list,
             AutoUnlinks& unlinks)
   {
+    using cutl::shared_ptr;
     typedef cutl::re::regexsub Regex;
 
     typedef vector Paths;
@@ -711,29 +712,13 @@ namespace CXX
             << "#define " << guard << endl
             << endl;
 
-        // Version check.
-        //
-        fwd << "#include " << endl
-            << endl
-            << "#if (XSD_INT_VERSION != " << XSD_INT_VERSION << "L)" << endl
-            << "#error XSD runtime version mismatch" << endl
-            << "#endif" << endl
-            << endl;
-
-        fwd << "#include " << endl
+        if (ctx.std >= cxx_version::cxx11)
+        {
+          fwd << "#ifndef XSD_CXX11" << endl
+              << "#define XSD_CXX11" << endl
+              << "#endif" << endl
               << endl;
-
-        // Copy prologue.
-        //
-        fwd << "// Begin prologue." << endl
-            << "//" << endl;
-
-        append (fwd, ops.fwd_prologue (), ops.prologue ());
-        append (fwd, ops.fwd_prologue_file (), prologue);
-
-        fwd << "//" << endl
-            << "// End prologue." << endl
-            << endl;
+        }
 
         if (ctx.char_type == L"char")
         {
@@ -760,6 +745,30 @@ namespace CXX
               << endl;
         }
 
+        // Version check.
+        //
+        fwd << "#include " << endl
+            << endl
+            << "#if (XSD_INT_VERSION != " << XSD_INT_VERSION << "L)" << endl
+            << "#error XSD runtime version mismatch" << endl
+            << "#endif" << endl
+            << endl;
+
+        fwd << "#include " << endl
+              << endl;
+
+        // Copy prologue.
+        //
+        fwd << "// Begin prologue." << endl
+            << "//" << endl;
+
+        append (fwd, ops.fwd_prologue (), ops.prologue ());
+        append (fwd, ops.fwd_prologue_file (), prologue);
+
+        fwd << "//" << endl
+            << "// End prologue." << endl
+            << endl;
+
         // Generate.
         //
         {
@@ -817,34 +826,16 @@ namespace CXX
             << "#define " << guard << endl
             << endl;
 
-        // Version check.
-        //
-        hxx << "#include " << endl
-            << endl
-            << "#if (XSD_INT_VERSION != " << XSD_INT_VERSION << "L)" << endl
-            << "#error XSD runtime version mismatch" << endl
-            << "#endif" << endl
-            << endl;
-
-        hxx << "#include " << endl
-            << endl;
-
-        // Copy prologue.
-        //
-        hxx << "// Begin prologue." << endl
-            << "//" << endl;
-
-        append (hxx, ops.hxx_prologue (), ops.prologue ());
-        append (hxx, ops.hxx_prologue_file (), prologue);
-
-        hxx << "//" << endl
-            << "// End prologue." << endl
-            << endl;
-
-        // Generate character selection defines.
-        //
         if (!forward)
         {
+          if (ctx.std >= cxx_version::cxx11)
+          {
+            hxx << "#ifndef XSD_CXX11" << endl
+                << "#define XSD_CXX11" << endl
+                << "#endif" << endl
+                << endl;
+          }
+
           if (ctx.char_type == L"char")
           {
             hxx << "#ifndef XSD_USE_CHAR" << endl
@@ -871,6 +862,30 @@ namespace CXX
           }
         }
 
+        // Version check.
+        //
+        hxx << "#include " << endl
+            << endl
+            << "#if (XSD_INT_VERSION != " << XSD_INT_VERSION << "L)" << endl
+            << "#error XSD runtime version mismatch" << endl
+            << "#endif" << endl
+            << endl;
+
+        hxx << "#include " << endl
+            << endl;
+
+        // Copy prologue.
+        //
+        hxx << "// Begin prologue." << endl
+            << "//" << endl;
+
+        append (hxx, ops.hxx_prologue (), ops.prologue ());
+        append (hxx, ops.hxx_prologue_file (), prologue);
+
+        hxx << "//" << endl
+            << "// End prologue." << endl
+            << endl;
+
         // Generate.
         //
         {
diff --git a/xsd/cxx/tree/parser-header.cxx b/xsd/cxx/tree/parser-header.cxx
index 59cc043..cdad52c 100644
--- a/xsd/cxx/tree/parser-header.cxx
+++ b/xsd/cxx/tree/parser-header.cxx
@@ -71,7 +71,7 @@ namespace CXX
           }
 
           os << inst_exp
-             << "::std::auto_ptr< " << type_name (e) << " >" << endl
+             << auto_ptr << "< " << type_name (e) << " >" << endl
              << name << " (const " << string_type << "& uri," << endl
              << flags_type << " f = 0," << endl
              << "const " << properties_type << "& p = " << properties_type << " ());"
@@ -94,7 +94,7 @@ namespace CXX
           }
 
           os << inst_exp
-             << "::std::auto_ptr< " << type_name (e) << " >" << endl
+             << auto_ptr << "< " << type_name (e) << " >" << endl
              << name << " (const " << string_type << "& uri," << endl
              << error_handler << "& eh," << endl
              << flags_type << " f = 0," << endl
@@ -120,7 +120,7 @@ namespace CXX
           }
 
           os << inst_exp
-             << "::std::auto_ptr< " << type_name (e) << " >" << endl
+             << auto_ptr << "< " << type_name (e) << " >" << endl
              << name << " (const " << string_type << "& uri," << endl
              << xerces_ns << "::DOMErrorHandler& eh," << endl
              << flags_type << " f = 0," << endl
@@ -149,7 +149,7 @@ namespace CXX
           }
 
           os << inst_exp
-             << "::std::auto_ptr< " << type_name (e) << " >" << endl
+             << auto_ptr << "< " << type_name (e) << " >" << endl
              << name << " (::std::istream& is," << endl
              << flags_type << " f = 0," << endl
              << "const " << properties_type << "& p = " << properties_type << " ());"
@@ -172,7 +172,7 @@ namespace CXX
           }
 
           os << inst_exp
-             << "::std::auto_ptr< " << type_name (e) << " >" << endl
+             << auto_ptr << "< " << type_name (e) << " >" << endl
              << name << " (::std::istream& is," << endl
              << error_handler << "& eh," << endl
              << flags_type << " f = 0," << endl
@@ -198,7 +198,7 @@ namespace CXX
           }
 
           os << inst_exp
-             << "::std::auto_ptr< " << type_name (e) << " >" << endl
+             << auto_ptr << "< " << type_name (e) << " >" << endl
              << name << " (::std::istream& is," << endl
              << xerces_ns << "::DOMErrorHandler& eh," << endl
              << flags_type << " f = 0," << endl
@@ -225,7 +225,7 @@ namespace CXX
           }
 
           os << inst_exp
-             << "::std::auto_ptr< " << type_name (e) << " >" << endl
+             << auto_ptr << "< " << type_name (e) << " >" << endl
              << name << " (::std::istream& is," << endl
              << "const " << string_type << "& id," << endl
              << flags_type << " f = 0," << endl
@@ -256,7 +256,7 @@ namespace CXX
           }
 
           os << inst_exp
-             << "::std::auto_ptr< " << type_name (e) << " >" << endl
+             << auto_ptr << "< " << type_name (e) << " >" << endl
              << name << " (::std::istream& is," << endl
              << "const " << string_type << "& id," << endl
              << error_handler << "& eh," << endl
@@ -288,7 +288,7 @@ namespace CXX
           }
 
           os << inst_exp
-             << "::std::auto_ptr< " << type_name (e) << " >" << endl
+             << auto_ptr << "< " << type_name (e) << " >" << endl
              << name << " (::std::istream& is," << endl
              << "const " << string_type << "& id," << endl
              << xerces_ns << "::DOMErrorHandler& eh," << endl
@@ -318,7 +318,7 @@ namespace CXX
           }
 
           os << inst_exp
-             << "::std::auto_ptr< " << type_name (e) << " >" << endl
+             << auto_ptr << "< " << type_name (e) << " >" << endl
              << name << " (" << xerces_ns << "::InputSource& is," << endl
              << flags_type << " f = 0," << endl
              << "const " << properties_type << "& p = " << properties_type << " ());"
@@ -342,7 +342,7 @@ namespace CXX
           }
 
           os << inst_exp
-             << "::std::auto_ptr< " << type_name (e) << " >" << endl
+             << auto_ptr << "< " << type_name (e) << " >" << endl
              << name << " (" << xerces_ns << "::InputSource& is," << endl
              << error_handler << "& eh," << endl
              << flags_type << " f = 0," << endl
@@ -368,7 +368,7 @@ namespace CXX
           }
 
           os << inst_exp
-             << "::std::auto_ptr< " << type_name (e) << " >" << endl
+             << auto_ptr << "< " << type_name (e) << " >" << endl
              << name << " (" << xerces_ns << "::InputSource& is," << endl
              << xerces_ns << "::DOMErrorHandler& eh," << endl
              << flags_type << " f = 0," << endl
@@ -395,7 +395,7 @@ namespace CXX
           }
 
           os << inst_exp
-             << "::std::auto_ptr< " << type_name (e) << " >" << endl
+             << auto_ptr << "< " << type_name (e) << " >" << endl
              << name << " (const " << xerces_ns << "::DOMDocument& d," << endl
              << flags_type << " f = 0," << endl
              << "const " << properties_type << "& p = " << properties_type << " ());"
@@ -420,9 +420,9 @@ namespace CXX
           }
 
           os << inst_exp
-             << "::std::auto_ptr< " << type_name (e) << " >" << endl
+             << auto_ptr << "< " << type_name (e) << " >" << endl
              << name << " (" << dom_auto_ptr << "< " << xerces_ns <<
-            "::DOMDocument >& d," << endl
+            "::DOMDocument > d," << endl
              << flags_type << " f = 0," << endl
              << "const " << properties_type << "& p = " << properties_type << " ());"
              << endl;
diff --git a/xsd/cxx/tree/parser-source.cxx b/xsd/cxx/tree/parser-source.cxx
index 362e9e6..be641e5 100644
--- a/xsd/cxx/tree/parser-source.cxx
+++ b/xsd/cxx/tree/parser-source.cxx
@@ -38,9 +38,11 @@ namespace CXX
           // confused if the name is 'type'. (see tests/schema/anonymous)
           //
 
+          char const* d (std >= cxx_version::cxx11 ? "std::move (d)" : "d");
+
           // URI.
           //
-          os << "::std::auto_ptr< " << type << " >" << endl
+          os << auto_ptr << "< " << type << " >" << endl
              << name << " (const " << string_type << "& u," << endl
              << flags_type << " f," << endl
              << "const " << properties_type << "& p)"
@@ -59,19 +61,17 @@ namespace CXX
           if (options.disable_multi_import ())
             os << " | ::xsd::cxx::xml::dom::no_muliple_imports";
 
-            os << "));"
+          os << "));"
              << endl
              << "h.throw_if_failed< ::xsd::cxx::tree::parsing< " <<
             char_type << " > > ();"
              << endl
-             << "::std::auto_ptr< " << type << " > r (" << endl
+             << "return " << auto_ptr << "< " << type << " > (" << endl
              << fq_name (e, "parser") << " (" << endl
-             << "d, f | " << flags_type << "::own_dom, p));"
-             << endl
-             << "return r;"
+             << d << ", f | " << flags_type << "::own_dom, p));"
              << "}";
 
-          os << "::std::auto_ptr< " << type << " >" << endl
+          os << auto_ptr << "< " << type << " >" << endl
              << name << " (const " << string_type << "& u," << endl
              << error_handler << "& h," << endl
              << flags_type << " f," << endl
@@ -94,14 +94,12 @@ namespace CXX
              << "if (!d.get ())" << endl
              << "throw ::xsd::cxx::tree::parsing< " << char_type << " > ();"
              << endl
-             << "::std::auto_ptr< " << type << " > r (" << endl
+             << "return " << auto_ptr << "< " << type << " > (" << endl
              << fq_name (e, "parser") << " (" << endl
-             << "d, f | " << flags_type << "::own_dom, p));"
-             << endl
-             << "return r;"
+             << d << ", f | " << flags_type << "::own_dom, p));"
              << "}";
 
-          os << "::std::auto_ptr< " << type << " >" << endl
+          os << auto_ptr << "< " << type << " >" << endl
              << name << " (const " << string_type << "& u," << endl
              << xerces_ns << "::DOMErrorHandler& h," << endl
              << flags_type << " f," << endl
@@ -120,17 +118,15 @@ namespace CXX
              << "if (!d.get ())" << endl
              << "throw ::xsd::cxx::tree::parsing< " << char_type << " > ();"
              << endl
-             << "::std::auto_ptr< " << type << " > r (" << endl
+             << "return " << auto_ptr << "< " << type << " > (" << endl
              << fq_name (e, "parser") << " (" << endl
-             << "d, f | " << flags_type << "::own_dom, p));"
-             << endl
-             << "return r;"
+             << d << ", f | " << flags_type << "::own_dom, p));"
              << "}";
 
 
           // istream
           //
-          os << "::std::auto_ptr< " << type << " >" << endl
+          os << auto_ptr << "< " << type << " >" << endl
              << name << " (::std::istream& is," << endl
              << flags_type << " f," << endl
              << "const " << properties_type << "& p)"
@@ -143,7 +139,7 @@ namespace CXX
              << "return " << fq_name (e, "parser") << " (isrc, f, p);"
              << "}";
 
-          os << "::std::auto_ptr< " << type << " >" << endl
+          os << auto_ptr << "< " << type << " >" << endl
              << name << " (::std::istream& is," << endl
              << error_handler << "& h," << endl
              << flags_type << " f," << endl
@@ -157,7 +153,7 @@ namespace CXX
              << "return " << fq_name (e, "parser") << " (isrc, h, f, p);"
              << "}";
 
-          os << "::std::auto_ptr< " << type << " >" << endl
+          os << auto_ptr << "< " << type << " >" << endl
              << name << " (::std::istream& is," << endl
              << xerces_ns << "::DOMErrorHandler& h," << endl
              << flags_type << " f," << endl
@@ -167,7 +163,7 @@ namespace CXX
              << "return " << fq_name (e, "parser") << " (isrc, h, f, p);"
              << "}";
 
-          os << "::std::auto_ptr< " << type << " >" << endl
+          os << auto_ptr << "< " << type << " >" << endl
              << name << " (::std::istream& is," << endl
              << "const " << string_type << "& sid," << endl
              << flags_type << " f," << endl
@@ -181,7 +177,7 @@ namespace CXX
              << "return " << fq_name (e, "parser") << " (isrc, f, p);"
              << "}";
 
-          os << "::std::auto_ptr< " << type << " >" << endl
+          os << auto_ptr << "< " << type << " >" << endl
              << name << " (::std::istream& is," << endl
              << "const " << string_type << "& sid," << endl
              << error_handler << "& h," << endl
@@ -196,7 +192,7 @@ namespace CXX
              << "return " << fq_name (e, "parser") << " (isrc, h, f, p);"
              << "}";
 
-          os << "::std::auto_ptr< " << type << " >" << endl
+          os << auto_ptr << "< " << type << " >" << endl
              << name << " (::std::istream& is," << endl
              << "const " << string_type << "& sid," << endl
              << xerces_ns << "::DOMErrorHandler& h," << endl
@@ -210,7 +206,7 @@ namespace CXX
 
           // InputSource.
           //
-          os << "::std::auto_ptr< " << type << " >" << endl
+          os << auto_ptr << "< " << type << " >" << endl
              << name << " (" << xerces_ns << "::InputSource& i," << endl
              << flags_type << " f," << endl
              << "const " << properties_type << "& p)"
@@ -230,14 +226,12 @@ namespace CXX
              << "h.throw_if_failed< ::xsd::cxx::tree::parsing< " <<
             char_type << " > > ();"
              << endl
-             << "::std::auto_ptr< " << type << " > r (" << endl
+             << "return " << auto_ptr << "< " << type << " > (" << endl
              << fq_name (e, "parser") << " (" << endl
-             << "d, f | " << flags_type << "::own_dom, p));"
-             << endl
-             << "return r;"
+             << d << ", f | " << flags_type << "::own_dom, p));"
              << "}";
 
-          os << "::std::auto_ptr< " << type << " >" << endl
+          os << auto_ptr << "< " << type << " >" << endl
              << name << " (" << xerces_ns << "::InputSource& i," << endl
              << error_handler << "& h," << endl
              << flags_type << " f," << endl
@@ -256,15 +250,13 @@ namespace CXX
              << "if (!d.get ())" << endl
              << "throw ::xsd::cxx::tree::parsing< " << char_type << " > ();"
              << endl
-             << "::std::auto_ptr< " << type << " > r (" << endl
+             << "return " << auto_ptr << "< " << type << " > (" << endl
              << fq_name (e, "parser") << " (" << endl
-             << "d, f | " << flags_type << "::own_dom, p));"
-             << endl
-             << "return r;"
+             << d << ", f | " << flags_type << "::own_dom, p));"
              << "}";
 
 
-          os << "::std::auto_ptr< " << type << " >" << endl
+          os << auto_ptr << "< " << type << " >" << endl
              << name << " (" << xerces_ns << "::InputSource& i," << endl
              << xerces_ns << "::DOMErrorHandler& h," << endl
              << flags_type << " f," << endl
@@ -283,11 +275,9 @@ namespace CXX
              << "if (!d.get ())" << endl
              << "throw ::xsd::cxx::tree::parsing< " << char_type << " > ();"
              << endl
-             << "::std::auto_ptr< " << type << " > r (" << endl
+             << "return " << auto_ptr << "< " << type << " > (" << endl
              << fq_name (e, "parser") << " (" << endl
-             << "d, f | " << flags_type << "::own_dom, p));"
-             << endl
-             << "return r;"
+             << d << ", f | " << flags_type << "::own_dom, p));"
              << "}";
 
 
@@ -308,32 +298,30 @@ namespace CXX
 
           // const DOMDocument&
           //
-          os << "::std::auto_ptr< " << type << " >" << endl
-             << name << " (const " << xerces_ns << "::DOMDocument& d," << endl
+          os << auto_ptr << "< " << type << " >" << endl
+             << name << " (const " << xerces_ns << "::DOMDocument& doc," << endl
              << flags_type << " f," << endl
              << "const " << properties_type << "& p)"
              << "{"
              << "if (f & " << flags_type << "::keep_dom)"
              << "{"
              << dom_auto_ptr << "< " << xerces_ns <<
-            "::DOMDocument > c (" << endl
+            "::DOMDocument > d (" << endl
              << "static_cast< " << xerces_ns <<
-            "::DOMDocument* > (d.cloneNode (true)));"
+            "::DOMDocument* > (doc.cloneNode (true)));"
              << endl
-             << "::std::auto_ptr< " << type << " > r (" << endl
+             << "return " << auto_ptr << "< " << type << " > (" << endl
              << fq_name (e, "parser") << " (" << endl
-             << "c, f | " << flags_type << "::own_dom, p));"
-             << endl
-             << "return r;"
+             << d << ", f | " << flags_type << "::own_dom, p));"
              << "}"
-             << "const " << xerces_ns << "::DOMElement& e (*d.getDocumentElement ());"
+             << "const " << xerces_ns << "::DOMElement& e (*doc.getDocumentElement ());"
              << "const " << qname_type << " n (" << endl
              << "::xsd::cxx::xml::dom::name< " << char_type << " > (e));"
              << endl;
 
           if (poly)
           {
-            os << "::std::auto_ptr< ::xsd::cxx::tree::type > tmp (" << endl
+            os << auto_ptr << "< ::xsd::cxx::tree::type > tmp (" << endl
                << "::xsd::cxx::tree::type_factory_map_instance< " <<
               poly_plate << ", " << char_type << " > ().create (" << endl
                << strlit (e.name ()) << "," << endl
@@ -343,7 +331,7 @@ namespace CXX
                << endl
                << "if (tmp.get () != 0)"
                << "{"
-               << "::std::auto_ptr< " << type << " > r (" << endl
+               << auto_ptr << "< " << type << " > r (" << endl
                << "dynamic_cast< " << type << "* > (tmp.get ()));"
                << endl
                << "if (r.get ())" << endl
@@ -361,7 +349,7 @@ namespace CXX
 
             if (fund)
             {
-              os << "::std::auto_ptr< " << type << " > r (" << endl
+              os << auto_ptr << "< " << type << " > r (" << endl
                  << "new " << type << " (" << endl
                  << "::xsd::cxx::tree::traits< " << type << ", " <<
                 char_type;
@@ -376,7 +364,7 @@ namespace CXX
             }
             else
             {
-              os << "::std::auto_ptr< " << type << " > r (" << endl
+              os << auto_ptr << "< " << type << " > r (" << endl
                  << "::xsd::cxx::tree::traits< " << type << ", " <<
                 char_type << " >::create (" << endl
                  << "e, f, 0));";
@@ -394,11 +382,11 @@ namespace CXX
              << "}";
 
 
-          // dom::auto_ptr
+          // dom::auto_ptr/unique_ptr
           //
-          os << "::std::auto_ptr< " << type << " >" << endl
+          os << auto_ptr << "< " << type << " >" << endl
              << name << " (" << dom_auto_ptr << "< " << xerces_ns <<
-            "::DOMDocument >& d," << endl
+            "::DOMDocument > d," << endl
              << flags_type << " f," << endl
              << "const " << properties_type << "&)"
              << "{"
@@ -425,7 +413,7 @@ namespace CXX
 
           if (poly)
           {
-            os << "::std::auto_ptr< ::xsd::cxx::tree::type > tmp (" << endl
+            os << auto_ptr << "< ::xsd::cxx::tree::type > tmp (" << endl
                << "::xsd::cxx::tree::type_factory_map_instance< " <<
               poly_plate << ", " << char_type << " > ().create (" << endl
                << strlit (e.name ()) << "," << endl
@@ -444,7 +432,7 @@ namespace CXX
 
             if (fund)
             {
-              os << "::std::auto_ptr< " << type << " > r (" << endl
+              os << auto_ptr << "< " << type << " > r (" << endl
                  << "new " << type << " (" << endl
                  << "::xsd::cxx::tree::traits< " << type << ", " <<
                 char_type;
@@ -459,7 +447,7 @@ namespace CXX
             }
             else
             {
-              os << "::std::auto_ptr< " << type << " > r (" << endl
+              os << auto_ptr << "< " << type << " > r (" << endl
                  << "::xsd::cxx::tree::traits< " << type << ", " <<
                 char_type << " >::create (" << endl
                  << "e, f, 0));";
@@ -469,7 +457,7 @@ namespace CXX
           if (poly)
           {
             os << endl
-               << "::std::auto_ptr< " << type << " > r (" << endl
+               << auto_ptr << "< " << type << " > r (" << endl
                << "dynamic_cast< " << type << "* > (tmp.get ()));"
                << endl
                << "if (r.get ())" << endl
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 << "}";
diff --git a/xsd/cxx/tree/tree-header.cxx b/xsd/cxx/tree/tree-header.cxx
index 4024bc3..56bf932 100644
--- a/xsd/cxx/tree/tree-header.cxx
+++ b/xsd/cxx/tree/tree-header.cxx
@@ -1250,7 +1250,7 @@ namespace CXX
               }
 
               os << "void" << endl
-                 << mname << " (::std::auto_ptr< " << type << " > p);"
+                 << mname << " (" << auto_ptr << "< " << type << " > p);"
                  << endl;
             }
           }
@@ -1339,7 +1339,7 @@ namespace CXX
                 }
 
                 os << "void" << endl
-                   << mname << " (::std::auto_ptr< " << type << " > p);"
+                   << mname << " (" << auto_ptr << "< " << type << " > p);"
                    << endl;
 
               }
@@ -1363,7 +1363,7 @@ namespace CXX
                      << " */" << endl;
                 }
 
-                os << "::std::auto_ptr< " << type << " >" << endl
+                os << auto_ptr << "< " << type << " >" << endl
                    << edname (m) << " ();"
                    << endl;
               }
@@ -2506,7 +2506,7 @@ namespace CXX
               inherits (c, inherits_member_);
               os << "&";
               {
-                FromBaseCtorArg args (*this, FromBaseCtorArg::arg_type, false);
+                FromBaseCtorArg args (*this, CtorArgType::type, false);
                 Traversal::Names args_names (args);
                 names (c, args_names);
               }
@@ -2525,7 +2525,7 @@ namespace CXX
                     "base and" << endl
                      << " * initializers for required elements and "
                      << "attributes" << endl
-                     << " * (auto_ptr version)." << endl
+                     << " * (" << auto_ptr << " version)." << endl
                      << " *" << endl
                      << " * This constructor will try to use the passed " <<
                     "values directly" << endl
@@ -2538,7 +2538,7 @@ namespace CXX
                 os << "&";
                 {
                   FromBaseCtorArg args (
-                    *this, FromBaseCtorArg::arg_complex_auto_ptr, false);
+                    *this, CtorArgType::complex_auto_ptr, false);
                   Traversal::Names args_names (args);
                   names (c, args_names);
                 }
@@ -2559,7 +2559,7 @@ namespace CXX
                     "base and" << endl
                      << " * initializers for required elements and "
                      << "attributes" << endl
-                     << " * (auto_ptr version)." << endl
+                     << " * (" << auto_ptr << " version)." << endl
                      << " *" << endl
                      << " * This constructor will try to use the passed " <<
                     "values directly" << endl
@@ -2572,7 +2572,7 @@ namespace CXX
                 os << "&";
                 {
                   FromBaseCtorArg args (
-                    *this, FromBaseCtorArg::arg_poly_auto_ptr, false);
+                    *this, CtorArgType::poly_auto_ptr, false);
                   Traversal::Names args_names (args);
                   names (c, args_names);
                 }
@@ -2598,7 +2598,7 @@ namespace CXX
             os << name << " (";
             {
               CtorArgsWithoutBase ctor_args (
-                *this, CtorArgsWithoutBase::arg_type, false, true);
+                *this, CtorArgType::type, false, true);
               ctor_args.dispatch (c);
             }
             os << ");"
@@ -2616,7 +2616,8 @@ namespace CXX
                 os << "/**" << endl
                    << " * @brief Create an instance from initializers " <<
                   "for required " << endl
-                   << " * elements and attributes (auto_ptr version)." << endl
+                   << " * elements and attributes (" << auto_ptr <<
+                  " version)." << endl
                    << " *" << endl
                    << " * This constructor will try to use the passed " <<
                   "values directly" << endl
@@ -2627,7 +2628,7 @@ namespace CXX
               os << name << " (";
               {
                 CtorArgsWithoutBase ctor_args (
-                  *this, CtorArgsWithoutBase::arg_complex_auto_ptr, false, true);
+                  *this, CtorArgType::complex_auto_ptr, false, true);
                 ctor_args.dispatch (c);
               }
               os << ");"
@@ -2645,7 +2646,8 @@ namespace CXX
                 os << "/**" << endl
                    << " * @brief Create an instance from initializers " <<
                   "for required " << endl
-                   << " * elements and attributes (auto_ptr version)." << endl
+                   << " * elements and attributes (" << auto_ptr <<
+                  " version)." << endl
                    << " *" << endl
                    << " * This constructor will try to use the passed " <<
                   "values directly" << endl
@@ -2656,7 +2658,7 @@ namespace CXX
               os << name << " (";
               {
                 CtorArgsWithoutBase ctor_args (
-                  *this, CtorArgsWithoutBase::arg_poly_auto_ptr, false, true);
+                  *this, CtorArgType::poly_auto_ptr, false, true);
                 ctor_args.dispatch (c);
               }
               os << ");"
@@ -2687,7 +2689,7 @@ namespace CXX
 
               {
                 CtorArgsWithoutBase ctor_args (
-                  *this, CtorArgsWithoutBase::arg_type, false, false);
+                  *this, CtorArgType::type, false, false);
                 ctor_args.dispatch (c);
               }
 
@@ -2710,7 +2712,7 @@ namespace CXX
 
             {
               CtorArgsWithoutBase ctor_args (
-                *this, CtorArgsWithoutBase::arg_type, false, false);
+                *this, CtorArgType::type, false, false);
               ctor_args.dispatch (c);
             }
 
@@ -2732,7 +2734,7 @@ namespace CXX
 
             {
               CtorArgsWithoutBase ctor_args (
-                *this, CtorArgsWithoutBase::arg_type, false, false);
+                *this, CtorArgType::type, false, false);
               ctor_args.dispatch (c);
             }
 
@@ -2756,7 +2758,7 @@ namespace CXX
           os << name << " (";
 
           {
-            CtorArgs ctor_args (*this, CtorArgs::arg_type);
+            CtorArgs ctor_args (*this, CtorArgType::type);
             ctor_args.dispatch (c);
           }
 
@@ -2775,7 +2777,7 @@ namespace CXX
                 "base and" << endl
                  << " * initializers for required elements and " <<
                 "attributes" << endl
-                 << " * (auto_ptr version)." << endl
+                 << " * (" << auto_ptr << " version)." << endl
                  << " *" << endl
                  << " * This constructor will try to use the passed " <<
                 "values directly" << endl
@@ -2786,7 +2788,7 @@ namespace CXX
             os << name << " (";
 
             {
-              CtorArgs ctor_args (*this, CtorArgs::arg_complex_auto_ptr);
+              CtorArgs ctor_args (*this, CtorArgType::complex_auto_ptr);
               ctor_args.dispatch (c);
             }
 
@@ -2806,7 +2808,7 @@ namespace CXX
                 "base and" << endl
                  << " * initializers for required elements and " <<
                 "attributes" << endl
-                 << " * (auto_ptr version)." << endl
+                 << " * (" << auto_ptr << " version)." << endl
                  << " *" << endl
                  << " * This constructor will try to use the passed " <<
                 "values directly" << endl
@@ -2817,7 +2819,7 @@ namespace CXX
             os << name << " (";
 
             {
-              CtorArgs ctor_args (*this, CtorArgs::arg_poly_auto_ptr);
+              CtorArgs ctor_args (*this, CtorArgType::poly_auto_ptr);
               ctor_args.dispatch (c);
             }
 
@@ -3326,7 +3328,7 @@ namespace CXX
             }
 
             os << "void" << endl
-               << mname << " (::std::auto_ptr< " << type << " > p);"
+               << mname << " (" << auto_ptr << "< " << type << " > p);"
                << endl;
           }
 
@@ -3348,7 +3350,7 @@ namespace CXX
                  << " */" << endl;
             }
 
-            os << "::std::auto_ptr< " << type << " >" << endl
+            os << auto_ptr << "< " << type << " >" << endl
                << edname (e) << " ();"
                << endl;
           }
@@ -3455,7 +3457,8 @@ namespace CXX
               os << "/**" << endl
                  << " * @brief Create an instance from an initializer " <<
                 "for" << endl
-                 << " * the element value (auto_ptr version)." << endl
+                 << " * the element value (" << auto_ptr <<
+                " version)." << endl
                  << " *" << endl
                  << " * @param p Element value to use." << endl
                  << " *" << endl
@@ -3465,7 +3468,7 @@ namespace CXX
                  << " */" << endl;
             }
 
-            os << name << " (::std::auto_ptr< " << type << " > p);"
+            os << name << " (" << auto_ptr << "< " << type << " > p);"
                << endl;
           }
 
@@ -3802,10 +3805,14 @@ namespace CXX
       {
         bool inline_ (ctx.options.generate_inline ());
 
-        ctx.os << "#include     // std::auto_ptr" << endl
+        ctx.os << "#include     // " << ctx.auto_ptr << endl
                << "#include     // std::numeric_limits" << endl
-               << "#include  // std::binary_search" << endl
-               << endl;
+               << "#include  // std::binary_search" << endl;
+
+        if (ctx.std >= cxx_version::cxx11)
+          ctx.os << "#include    // std::move" << endl;
+
+        ctx.os << endl;
 
         if (ctx.char_type == L"char" && ctx.char_encoding != L"custom")
         {
diff --git a/xsd/cxx/tree/tree-inline.cxx b/xsd/cxx/tree/tree-inline.cxx
index 0641a4d..0c64650 100644
--- a/xsd/cxx/tree/tree-inline.cxx
+++ b/xsd/cxx/tree/tree-inline.cxx
@@ -537,9 +537,10 @@ namespace CXX
             if (!fund)
               os << inl
                  << "void " << scope_ << "::" << endl
-                 << mname << " (::std::auto_ptr< " << type << " > x)"
+                 << mname << " (" << auto_ptr << "< " << type << " > x)"
                  << "{"
-                 << "this->" << member << ".set (x);"
+                 << "this->" << member << ".set (" <<
+                (std >= cxx_version::cxx11 ? "std::move (x)" : "x") << ");"
                  << "}";
           }
           else
@@ -589,9 +590,10 @@ namespace CXX
               if (!fund)
                 os << inl
                    << "void " << scope_ << "::" << endl
-                   << mname << " (::std::auto_ptr< " << type << " > x)"
+                   << mname << " (" << auto_ptr << "< " << type << " > x)"
                    << "{"
-                   << "this->" << member << ".set (x);"
+                   << "this->" << member << ".set (" <<
+                  (std >= cxx_version::cxx11 ? "std::move (x)" : "x") << ");"
                    << "}";
 
               // auto_ptr
@@ -599,7 +601,7 @@ namespace CXX
               //
               if (detach && !fund)
                 os << inl
-                   << "::std::auto_ptr< " << q_type << " > " <<
+                   << auto_ptr << "< " << q_type << " > " <<
                   scope_ << "::" << endl
                    << edname (m) << " ()"
                    << "{"
@@ -976,7 +978,7 @@ namespace CXX
              << "void " << name << "::" << endl
              << mname << " (const " << type << "& x)"
              << "{"
-             << "return this->" << member << ".set (x);"
+             << "this->" << member << ".set (x);"
              << "}";
 
           // void
@@ -986,9 +988,10 @@ namespace CXX
           {
             os << inl
                << "void " << name << "::" << endl
-               << mname << " (::std::auto_ptr< " << type << " > p)"
+               << mname << " (" << auto_ptr  << "< " << type << " > x)"
                << "{"
-               << "return this->" << member << ".set (p);"
+               << "this->" << member << ".set (" <<
+              (std >= cxx_version::cxx11 ? "std::move (x)" : "x") << ");"
                << "}";
           }
 
@@ -997,7 +1000,7 @@ namespace CXX
           //
           if (detach && !fund)
             os << inl
-               << "::std::auto_ptr< " << name << "::" << type << " > " <<
+               << auto_ptr << "< " << name << "::" << type << " > " <<
               name << "::" << endl
                << edname (e) << " ()"
                << "{"
diff --git a/xsd/cxx/tree/tree-source.cxx b/xsd/cxx/tree/tree-source.cxx
index 8f41a37..423f3bf 100644
--- a/xsd/cxx/tree/tree-source.cxx
+++ b/xsd/cxx/tree/tree-source.cxx
@@ -721,7 +721,7 @@ namespace CXX
           if (poly)
           {
             os << "{"
-               << "::std::auto_ptr< ::xsd::cxx::tree::type > tmp (" << endl
+               << auto_ptr << "< ::xsd::cxx::tree::type > tmp (" << endl
                << "::xsd::cxx::tree::type_factory_map_instance< " <<
               poly_plate << ", " << char_type << " > ().create (" << endl
                << strlit (e.name ()) << "," << endl
@@ -753,7 +753,7 @@ namespace CXX
 
             if (!fund)
             {
-              os << "::std::auto_ptr< " << type << " > r (" << endl
+              os << auto_ptr << "< " << type << " > r (" << endl
                  << tr << "::create (i, f, this));"
                  << endl;
             }
@@ -793,7 +793,7 @@ namespace CXX
             {
               // Cast to static type.
               //
-              os << "::std::auto_ptr< " << type << " > r (" << endl
+              os << auto_ptr << "< " << type << " > r (" << endl
                  << "dynamic_cast< " << type << "* > (tmp.get ()));"
                  << endl
                  << "if (r.get ())" << endl
@@ -804,23 +804,25 @@ namespace CXX
                  << endl;
             }
 
+            char const* r (std >= cxx_version::cxx11 ? "::std::move (r)" : "r");
+
             if (max (e) != 1)
             {
               // sequence
               //
-              os << "this->" << member << ".push_back (r);";
+              os << "this->" << member << ".push_back (" << r << ");";
             }
             else if (min (e) == 0)
             {
               // optional
               //
-              os << "this->" << member << ".set (r);";
+              os << "this->" << member << ".set (" << r << ");";
             }
             else
             {
               // one
               //
-              os << "this->" << member << ".set (r);";
+              os << "this->" << member << ".set (" << r << ");";
             }
           }
           else
@@ -1096,26 +1098,8 @@ namespace CXX
                << "{";
           }
 
-          bool fund (false);
-          {
-            IsFundamentalType traverser (fund);
-            traverser.dispatch (a.type ());
-          }
-
-          if (fund)
-          {
-            os << "this->" << member << ".set (" << tr <<
-              "::create (i, f, this));";
-          }
-          else
-          {
-            String type (etype (a));
-
-            os << "::std::auto_ptr< " << type << " > r (" << endl
-               << tr << "::create (i, f, this));"
-               << endl
-               << "this->" << member << ".set (r);";
-          }
+          os << "this->" << member << ".set (" << tr <<
+            "::create (i, f, this));";
 
           os << "continue;"
              << "}";
@@ -1259,33 +1243,31 @@ namespace CXX
                        Traversal::Type,
                        Context
       {
-        // If base_arg is empty then no base argument is
-        // generated.
+        // If base_arg is empty then no base argument is generated.
         //
-        CtorBase (Context& c, String const& base_arg)
-            : Context (c), base_arg_ (base_arg)
+        CtorBase (Context& c, CtorArgType at, String const& base_arg)
+            : Context (c), args_ (c, at, base_arg)
         {
         }
 
         virtual void
         traverse (SemanticGraph::Type&)
         {
-          if (base_arg_)
-            os << base_arg_;
+          if (args_.base_arg_)
+            os << args_.base_arg_;
         }
 
         virtual void
         traverse (SemanticGraph::Enumeration&)
         {
-          if (base_arg_)
-            os << base_arg_;
+          if (args_.base_arg_)
+            os << args_.base_arg_;
         }
 
         void
         traverse (SemanticGraph::Complex& c)
         {
-          Args args (*this, base_arg_);
-          args.traverse (c);
+          args_.traverse (c);
         }
 
       private:
@@ -1300,8 +1282,9 @@ namespace CXX
                      Traversal::Attribute,
                      Context
         {
-          Args (Context& c, String const& base_arg)
-              : Context (c), base_arg_ (base_arg), first_ (true)
+          Args (Context& c, CtorArgType at, String const& base_arg)
+              : Context (c),
+                arg_type_ (at), base_arg_ (base_arg), first_ (true)
           {
             *this >> inherits_ >> *this;
             *this >> names_ >> *this;
@@ -1342,7 +1325,32 @@ namespace CXX
             {
               // one
               //
-              os << comma () << ename (e);
+              bool move (false);
+
+              if (std >= cxx_version::cxx11)
+              {
+                switch (arg_type_)
+                {
+                case CtorArgType::complex_auto_ptr:
+                  {
+                    bool simple (true);
+                    IsSimpleType t (simple);
+                    t.dispatch (e.type ());
+                    move = !simple;
+                    break;
+                  }
+                case CtorArgType::poly_auto_ptr:
+                  {
+                    move = polymorphic && polymorphic_p (e.type ());
+                    break;
+                  }
+                case CtorArgType::type:
+                  break;
+                }
+              }
+
+              os << comma () << (move ? "std::move (" : "") << ename (e) <<
+                (move ? ")" : "");
             }
           }
 
@@ -1371,15 +1379,18 @@ namespace CXX
             return tmp ? "" : ",\n";
           }
 
-        private:
+        public:
+          CtorArgType arg_type_;
           String base_arg_;
+
+        private:
           bool first_;
 
           Traversal::Inherits inherits_;
           Traversal::Names names_;
         };
 
-        String base_arg_;
+        Args args_;
       };
 
 
@@ -1387,8 +1398,8 @@ namespace CXX
                          Traversal::Attribute,
                          Context
       {
-        CtorMember (Context& c)
-            : Context (c)
+        CtorMember (Context& c, CtorArgType at)
+            : Context (c), arg_type_ (at)
         {
         }
 
@@ -1418,8 +1429,33 @@ namespace CXX
           {
             // one
             //
+            bool move (false);
+
+            if (std >= cxx_version::cxx11)
+            {
+              switch (arg_type_)
+              {
+              case CtorArgType::complex_auto_ptr:
+                {
+                  bool simple (true);
+                  IsSimpleType t (simple);
+                  t.dispatch (e.type ());
+                  move = !simple;
+                  break;
+                }
+              case CtorArgType::poly_auto_ptr:
+                {
+                  move = polymorphic && polymorphic_p (e.type ());
+                  break;
+                }
+              case CtorArgType::type:
+                break;
+              }
+            }
+
             os << "," << endl
-               << "  " << member << " (" << ename (e) << ", this)";
+               << "  " << member << " (" << (move ? "std::move (" : "") <<
+              ename (e) << (move ? ")" : "") << ", this)";
           }
         }
 
@@ -1458,6 +1494,9 @@ namespace CXX
             }
           }
         }
+
+      private:
+        CtorArgType arg_type_;
       };
 
       struct CtorAny: Traversal::Any,
@@ -2134,7 +2173,7 @@ namespace CXX
               default_ctor_any_init_ (c),
               default_ctor_member_init_ (c),
               ctor_any_ (c),
-              ctor_member_ (c),
+              ctor_member_ (c, CtorArgType::type),
               element_ctor_any_ (c),
               element_ctor_member_ (c),
               assign_any_ (c),
@@ -2184,6 +2223,8 @@ namespace CXX
         virtual void
         traverse (Type& c)
         {
+          bool gen_wildcard (options.generate_wildcard ());
+
           String name (ename (c));
 
           // If renamed name is empty then we do not need to generate
@@ -2348,7 +2389,7 @@ namespace CXX
               inherits (c, inherits_member_);
               os << "& " << base_arg;
               {
-                FromBaseCtorArg args (*this, FromBaseCtorArg::arg_type, true);
+                FromBaseCtorArg args (*this, CtorArgType::type, true);
                 Traversal::Names args_names (args);
                 names (c, args_names);
               }
@@ -2375,13 +2416,14 @@ namespace CXX
               //
               if (has_complex_non_op_args)
               {
+                CtorArgType const at (CtorArgType::complex_auto_ptr);
+
                 os << name << "::" << endl
                    << name << " (const ";
                 inherits (c, inherits_member_);
                 os << "& " << base_arg;
                 {
-                  FromBaseCtorArg args (
-                    *this, FromBaseCtorArg::arg_complex_auto_ptr, true);
+                  FromBaseCtorArg args (*this, at, true);
                   Traversal::Names args_names (args);
                   names (c, args_names);
                 }
@@ -2396,7 +2438,15 @@ namespace CXX
                     " > ())";
                 }
 
-                names (c, ctor_names_);
+                {
+                  CtorMember t (*this, at);
+                  Traversal::Names n (t);
+
+                  if (gen_wildcard)
+                    n >> ctor_any_;
+
+                  names (c, n);
+                }
 
                 os << "{";
                 if (facets)
@@ -2410,13 +2460,14 @@ namespace CXX
               if (polymorphic &&
                   has_poly_non_op_args && !complex_poly_args_clash)
               {
+                CtorArgType const at (CtorArgType::poly_auto_ptr);
+
                 os << name << "::" << endl
                    << name << " (const ";
                 inherits (c, inherits_member_);
                 os << "& " << base_arg;
                 {
-                  FromBaseCtorArg args (
-                    *this, FromBaseCtorArg::arg_poly_auto_ptr, true);
+                  FromBaseCtorArg args (*this, at, true);
                   Traversal::Names args_names (args);
                   names (c, args_names);
                 }
@@ -2431,7 +2482,15 @@ namespace CXX
                     " > ())";
                 }
 
-                names (c, ctor_names_);
+                {
+                  CtorMember t (*this, at);
+                  Traversal::Names n (t);
+
+                  if (gen_wildcard)
+                    n >> ctor_any_;
+
+                  names (c, n);
+                }
 
                 os << "{";
                 if (facets)
@@ -2445,17 +2504,18 @@ namespace CXX
           //
           if (generate_no_base_ctor)
           {
+            CtorArgType const at (CtorArgType::type);
+
             os << name << "::" << endl
                << name << " (";
             {
-              CtorArgsWithoutBase ctor_args (
-                *this, CtorArgsWithoutBase::arg_type, true, true);
+              CtorArgsWithoutBase ctor_args (*this, at, true, true);
               ctor_args.dispatch (c);
             }
             os << ")" << endl
                << ": " << base << " (";
             {
-              CtorBase base (*this, "");
+              CtorBase base (*this, at, "");
               Traversal::Inherits inherits_base (base);
 
               inherits (c, inherits_base);
@@ -2483,17 +2543,18 @@ namespace CXX
             //
             if (has_complex_non_op_args)
             {
+              CtorArgType const at (CtorArgType::complex_auto_ptr);
+
               os << name << "::" << endl
                  << name << " (";
               {
-                CtorArgsWithoutBase ctor_args (
-                  *this, CtorArgsWithoutBase::arg_complex_auto_ptr, true, true);
+                CtorArgsWithoutBase ctor_args (*this, at, true, true);
                 ctor_args.dispatch (c);
               }
               os << ")" << endl
                  << ": " << base << " (";
               {
-                CtorBase base (*this, "");
+                CtorBase base (*this, at, "");
                 Traversal::Inherits inherits_base (base);
 
                 inherits (c, inherits_base);
@@ -2508,7 +2569,15 @@ namespace CXX
                   " > ())";
               }
 
-              names (c, ctor_names_);
+              {
+                CtorMember t (*this, at);
+                Traversal::Names n (t);
+
+                if (gen_wildcard)
+                  n >> ctor_any_;
+
+                names (c, n);
+              }
 
               os << "{";
               if (facets)
@@ -2522,17 +2591,18 @@ namespace CXX
             if (polymorphic &&
                 has_poly_non_op_args && !complex_poly_args_clash)
             {
+              CtorArgType const at (CtorArgType::poly_auto_ptr);
+
               os << name << "::" << endl
                  << name << " (";
               {
-                CtorArgsWithoutBase ctor_args (
-                  *this, CtorArgsWithoutBase::arg_poly_auto_ptr, true, true);
+                CtorArgsWithoutBase ctor_args (*this, at, true, true);
                 ctor_args.dispatch (c);
               }
               os << ")" << endl
                  << ": " << base << " (";
               {
-                CtorBase base (*this, "");
+                CtorBase base (*this, at, "");
                 Traversal::Inherits inherits_base (base);
 
                 inherits (c, inherits_base);
@@ -2547,7 +2617,15 @@ namespace CXX
                   " > ())";
               }
 
-              names (c, ctor_names_);
+              {
+                CtorMember t (*this, at);
+                Traversal::Names n (t);
+
+                if (gen_wildcard)
+                  n >> ctor_any_;
+
+                names (c, n);
+              }
 
               os << "{";
               if (facets)
@@ -2564,6 +2642,7 @@ namespace CXX
             {
               // c-tor (enum-value, all-non-optional-members)
               //
+              CtorArgType const at (CtorArgType::type);
               String base_arg (L"_xsd_" + ename (*enum_base) + L"_base");
 
               os << name << "::" << endl
@@ -2571,8 +2650,7 @@ namespace CXX
                 evalue (*enum_base) << " " << base_arg;
 
               {
-                CtorArgsWithoutBase ctor_args (
-                  *this, CtorArgsWithoutBase::arg_type, true, false);
+                CtorArgsWithoutBase ctor_args (*this, at, true, false);
                 ctor_args.dispatch (c);
               }
 
@@ -2580,7 +2658,7 @@ namespace CXX
                  << ": " << base << " (";
 
               {
-                CtorBase base (*this, base_arg);
+                CtorBase base (*this, at, base_arg);
                 Traversal::Inherits inherits_base (base);
 
                 inherits (c, inherits_base);
@@ -2604,6 +2682,7 @@ namespace CXX
               os << "}";
             }
 
+            CtorArgType const at (CtorArgType::type);
             String base_arg (L"_xsd_" + ename (ultimate_base (c)) + L"_base");
 
             // c-tor (const char*, all-non-optional-members)
@@ -2612,8 +2691,7 @@ namespace CXX
                << name << " (const " << char_type << "* " << base_arg;
 
             {
-              CtorArgsWithoutBase ctor_args (
-                *this, CtorArgsWithoutBase::arg_type, true, false);
+              CtorArgsWithoutBase ctor_args (*this, at, true, false);
               ctor_args.dispatch (c);
             }
 
@@ -2621,7 +2699,7 @@ namespace CXX
                << ": " << base << " (";
 
             {
-              CtorBase base (*this, base_arg);
+              CtorBase base (*this, at, base_arg);
               Traversal::Inherits inherits_base (base);
 
               inherits (c, inherits_base);
@@ -2651,8 +2729,7 @@ namespace CXX
                << name << " (const " << string_type << "& " << base_arg;
 
             {
-              CtorArgsWithoutBase ctor_args (
-                *this, CtorArgsWithoutBase::arg_type, true, false);
+              CtorArgsWithoutBase ctor_args (*this, at, true, false);
               ctor_args.dispatch (c);
             }
 
@@ -2660,7 +2737,7 @@ namespace CXX
                << ": " << base << " (";
 
             {
-              CtorBase base (*this, base_arg);
+              CtorBase base (*this, at, base_arg);
               Traversal::Inherits inherits_base (base);
 
               inherits (c, inherits_base);
@@ -2686,57 +2763,60 @@ namespace CXX
 
           // c-tor (ultimate-base, all-non-optional-members)
           //
+          {
+            CtorArgType const at (CtorArgType::type);
 
-          os << name << "::" << endl
-             << name << " (";
+            os << name << "::" << endl
+               << name << " (";
 
-          String base_arg;
+            String base_arg;
 
-          {
-            CtorArgs ctor_args (*this, CtorArgs::arg_type, base_arg);
-            ctor_args.dispatch (c);
-          }
+            {
+              CtorArgs ctor_args (*this, at, base_arg);
+              ctor_args.dispatch (c);
+            }
 
-          os << ")" << endl
-             << ": " << base << " (";
+            os << ")" << endl
+               << ": " << base << " (";
 
-          {
-            CtorBase base (*this, base_arg);
-	    Traversal::Inherits inherits_base (base);
+            {
+              CtorBase base (*this, at, base_arg);
+              Traversal::Inherits inherits_base (base);
 
-            inherits (c, inherits_base);
-          }
+              inherits (c, inherits_base);
+            }
 
-          os << ")";
+            os << ")";
 
-          if (edom_document_member_p (c))
-          {
-            os << "," << endl
-               << "  " << edom_document_member (c) << " (" <<
-              "::xsd::cxx::xml::dom::create_document< " << char_type <<
-              " > ())";
-          }
+            if (edom_document_member_p (c))
+            {
+              os << "," << endl
+                 << "  " << edom_document_member (c) << " (" <<
+                "::xsd::cxx::xml::dom::create_document< " << char_type <<
+                " > ())";
+            }
 
-          names (c, ctor_names_);
+            names (c, ctor_names_);
 
-          os << "{";
-          if (facets)
-            os << "this->_facet_table (_xsd_" << name << "_facet_table);";
-          os << "}";
+            os << "{";
+            if (facets)
+              os << "this->_facet_table (_xsd_" << name << "_facet_table);";
+            os << "}";
+          }
 
           // If we have any complex arguments in the previous c-tor
           // then also generate the auto_ptr version.
           //
           if (has_complex_non_op_args)
           {
+            CtorArgType const at (CtorArgType::complex_auto_ptr);
+            String base_arg;
+
             os << name << "::" << endl
                << name << " (";
 
-            String base_arg;
-
             {
-              CtorArgs ctor_args (
-                *this, CtorArgs::arg_complex_auto_ptr, base_arg);
+              CtorArgs ctor_args (*this, at, base_arg);
               ctor_args.dispatch (c);
             }
 
@@ -2744,7 +2824,7 @@ namespace CXX
                << ": " << base << " (";
 
             {
-              CtorBase base (*this, base_arg);
+              CtorBase base (*this, at, base_arg);
               Traversal::Inherits inherits_base (base);
 
               inherits (c, inherits_base);
@@ -2760,7 +2840,15 @@ namespace CXX
                 " > ())";
             }
 
-            names (c, ctor_names_);
+            {
+              CtorMember t (*this, at);
+              Traversal::Names n (t);
+
+              if (gen_wildcard)
+                n >> ctor_any_;
+
+              names (c, n);
+            }
 
             os << "{";
             if (facets)
@@ -2774,14 +2862,14 @@ namespace CXX
           if (polymorphic &&
               has_poly_non_op_args && !complex_poly_args_clash)
           {
+            CtorArgType const at (CtorArgType::poly_auto_ptr);
+            String base_arg;
+
             os << name << "::" << endl
                << name << " (";
 
-            String base_arg;
-
             {
-              CtorArgs ctor_args (
-                *this, CtorArgs::arg_poly_auto_ptr, base_arg);
+              CtorArgs ctor_args (*this, at, base_arg);
               ctor_args.dispatch (c);
             }
 
@@ -2789,7 +2877,7 @@ namespace CXX
                << ": " << base << " (";
 
             {
-              CtorBase base (*this, base_arg);
+              CtorBase base (*this, at, base_arg);
               Traversal::Inherits inherits_base (base);
 
               inherits (c, inherits_base);
@@ -2805,7 +2893,15 @@ namespace CXX
                 " > ())";
             }
 
-            names (c, ctor_names_);
+            {
+              CtorMember t (*this, at);
+              Traversal::Names n (t);
+
+              if (gen_wildcard)
+                n >> ctor_any_;
+
+              names (c, n);
+            }
 
             os << "{";
             if (facets)
@@ -2838,7 +2934,7 @@ namespace CXX
 
             names >> copy_member;
 
-            if (options.generate_wildcard ())
+            if (gen_wildcard)
               names >> copy_any;
 
             Complex::names (c, names);
@@ -2857,8 +2953,6 @@ namespace CXX
           bool ha (has (c));
           bool haa (has (c));
 
-          bool gen_wildcard (options.generate_wildcard ());
-
           //
           //
           if (!options.suppress_parsing ())
@@ -3291,7 +3385,7 @@ namespace CXX
             if (!simple || (polymorphic && polymorphic_p (t)))
             {
               os << name << "::" << endl
-                 << name << " (::std::auto_ptr< " << type << " > p)" << endl
+                 << name << " (" << auto_ptr << "< " << type << " > p)" << endl
                  << ": " << member << " (p, 0)"
                  << "{"
                  << "}";
-- 
cgit v1.1