From bfcb36927c98ca69095b482ebb159e06d2a7a654 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 1 Jan 2002 18:49:20 +0000 Subject: [PATCH] Accounting for by-value conversions [SVN r12190] --- include/boost/python/converter/target.hpp | 44 ++++++++++++++++------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/include/boost/python/converter/target.hpp b/include/boost/python/converter/target.hpp index 6effb996..f8f33171 100644 --- a/include/boost/python/converter/target.hpp +++ b/include/boost/python/converter/target.hpp @@ -33,8 +33,6 @@ namespace boost { namespace python { namespace converter { // importantly, avoids having to dynamically allocate room for // an lvalue of types which can be cheaply copied. // -// In the tables below, "cv" stands for the set of all possible -// cv-qualifications. // Target Source // int int @@ -46,10 +44,16 @@ namespace boost { namespace python { namespace converter { // On compilers supporting partial specialization: // // Target Source -// T T& -// T cv& T& -// T cv* T* -// T cv*const& T* +// T T const& +// T& T& +// T const& T const& +// T volatile T& +// T const volatile& T const& +// T* T* +// T const* T const* +// T volatile T* +// T const volatile* T const* +// T cv*const& same as T cv* // T cv*& T*& <- should this be legal? // T cv*volatile& T*& <- should this be legal? // T cv*const volatile& T*& <- should this be legal? @@ -75,7 +79,11 @@ struct target typedef typename mpl::select_type< use_identity , T - , typename add_reference::type>::type + , typename add_reference< + typename add_const< + typename remove_volatile::type + >::type + >::type >::type type; }; @@ -86,13 +94,23 @@ struct target template struct target { - typedef typename remove_cv::type& type; + typedef typename remove_volatile::type& type; +}; + +template +struct target +{ + typedef typename boost::mpl::select_type< + is_scalar::value + , typename remove_cv::type + , typename remove_volatile::type const& + >::type type; }; template struct target { - typedef typename remove_cv::type* type; + typedef typename remove_volatile::type* type; }; // Handle T*-cv for completeness. Function arguments in a signature @@ -102,19 +120,19 @@ struct target template struct target { - typedef typename remove_cv::type* type; + typedef typename remove_volatile::type* type; }; template struct target { - typedef typename remove_cv::type* type; + typedef typename remove_volatile::type* type; }; template struct target { - typedef typename remove_cv::type* type; + typedef typename remove_volatile::type* type; }; // non-const references to pointers should be handled by the @@ -122,7 +140,7 @@ struct target template struct target { - typedef typename remove_cv::type* type; + typedef typename remove_volatile::type* type; }; # endif