$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r70798 - in branches/release: . boost boost/bimap boost/fusion boost/fusion/container/list/detail boost/gil boost/graph boost/icl boost/integer boost/interprocess boost/intrusive boost/iostreams boost/msm boost/numeric/ublas boost/pool boost/program_options boost/property_tree boost/signals boost/spirit boost/spirit/home boost/spirit/home/karma boost/spirit/home/support boost/statechart boost/type_traits boost/typeof boost/utility boost/uuid boost/variant boost/variant/detail boost/wave libs libs/bimap libs/date_time libs/fusion libs/graph_parallel libs/icl libs/icl/doc libs/icl/doc/html libs/icl/doc/html/header/boost/icl libs/icl/test libs/icl/test/test_doc_code_ libs/integer libs/mpi/build libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/msm libs/numeric/ublas libs/numeric/ublas/doc libs/parameter/doc/html libs/pool libs/program_options libs/property_tree libs/serialization libs/serialization/doc libs/serialization/vc7ide libs/signals libs/signals2 libs/spirit libs/spirit/classic/example libs/spirit/doc libs/spirit/example libs/spirit/phoenix libs/spirit/test libs/spirit/test/qi libs/statechart libs/static_assert libs/timer libs/type_traits libs/typeof/doc libs/units/test libs/utility libs/utility/swap/test libs/uuid libs/variant/test libs/wave status tools tools/bcp tools/quickbook tools/regression tools/regression/src tools/wave
From: steven_at_[hidden]
Date: 2011-03-31 17:08:37
Author: steven_watanabe
Date: 2011-03-31 17:08:35 EDT (Thu, 31 Mar 2011)
New Revision: 70798
URL: http://svn.boost.org/trac/boost/changeset/70798
Log:
Merge variant from the trunk.
Properties modified: 
   branches/release/   (props changed)
   branches/release/INSTALL   (props changed)
   branches/release/Jamroot   (props changed)
   branches/release/LICENSE_1_0.txt   (props changed)
   branches/release/boost/   (props changed)
   branches/release/boost-build.jam   (props changed)
   branches/release/boost.css   (props changed)
   branches/release/boost.png   (props changed)
   branches/release/boost/bimap/   (props changed)
   branches/release/boost/concept_check.hpp   (props changed)
   branches/release/boost/config.hpp   (props changed)
   branches/release/boost/fusion/   (props changed)
   branches/release/boost/fusion/container/list/detail/build_cons.hpp   (props changed)
   branches/release/boost/gil/   (props changed)
   branches/release/boost/graph/   (props changed)
   branches/release/boost/icl/   (props changed)
   branches/release/boost/integer/   (props changed)
   branches/release/boost/interprocess/   (props changed)
   branches/release/boost/intrusive/   (props changed)
   branches/release/boost/iostreams/   (props changed)
   branches/release/boost/math_fwd.hpp   (props changed)
   branches/release/boost/msm/   (props changed)
   branches/release/boost/numeric/ublas/   (props changed)
   branches/release/boost/numeric/ublas/functional.hpp   (props changed)
   branches/release/boost/pool/   (props changed)
   branches/release/boost/program_options/   (props changed)
   branches/release/boost/property_tree/   (props changed)
   branches/release/boost/signals/   (props changed)
   branches/release/boost/signals2.hpp   (props changed)
   branches/release/boost/spirit/   (props changed)
   branches/release/boost/spirit/home/   (props changed)
   branches/release/boost/spirit/home/karma/   (props changed)
   branches/release/boost/spirit/home/support/attributes.hpp   (props changed)
   branches/release/boost/statechart/   (props changed)
   branches/release/boost/token_functions.hpp   (props changed)
   branches/release/boost/type_traits/   (props changed)
   branches/release/boost/typeof/message.hpp   (props changed)
   branches/release/boost/typeof/register_functions.hpp   (props changed)
   branches/release/boost/typeof/register_functions_iterate.hpp   (props changed)
   branches/release/boost/typeof/typeof.hpp   (props changed)
   branches/release/boost/typeof/unsupported.hpp   (props changed)
   branches/release/boost/utility/   (props changed)
   branches/release/boost/utility/value_init.hpp   (props changed)
   branches/release/boost/uuid/   (props changed)
   branches/release/boost/variant/   (props changed)
   branches/release/boost/version.hpp   (props changed)
   branches/release/boost/wave/   (props changed)
   branches/release/bootstrap.bat   (props changed)
   branches/release/bootstrap.sh   (props changed)
   branches/release/index.htm   (props changed)
   branches/release/index.html   (props changed)
   branches/release/libs/   (props changed)
   branches/release/libs/bimap/   (props changed)
   branches/release/libs/date_time/   (props changed)
   branches/release/libs/fusion/   (props changed)
   branches/release/libs/graph_parallel/   (props changed)
   branches/release/libs/icl/   (props changed)
   branches/release/libs/icl/doc/   (props changed)
   branches/release/libs/icl/doc/html/   (props changed)
   branches/release/libs/icl/doc/html/header/boost/icl/   (props changed)
   branches/release/libs/icl/test/   (props changed)
   branches/release/libs/icl/test/test_doc_code_/   (props changed)
   branches/release/libs/integer/   (props changed)
   branches/release/libs/libraries.htm   (props changed)
   branches/release/libs/maintainers.txt   (props changed)
   branches/release/libs/mpi/build/   (props changed)
   branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html   (props changed)
   branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html   (props changed)
   branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html   (props changed)
   branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html   (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-concepts.html   (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html   (props changed)
   branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html   (props changed)
   branches/release/libs/mpl/doc/refmanual/inserter-class.html   (props changed)
   branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html   (props changed)
   branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html   (props changed)
   branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst   (props changed)
   branches/release/libs/msm/   (props changed)
   branches/release/libs/numeric/ublas/   (props changed)
   branches/release/libs/numeric/ublas/doc/   (props changed)
   branches/release/libs/parameter/doc/html/index.html   (props changed)
   branches/release/libs/pool/   (props changed)
   branches/release/libs/program_options/   (props changed)
   branches/release/libs/property_tree/   (props changed)
   branches/release/libs/serialization/   (props changed)
   branches/release/libs/serialization/doc/   (props changed)
   branches/release/libs/serialization/vc7ide/   (props changed)
   branches/release/libs/signals/   (props changed)
   branches/release/libs/signals2/   (props changed)
   branches/release/libs/spirit/   (props changed)
   branches/release/libs/spirit/classic/example/   (props changed)
   branches/release/libs/spirit/doc/   (props changed)
   branches/release/libs/spirit/example/   (props changed)
   branches/release/libs/spirit/phoenix/   (props changed)
   branches/release/libs/spirit/test/   (props changed)
   branches/release/libs/spirit/test/qi/optional.cpp   (props changed)
   branches/release/libs/statechart/   (props changed)
   branches/release/libs/static_assert/   (props changed)
   branches/release/libs/timer/   (props changed)
   branches/release/libs/type_traits/   (props changed)
   branches/release/libs/typeof/doc/typeof.qbk   (props changed)
   branches/release/libs/units/test/   (props changed)
   branches/release/libs/utility/   (props changed)
   branches/release/libs/utility/swap.html   (props changed)
   branches/release/libs/utility/swap/test/std_bitset.cpp   (props changed)
   branches/release/libs/utility/value_init.htm   (props changed)
   branches/release/libs/utility/value_init_test.cpp   (props changed)
   branches/release/libs/uuid/   (props changed)
   branches/release/libs/wave/   (props changed)
   branches/release/rst.css   (props changed)
   branches/release/status/   (props changed)
   branches/release/status/Jamfile.v2   (props changed)
   branches/release/status/explicit-failures-markup.xml   (props changed)
   branches/release/tools/   (props changed)
   branches/release/tools/bcp/   (props changed)
   branches/release/tools/quickbook/   (props changed)
   branches/release/tools/regression/   (props changed)
   branches/release/tools/regression/src/library_status.cpp   (props changed)
   branches/release/tools/wave/   (props changed)
Text files modified: 
   branches/release/boost/variant/detail/apply_visitor_delayed.hpp |     4                                         
   branches/release/boost/variant/detail/visitation_impl.hpp       |     4                                         
   branches/release/boost/variant/recursive_variant.hpp            |    63 +++++++-----                            
   branches/release/boost/variant/variant.hpp                      |    52 ++++++++--                              
   branches/release/boost/variant/variant_fwd.hpp                  |     2                                         
   branches/release/libs/variant/test/recursive_variant_test.cpp   |   192 +++++++++++++++++++++++++++++++++++++-- 
   6 files changed, 262 insertions(+), 55 deletions(-)
Modified: branches/release/boost/variant/detail/apply_visitor_delayed.hpp
==============================================================================
--- branches/release/boost/variant/detail/apply_visitor_delayed.hpp	(original)
+++ branches/release/boost/variant/detail/apply_visitor_delayed.hpp	2011-03-31 17:08:35 EDT (Thu, 31 Mar 2011)
@@ -58,7 +58,7 @@
 
     template <typename Visitable>
         BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
-    operator()(Visitable& visitable)
+    operator()(Visitable& visitable) const
     {
         return apply_visitor(visitor_, visitable);
     }
@@ -67,7 +67,7 @@
 
     template <typename Visitable1, typename Visitable2>
         BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
-    operator()(Visitable1& visitable1, Visitable2& visitable2)
+    operator()(Visitable1& visitable1, Visitable2& visitable2) const
     {
         return apply_visitor(visitor_, visitable1, visitable2);
     }
Modified: branches/release/boost/variant/detail/visitation_impl.hpp
==============================================================================
--- branches/release/boost/variant/detail/visitation_impl.hpp	(original)
+++ branches/release/boost/variant/detail/visitation_impl.hpp	2011-03-31 17:08:35 EDT (Thu, 31 Mar 2011)
@@ -167,7 +167,7 @@
         , has_nothrow_copy<T>
         >::type never_uses_backup;
 
-    return visitation_impl_invoke_impl(
+    return (visitation_impl_invoke_impl)(
           internal_which, visitor, storage, t
         , never_uses_backup()
         );
@@ -246,7 +246,7 @@
     // ...applying the appropriate case:
 #   define BOOST_VARIANT_AUX_APPLY_VISITOR_STEP_CASE(z, N, _) \
     case (Which::value + (N)): \
-        return visitation_impl_invoke( \
+        return (visitation_impl_invoke)( \
               internal_which, visitor, storage \
             , static_cast<BOOST_PP_CAT(T,N)*>(0) \
             , no_backup_flag, 1L \
Modified: branches/release/boost/variant/recursive_variant.hpp
==============================================================================
--- branches/release/boost/variant/recursive_variant.hpp	(original)
+++ branches/release/boost/variant/recursive_variant.hpp	2011-03-31 17:08:35 EDT (Thu, 31 Mar 2011)
@@ -21,15 +21,15 @@
 
 #include "boost/mpl/aux_/lambda_arity_param.hpp"
 
-#if !defined(BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT)
-#   include "boost/mpl/eval_if.hpp"
-#   include "boost/mpl/identity.hpp"
-#   include "boost/mpl/protect.hpp"
-#   include "boost/mpl/transform.hpp"
-#else
-#   include "boost/preprocessor/cat.hpp"
-#   include "boost/preprocessor/repeat.hpp"
-#endif
+#include "boost/mpl/equal.hpp"
+#include "boost/mpl/eval_if.hpp"
+#include "boost/mpl/identity.hpp"
+#include "boost/mpl/if.hpp"
+#include "boost/mpl/protect.hpp"
+#include "boost/mpl/transform.hpp"
+#include "boost/type_traits/is_same.hpp"
+#include "boost/preprocessor/cat.hpp"
+#include "boost/preprocessor/repeat.hpp"
 
 #include "boost/mpl/bool.hpp"
 #include "boost/mpl/is_sequence.hpp"
@@ -74,34 +74,48 @@
       BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(typename Arity)
     >
 struct substitute<
-      ::boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >
+      ::boost::variant<
+          ::boost::detail::variant::over_sequence< T0 >
+        , BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T)
+        >
     , RecursiveVariant
     , ::boost::recursive_variant_
       BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(Arity)
     >
 {
+private:
 
-#if !defined(BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT)
-
-private: // helpers, for metafunction result (below)
-
-    typedef typename mpl::eval_if<
-          ::boost::detail::variant::is_over_sequence<T0>
-        , mpl::identity< T0 >
-        , make_variant_list< BOOST_VARIANT_ENUM_PARAMS(T) >
-        >::type initial_types;
+    typedef T0 initial_types;
 
     typedef typename mpl::transform<
           initial_types
         , mpl::protect< quoted_enable_recursive<RecursiveVariant,mpl::true_> >
         >::type types;
 
-public: // metafunction result
-
-    typedef ::boost::variant< types > type;
+public:
 
-#else // defined(BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT)
+    typedef typename mpl::if_<
+          mpl::equal<initial_types, types, ::boost::is_same<mpl::_1, mpl::_2> >
+        , ::boost::variant<
+              ::boost::detail::variant::over_sequence< T0 >
+            , BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T)
+            >
+        , ::boost::variant< over_sequence<types> >
+        >::type type;
+};
 
+template <
+      BOOST_VARIANT_ENUM_PARAMS(typename T)
+    , typename RecursiveVariant
+      BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(typename Arity)
+    >
+struct substitute<
+      ::boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >
+    , RecursiveVariant
+    , ::boost::recursive_variant_
+      BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(Arity)
+    >
+{
 private: // helpers, for metafunction result (below)
 
     #define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_TYPEDEFS(z,N,_)  \
@@ -123,9 +137,6 @@
 public: // metafunction result
 
     typedef ::boost::variant< BOOST_VARIANT_ENUM_PARAMS(wknd_T) > type;
-
-#endif // BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT workaround
-
 };
 
 #else // defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
Modified: branches/release/boost/variant/variant.hpp
==============================================================================
--- branches/release/boost/variant/variant.hpp	(original)
+++ branches/release/boost/variant/variant.hpp	2011-03-31 17:08:35 EDT (Thu, 31 Mar 2011)
@@ -40,6 +40,7 @@
 #include "boost/detail/reference_content.hpp"
 #include "boost/aligned_storage.hpp"
 #include "boost/blank.hpp"
+#include "boost/math/common_factor_ct.hpp"
 #include "boost/static_assert.hpp"
 #include "boost/preprocessor/cat.hpp"
 #include "boost/preprocessor/repeat.hpp"
@@ -53,12 +54,14 @@
 #include "boost/variant/recursive_wrapper_fwd.hpp"
 #include "boost/variant/static_visitor.hpp"
 
-#include "boost/mpl/eval_if.hpp"
+#include "boost/mpl/assert.hpp"
 #include "boost/mpl/begin_end.hpp"
 #include "boost/mpl/bool.hpp"
-#include "boost/mpl/not.hpp"
+#include "boost/mpl/deref.hpp"
 #include "boost/mpl/empty.hpp"
+#include "boost/mpl/eval_if.hpp"
 #include "boost/mpl/find_if.hpp"
+#include "boost/mpl/fold.hpp"
 #include "boost/mpl/front.hpp"
 #include "boost/mpl/identity.hpp"
 #include "boost/mpl/if.hpp"
@@ -69,7 +72,7 @@
 #include "boost/mpl/logical.hpp"
 #include "boost/mpl/max_element.hpp"
 #include "boost/mpl/next.hpp"
-#include "boost/mpl/deref.hpp"
+#include "boost/mpl/not.hpp"
 #include "boost/mpl/pair.hpp"
 #include "boost/mpl/protect.hpp"
 #include "boost/mpl/push_front.hpp"
@@ -77,7 +80,6 @@
 #include "boost/mpl/size_t.hpp"
 #include "boost/mpl/sizeof.hpp"
 #include "boost/mpl/transform.hpp"
-#include "boost/mpl/assert.hpp"
 
 ///////////////////////////////////////////////////////////////////////////////
 // Implementation Macros:
@@ -130,6 +132,19 @@
 
 };
 
+struct add_alignment
+{
+    template <typename State, typename Item>
+    struct apply
+        : mpl::size_t<
+              ::boost::math::static_lcm<
+                  BOOST_MPL_AUX_VALUE_WKND(State)::value
+                , ::boost::alignment_of<Item>::value
+                >::value
+            >
+    {};
+};
+
 ///////////////////////////////////////////////////////////////////////////////
 // (detail) metafunction find_fallback_type
 //
@@ -234,8 +249,10 @@
 
 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0551))
 
-    typedef typename max_value<
-          types, alignment_of<mpl::_1>
+    typedef typename mpl::fold<
+          types
+        , mpl::size_t<1>
+        , add_alignment
         >::type max_alignment;
 
 #else // borland
@@ -550,7 +567,7 @@
 // NOTE: This needs to be a friend of variant, as it needs access to
 // indicate_which, indicate_backup_which, etc.
 //
-template <typename Variant, typename RhsT>
+template <typename Variant>
 class backup_assigner
     : public static_visitor<>
 {
@@ -558,19 +575,28 @@
 
     Variant& lhs_;
     int rhs_which_;
-    const RhsT& rhs_content_;
+    const void* rhs_content_;
+    void (*copy_rhs_content_)(void*, const void*);
 
 public: // structors
 
+    template<class RhsT>
     backup_assigner(Variant& lhs, int rhs_which, const RhsT& rhs_content)
         : lhs_(lhs)
         , rhs_which_(rhs_which)
-        , rhs_content_(rhs_content)
+        , rhs_content_(&rhs_content)
+        , copy_rhs_content_(&construct_impl<RhsT>)
     {
     }
 
 private: // helpers, for visitor interface (below)
 
+    template<class RhsT>
+    static void construct_impl(void* addr, const void* obj)
+    {
+        new(addr) RhsT(*static_cast<const RhsT*>(obj));
+    }
+
     template <typename LhsT>
     void backup_assign_impl(
           LhsT& lhs_content
@@ -588,7 +614,7 @@
         try
         {
             // ...and attempt to copy rhs content into lhs storage:
-            new(lhs_.storage_.address()) RhsT(rhs_content_);
+            copy_rhs_content_(lhs_.storage_.address(), rhs_content_);
         }
         catch (...)
         {
@@ -621,7 +647,7 @@
         try
         {
             // ...and attempt to copy rhs content into lhs storage:
-            new(lhs_.storage_.address()) RhsT(rhs_content_);
+            copy_rhs_content_(lhs_.storage_.address(), rhs_content_);
         }
         catch (...)
         {
@@ -1431,7 +1457,7 @@
 private: // helpers, for modifiers (below)
 
 #   if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
-    template <typename Variant, typename RhsT>
+    template <typename Variant>
     friend class detail::variant::backup_assigner;
 #   endif
 
@@ -1544,7 +1570,7 @@
             , mpl::false_// has_fallback_type
             )
         {
-            detail::variant::backup_assigner<wknd_self_t, RhsT>
+            detail::variant::backup_assigner<wknd_self_t>
                 visitor(lhs_, rhs_which_, rhs_content);
             lhs_.internal_apply_visitor(visitor);
         }
Modified: branches/release/boost/variant/variant_fwd.hpp
==============================================================================
--- branches/release/boost/variant/variant_fwd.hpp	(original)
+++ branches/release/boost/variant/variant_fwd.hpp	2011-03-31 17:08:35 EDT (Thu, 31 Mar 2011)
@@ -229,7 +229,7 @@
 // Tag type indicates where recursive variant substitution should occur.
 //
 #if !defined(BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT)
-    struct recursive_variant_;
+    struct recursive_variant_ {};
 #else
     typedef mpl::arg<1> recursive_variant_;
 #endif
Modified: branches/release/libs/variant/test/recursive_variant_test.cpp
==============================================================================
--- branches/release/libs/variant/test/recursive_variant_test.cpp	(original)
+++ branches/release/libs/variant/test/recursive_variant_test.cpp	2011-03-31 17:08:35 EDT (Thu, 31 Mar 2011)
@@ -12,10 +12,13 @@
 
 #include "boost/test/minimal.hpp"
 #include "boost/variant.hpp"
+#include "boost/mpl/vector.hpp"
+#include "boost/mpl/copy.hpp"
 
 #include <iostream>
 #include <sstream>
 #include <vector>
+#include <map>
 
 struct vector_printer
     : boost::static_visitor<std::string>
@@ -45,24 +48,191 @@
     }
 };
 
-int test_main(int , char* [])
+void test_recursive_variant()
 {
     typedef boost::make_recursive_variant<
           int
         , std::vector<boost::recursive_variant_>
-        >::type var_t;
+        >::type var1_t;
+
+    std::vector<var1_t> vec1;
+    vec1.push_back(3);
+    vec1.push_back(5);
+    vec1.push_back(vec1);
+    vec1.push_back(7);
+
+    var1_t var1(vec1);
+    std::string result1( boost::apply_visitor( vector_printer(), var1 ) );
+
+    std::cout << "result1: " << result1 << '\n';
+    BOOST_CHECK(result1 == "( 3 5 ( 3 5 ) 7 ) ");
+
+    typedef boost::make_recursive_variant<
+          boost::variant<int, double>
+        , std::vector<boost::recursive_variant_>
+        >::type var2_t;
+
+    std::vector<var2_t> vec2;
+    vec2.push_back(boost::variant<int, double>(3));
+    vec2.push_back(boost::variant<int, double>(3.5));
+    vec2.push_back(vec2);
+    vec2.push_back(boost::variant<int, double>(7));
+
+    var2_t var2(vec2);
+    std::string result2( boost::apply_visitor( vector_printer(), var2 ) );
+
+    std::cout << "result2: " << result2 << '\n';
+    BOOST_CHECK(result2 == "( 3 3.5 ( 3 3.5 ) 7 ) ");
+    
+    typedef boost::make_recursive_variant<
+          int
+        , std::vector<
+              boost::variant<
+                    double
+                  , std::vector<boost::recursive_variant_>
+                  >
+              >
+        >::type var3_t;
+
+    typedef boost::variant<double, std::vector<var3_t> > var4_t;
+
+    std::vector<var3_t> vec3;
+    vec3.push_back(3);
+    vec3.push_back(5);
+    std::vector<var4_t> vec4;
+    vec4.push_back(3.5);
+    vec4.push_back(vec3);
+    vec3.push_back(vec4);
+    vec3.push_back(7);
+
+    var4_t var4(vec3);
+    std::string result3( boost::apply_visitor( vector_printer(), var4 ) );
+
+    std::cout << "result2: " << result3 << '\n';
+    BOOST_CHECK(result3 == "( 3 5 ( 3.5 ( 3 5 ) ) 7 ) ");
 
-    std::vector<var_t> vec;
-    vec.push_back(3);
-    vec.push_back(5);
-    vec.push_back(vec);
-    vec.push_back(7);
+    typedef boost::make_recursive_variant<
+          double,
+          std::vector<var1_t>
+        >::type var5_t;
+
+    std::vector<var5_t> vec5;
+    vec5.push_back(3.5);
+    vec5.push_back(vec1);
+    vec5.push_back(17.25);
+
+    std::string result5( vector_printer()(vec5) );
+
+    std::cout << "result5: " << result5 << '\n';
+    BOOST_CHECK(result5 == "( 3.5 ( 3 5 ( 3 5 ) 7 ) 17.25 ) ");
+
+    typedef boost::make_recursive_variant<
+          int,
+          std::map<int, boost::recursive_variant_>
+        >::type var6_t;
+    var6_t var6;
+}
 
-    var_t var(vec);
-    std::string result( boost::apply_visitor( vector_printer(), var ) );
+void test_recursive_variant_over()
+{
+    typedef boost::make_recursive_variant_over<
+          boost::mpl::vector<
+              int
+            , std::vector<boost::recursive_variant_>
+          >
+        >::type var1_t;
+
+    std::vector<var1_t> vec1;
+    vec1.push_back(3);
+    vec1.push_back(5);
+    vec1.push_back(vec1);
+    vec1.push_back(7);
+
+    var1_t var1(vec1);
+    std::string result1( boost::apply_visitor( vector_printer(), var1 ) );
+
+    std::cout << "result1: " << result1 << '\n';
+    BOOST_CHECK(result1 == "( 3 5 ( 3 5 ) 7 ) ");
+
+    typedef boost::make_recursive_variant_over<
+          boost::mpl::vector<
+              boost::make_variant_over<boost::mpl::vector<int, double> >::type
+            , std::vector<boost::recursive_variant_>
+            >
+        >::type var2_t;
+
+    std::vector<var2_t> vec2;
+    vec2.push_back(boost::variant<int, double>(3));
+    vec2.push_back(boost::variant<int, double>(3.5));
+    vec2.push_back(vec2);
+    vec2.push_back(boost::variant<int, double>(7));
+
+    var2_t var2(vec2);
+    std::string result2( boost::apply_visitor( vector_printer(), var2 ) );
+
+    std::cout << "result2: " << result2 << '\n';
+    BOOST_CHECK(result2 == "( 3 3.5 ( 3 3.5 ) 7 ) ");
+    
+    typedef boost::make_recursive_variant_over<
+          boost::mpl::vector<
+              int
+            , std::vector<
+                  boost::make_variant_over<
+                      boost::mpl::vector<
+                          double
+                        , std::vector<boost::recursive_variant_>
+                        >
+                    >::type
+                >
+            >
+        >::type var3_t;
+
+    typedef boost::make_variant_over<
+          boost::mpl::copy<
+              boost::mpl::vector<
+                  double
+                , std::vector<var3_t>
+                >
+            >::type
+        >::type var4_t;
+
+    std::vector<var3_t> vec3;
+    vec3.push_back(3);
+    vec3.push_back(5);
+    std::vector<var4_t> vec4;
+    vec4.push_back(3.5);
+    vec4.push_back(vec3);
+    vec3.push_back(vec4);
+    vec3.push_back(7);
+
+    var4_t var3(vec3);
+    std::string result3( boost::apply_visitor( vector_printer(), var3 ) );
+
+    std::cout << "result2: " << result3 << '\n';
+    BOOST_CHECK(result3 == "( 3 5 ( 3.5 ( 3 5 ) ) 7 ) ");
+    
+    typedef boost::make_recursive_variant_over<
+          boost::mpl::vector<
+              double
+            , std::vector<var1_t>
+            >
+        >::type var5_t;
+
+    std::vector<var5_t> vec5;
+    vec5.push_back(3.5);
+    vec5.push_back(vec1);
+    vec5.push_back(17.25);
+
+    std::string result5( vector_printer()(vec5) );
+
+    std::cout << "result5: " << result5 << '\n';
+    BOOST_CHECK(result5 == "( 3.5 ( 3 5 ( 3 5 ) 7 ) 17.25 ) ");
+}
 
-    std::cout << "result: " << result << '\n';
-    BOOST_CHECK(result == "( 3 5 ( 3 5 ) 7 ) ");
+int test_main(int , char* [])
+{
+    test_recursive_variant();
+    test_recursive_variant_over();
 
     return boost::exit_success;
 }