From b3402e49f9266161644da59cf069c958d2176676 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 4 Nov 2000 22:40:20 +0000 Subject: [PATCH] added missing 'template' keyword on type-dependent template member usage removed special-case MSVC code added much commentary [SVN r8138] --- gen_init_function.py | 43 +++++++++++++++++++++++++------------------ init_function.h | 43 +++++++++++++++++++++++++------------------ 2 files changed, 50 insertions(+), 36 deletions(-) diff --git a/gen_init_function.py b/gen_init_function.py index a34e8ba3..1a5fc2ca 100644 --- a/gen_init_function.py +++ b/gen_init_function.py @@ -26,11 +26,31 @@ namespace py { namespace detail { -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - // parameter_traits - so far, this is a way to pass a const T& when we can be // sure T is not a reference type, and a raw T otherwise. This should be - // rolled into boost::call_traits. + // rolled into boost::call_traits. Ordinarily, parameter_traits would be + // written: + // + // template struct parameter_traits + // { + // typedef const T& const_reference; + // }; + // + // template struct parameter_traits + // { + // typedef T& const_reference; + // }; + // + // template <> struct parameter_traits + // { + // typedef void const_reference; + // }; + // + // ...but since we can't partially specialize on reference types, we need this + // long-winded but equivalent incantation. + + // const_ref_selector -- an implementation detail of parameter_traits (below). This uses + // the usual "poor man's partial specialization" hack for MSVC. template struct const_ref_selector { @@ -61,26 +81,13 @@ namespace detail { private: typedef const_ref_selector::value> selector; public: - typedef typename selector::const_ref::type const_reference; + typedef typename selector::template const_ref::type const_reference; }; # ifdef BOOST_MSVC # pragma warning(pop) # endif // BOOST_MSVC -#else - template - struct parameter_traits - { - typedef const T& const_reference; - }; - - template - struct parameter_traits - { - typedef T& const_reference; - }; -#endif - + // Full spcialization for void template <> struct parameter_traits { diff --git a/init_function.h b/init_function.h index 8e976015..5ee49b26 100644 --- a/init_function.h +++ b/init_function.h @@ -20,11 +20,31 @@ namespace py { namespace detail { -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - // parameter_traits - so far, this is a way to pass a const T& when we can be // sure T is not a reference type, and a raw T otherwise. This should be - // rolled into boost::call_traits. + // rolled into boost::call_traits. Ordinarily, parameter_traits would be + // written: + // + // template struct parameter_traits + // { + // typedef const T& const_reference; + // }; + // + // template struct parameter_traits + // { + // typedef T& const_reference; + // }; + // + // template <> struct parameter_traits + // { + // typedef void const_reference; + // }; + // + // ...but since we can't partially specialize on reference types, we need this + // long-winded but equivalent incantation. + + // const_ref_selector -- an implementation detail of parameter_traits (below). This uses + // the usual "poor man's partial specialization" hack for MSVC. template struct const_ref_selector { @@ -55,26 +75,13 @@ namespace detail { private: typedef const_ref_selector::value> selector; public: - typedef typename selector::const_ref::type const_reference; + typedef typename selector::template const_ref::type const_reference; }; # ifdef BOOST_MSVC # pragma warning(pop) # endif // BOOST_MSVC -#else - template - struct parameter_traits - { - typedef const T& const_reference; - }; - - template - struct parameter_traits - { - typedef T& const_reference; - }; -#endif - + // Full spcialization for void template <> struct parameter_traits {