$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r59579 - in trunk: boost/typeof libs/typeof/test
From: Alexander.Nasonov_at_[hidden]
Date: 2010-02-07 14:13:44
Author: nasonov
Date: 2010-02-07 14:13:43 EST (Sun, 07 Feb 2010)
New Revision: 59579
URL: http://svn.boost.org/trac/boost/changeset/59579
Log:
Apply variadic functions patch from Sergey Zubkovsky.
Text files modified: 
   trunk/boost/typeof/register_functions.hpp         |    19 ++++++++++-----                         
   trunk/boost/typeof/register_functions_iterate.hpp |    48 ++++++++++++++++++++++++++++++++++++++++
   trunk/libs/typeof/test/function.cpp               |     2 +                                       
   trunk/libs/typeof/test/function_binding.cpp       |    16 ++++++++++---                           
   trunk/libs/typeof/test/function_ptr.cpp           |    17 ++++++++++----                          
   trunk/libs/typeof/test/function_ptr_from_tpl.cpp  |    20 +++++++++++-----                        
   trunk/libs/typeof/test/function_ref.cpp           |     2 +                                       
   7 files changed, 103 insertions(+), 21 deletions(-)
Modified: trunk/boost/typeof/register_functions.hpp
==============================================================================
--- trunk/boost/typeof/register_functions.hpp	(original)
+++ trunk/boost/typeof/register_functions.hpp	2010-02-07 14:13:43 EST (Sun, 07 Feb 2010)
@@ -24,12 +24,19 @@
 enum 
 {
     FUN_ID                          = BOOST_TYPEOF_UNIQUE_ID(),
-    FUN_PTR_ID                      = FUN_ID + 1 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
-    FUN_REF_ID                      = FUN_ID + 2 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
-    MEM_FUN_ID                      = FUN_ID + 3 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
-    CONST_MEM_FUN_ID                = FUN_ID + 4 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
-    VOLATILE_MEM_FUN_ID             = FUN_ID + 5 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
-    VOLATILE_CONST_MEM_FUN_ID       = FUN_ID + 6 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY)
+    FUN_PTR_ID                      = FUN_ID +  1 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
+    FUN_REF_ID                      = FUN_ID +  2 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
+    MEM_FUN_ID                      = FUN_ID +  3 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
+    CONST_MEM_FUN_ID                = FUN_ID +  4 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
+    VOLATILE_MEM_FUN_ID             = FUN_ID +  5 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
+    VOLATILE_CONST_MEM_FUN_ID       = FUN_ID +  6 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
+    FUN_VAR_ID                      = FUN_ID +  7 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
+    FUN_VAR_PTR_ID                  = FUN_ID +  8 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
+    FUN_VAR_REF_ID                  = FUN_ID +  9 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
+    MEM_FUN_VAR_ID                  = FUN_ID + 10 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
+    CONST_MEM_FUN_VAR_ID            = FUN_ID + 11 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
+    VOLATILE_MEM_FUN_VAR_ID         = FUN_ID + 12 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY),
+    VOLATILE_CONST_MEM_FUN_VAR_ID   = FUN_ID + 13 * BOOST_PP_INC(BOOST_TYPEOF_LIMIT_FUNCTION_ARITY)
 };
 
 BOOST_TYPEOF_BEGIN_ENCODE_NS
Modified: trunk/boost/typeof/register_functions_iterate.hpp
==============================================================================
--- trunk/boost/typeof/register_functions_iterate.hpp	(original)
+++ trunk/boost/typeof/register_functions_iterate.hpp	2010-02-07 14:13:43 EST (Sun, 07 Feb 2010)
@@ -15,6 +15,13 @@
     typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_PTR_ID + n) type;
 };
 
+template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
+struct encode_type_impl<V, R(*)(BOOST_PP_ENUM_PARAMS(n, P) ...)>
+{
+    typedef R BOOST_PP_CAT(P, n);
+    typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_VAR_PTR_ID + n) type;
+};
+
 template<class Iter>
 struct decode_type_impl<boost::mpl::size_t<FUN_PTR_ID + n>, Iter>
 {
@@ -24,6 +31,15 @@
     typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
 };
 
+template<class Iter>
+struct decode_type_impl<boost::mpl::size_t<FUN_VAR_PTR_ID + n>, Iter>
+{
+    typedef Iter iter0;
+    BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
+    typedef BOOST_PP_CAT(p, n)(*type)(BOOST_PP_ENUM_PARAMS(n, p) ...);
+    typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
+};
+
 #ifndef BOOST_TYPEOF_NO_FUNCTION_TYPES
 
     // function references
@@ -35,6 +51,13 @@
         typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_REF_ID + n) type;
     };
 
+    template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
+    struct encode_type_impl<V, R(&)(BOOST_PP_ENUM_PARAMS(n, P) ...)>
+    {
+        typedef R BOOST_PP_CAT(P, n);
+        typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_VAR_REF_ID + n) type;
+    };
+
     template<class Iter>
     struct decode_type_impl<boost::mpl::size_t<FUN_REF_ID + n>, Iter>
     {
@@ -44,6 +67,15 @@
         typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
     };
 
+    template<class Iter>
+    struct decode_type_impl<boost::mpl::size_t<FUN_VAR_REF_ID + n>, Iter>
+    {
+        typedef Iter iter0;
+        BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
+        typedef BOOST_PP_CAT(p, n)(&type)(BOOST_PP_ENUM_PARAMS(n, p) ...);
+        typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
+    };
+
     // functions
 
     template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
@@ -53,6 +85,13 @@
         typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_ID + n) type;
     };
 
+    template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
+    struct encode_type_impl<V, R(BOOST_PP_ENUM_PARAMS(n, P) ...)>
+    {
+        typedef R BOOST_PP_CAT(P, n);
+        typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_VAR_ID + n) type;
+    };
+
     template<class Iter>
     struct decode_type_impl<boost::mpl::size_t<FUN_ID + n>, Iter>
     {
@@ -62,6 +101,15 @@
         typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
     };
 
+    template<class Iter>
+    struct decode_type_impl<boost::mpl::size_t<FUN_VAR_ID + n>, Iter>
+    {
+        typedef Iter iter0;
+        BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
+        typedef BOOST_PP_CAT(p, n)(type)(BOOST_PP_ENUM_PARAMS(n, p) ...);
+        typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
+    };
+
 #endif//BOOST_TYPEOF_NO_FUNCTION_TYPES
 
 #ifndef BOOST_TYPEOF_NO_MEMBER_FUNCTION_TYPES
Modified: trunk/libs/typeof/test/function.cpp
==============================================================================
--- trunk/libs/typeof/test/function.cpp	(original)
+++ trunk/libs/typeof/test/function.cpp	2010-02-07 14:13:43 EST (Sun, 07 Feb 2010)
@@ -6,3 +6,5 @@
 
 BOOST_STATIC_ASSERT(boost::type_of::test<void()>::value);
 BOOST_STATIC_ASSERT(boost::type_of::test<double(bool)>::value);
+BOOST_STATIC_ASSERT(boost::type_of::test<void(...)>::value);
+BOOST_STATIC_ASSERT(boost::type_of::test<float(int, ...)>::value);
Modified: trunk/libs/typeof/test/function_binding.cpp
==============================================================================
--- trunk/libs/typeof/test/function_binding.cpp	(original)
+++ trunk/libs/typeof/test/function_binding.cpp	2010-02-07 14:13:43 EST (Sun, 07 Feb 2010)
@@ -7,8 +7,16 @@
 #include <boost/type_traits/is_same.hpp>
 #include <boost/static_assert.hpp>
 
-int foo(double);
-typedef int(&FREF)(double);
-FREF fref = *foo;
+int foo1(double);
+int foo2(...);
+int foo3(int, ...);
+typedef int(&FREF1)(double);
+typedef int(&FREF2)(...);
+typedef int(&FREF3)(int, ...);
+FREF1 fref1 = *foo1;
+FREF2 fref2 = *foo2;
+FREF3 fref3 = *foo3;
 
-BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(fref), int(double)>::value));
+BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(fref1), int(double)>::value));
+BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(fref2), int(...)>::value));
+BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(fref3), int(int,...)>::value));
Modified: trunk/libs/typeof/test/function_ptr.cpp
==============================================================================
--- trunk/libs/typeof/test/function_ptr.cpp	(original)
+++ trunk/libs/typeof/test/function_ptr.cpp	2010-02-07 14:13:43 EST (Sun, 07 Feb 2010)
@@ -8,12 +8,19 @@
 BOOST_STATIC_ASSERT(boost::type_of::test<double(*)(int, double, short, char*, bool, char, float, long, unsigned short)>::value);
 BOOST_STATIC_ASSERT(boost::type_of::test<void(*)()>::value);
 BOOST_STATIC_ASSERT(boost::type_of::test<void(*)(int, double, short, char*, bool, char, float, long, unsigned short)>::value);
+BOOST_STATIC_ASSERT(boost::type_of::test<void(*)(...)>::value);
+BOOST_STATIC_ASSERT(boost::type_of::test<void(*)(int, double, short, char*, bool, char, float, long, unsigned short, ...)>::value);
 
 // check that const gets stripped from function pointer
 
-int foo(double);
-typedef int(*PTR)(double);
-typedef const PTR CPTR;
-CPTR cptr = foo;
+int foo1(double);
+int foo2(...);
+typedef int(*PTR1)(double);
+typedef int(*PTR2)(...);
+typedef const PTR1 CPTR1;
+typedef const PTR2 CPTR2;
+CPTR1 cptr1 = foo1;
+CPTR2 cptr2 = foo2;
 
-BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(cptr), PTR>::value));
+BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(cptr1), PTR1>::value));
+BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(cptr2), PTR2>::value));
Modified: trunk/libs/typeof/test/function_ptr_from_tpl.cpp
==============================================================================
--- trunk/libs/typeof/test/function_ptr_from_tpl.cpp	(original)
+++ trunk/libs/typeof/test/function_ptr_from_tpl.cpp	2010-02-07 14:13:43 EST (Sun, 07 Feb 2010)
@@ -6,15 +6,23 @@
 #include <boost/type_traits/is_same.hpp>
 #include <boost/static_assert.hpp>
 
-void f()
-{}
+void f1() {}
+void f2(...) {}
 
 template<class T> 
-struct tpl
+struct tpl1
 {
-    typedef BOOST_TYPEOF_TPL(&f) type;
+    typedef BOOST_TYPEOF_TPL(&f1) type;
 };
 
-typedef void(*fun_type)();
+template<class T> 
+struct tpl2
+{
+    typedef BOOST_TYPEOF_TPL(&f2) type;
+};
+
+typedef void(*fun1_type)();
+typedef void(*fun2_type)(...);
  
-BOOST_STATIC_ASSERT((boost::is_same<tpl<void>::type, fun_type>::value));
+BOOST_STATIC_ASSERT((boost::is_same<tpl1<void>::type, fun1_type>::value));
+BOOST_STATIC_ASSERT((boost::is_same<tpl2<void>::type, fun2_type>::value));
Modified: trunk/libs/typeof/test/function_ref.cpp
==============================================================================
--- trunk/libs/typeof/test/function_ref.cpp	(original)
+++ trunk/libs/typeof/test/function_ref.cpp	2010-02-07 14:13:43 EST (Sun, 07 Feb 2010)
@@ -6,3 +6,5 @@
 
 BOOST_STATIC_ASSERT(boost::type_of::test<void(&)()>::value);
 BOOST_STATIC_ASSERT(boost::type_of::test<int(&)(int, short)>::value);
+BOOST_STATIC_ASSERT(boost::type_of::test<int(&)(...)>::value);
+BOOST_STATIC_ASSERT(boost::type_of::test<int(&)(int,...)>::value);