Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73953 - in trunk: boost/detail libs/utility
From: john_at_[hidden]
Date: 2011-08-20 12:03:59


Author: johnmaddock
Date: 2011-08-20 12:03:58 EDT (Sat, 20 Aug 2011)
New Revision: 73953
URL: http://svn.boost.org/trac/boost/changeset/73953

Log:
Change call_traits to pass enum's by value.
Fixes #5790.
Text files modified:
   trunk/boost/detail/call_traits.hpp | 20 ++++++++++++++------
   trunk/libs/utility/call_traits_test.cpp | 8 +++++++-
   2 files changed, 21 insertions(+), 7 deletions(-)

Modified: trunk/boost/detail/call_traits.hpp
==============================================================================
--- trunk/boost/detail/call_traits.hpp (original)
+++ trunk/boost/detail/call_traits.hpp 2011-08-20 12:03:58 EDT (Sat, 20 Aug 2011)
@@ -24,6 +24,7 @@
 #include <cstddef>
 
 #include <boost/type_traits/is_arithmetic.hpp>
+#include <boost/type_traits/is_enum.hpp>
 #include <boost/type_traits/is_pointer.hpp>
 #include <boost/detail/workaround.hpp>
 
@@ -43,20 +44,26 @@
    typedef const T param_type;
 };
 
-template <typename T, bool isp, bool b1>
+template <typename T, bool isp, bool b1, bool b2>
 struct ct_imp
 {
    typedef const T& param_type;
 };
 
-template <typename T, bool isp>
-struct ct_imp<T, isp, true>
+template <typename T, bool isp, bool b2>
+struct ct_imp<T, isp, true, b2>
+{
+ typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
+};
+
+template <typename T, bool isp, bool b1>
+struct ct_imp<T, isp, b1, true>
 {
    typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
 };
 
-template <typename T, bool b1>
-struct ct_imp<T, true, b1>
+template <typename T, bool b1, bool b2>
+struct ct_imp<T, true, b1, b2>
 {
    typedef const T param_type;
 };
@@ -79,7 +86,8 @@
    typedef typename boost::detail::ct_imp<
       T,
       ::boost::is_pointer<T>::value,
- ::boost::is_arithmetic<T>::value
+ ::boost::is_arithmetic<T>::value,
+ ::boost::is_enum<T>::value
>::param_type param_type;
 };
 

Modified: trunk/libs/utility/call_traits_test.cpp
==============================================================================
--- trunk/libs/utility/call_traits_test.cpp (original)
+++ trunk/libs/utility/call_traits_test.cpp 2011-08-20 12:03:58 EDT (Sat, 20 Aug 2011)
@@ -210,8 +210,10 @@
    comparible_UDT u;
    c1(u);
    call_traits_checker<int> c2;
+ call_traits_checker<enum_UDT> c2b;
    int i = 2;
    c2(i);
+ c2b(one);
    int* pi = &i;
    int a[2] = {1,2};
 #if defined(BOOST_MSVC6_MEMBER_TEMPLATES) && !defined(__ICL)
@@ -292,7 +294,11 @@
    BOOST_CHECK_TYPE(incomplete_type&, boost::call_traits<incomplete_type>::reference);
    BOOST_CHECK_TYPE(const incomplete_type&, boost::call_traits<incomplete_type>::const_reference);
    BOOST_CHECK_TYPE(const incomplete_type&, boost::call_traits<incomplete_type>::param_type);
-
+ // test enum:
+ BOOST_CHECK_TYPE(enum_UDT, boost::call_traits<enum_UDT>::value_type);
+ BOOST_CHECK_TYPE(enum_UDT&, boost::call_traits<enum_UDT>::reference);
+ BOOST_CHECK_TYPE(const enum_UDT&, boost::call_traits<enum_UDT>::const_reference);
+ BOOST_CHECK_TYPE(const enum_UDT, boost::call_traits<enum_UDT>::param_type);
    return 0;
 }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk