From 072cd1d47c876b7ee83de7e9211e20d269a72e44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20J=C3=A4rvi?= Date: Tue, 11 Dec 2001 22:02:29 +0000 Subject: [PATCH] helper templates for bind lambda functors [SVN r12014] --- include/boost/lambda/detail/lambda_traits.hpp | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/include/boost/lambda/detail/lambda_traits.hpp b/include/boost/lambda/detail/lambda_traits.hpp index 878ee15..80d4bb7 100644 --- a/include/boost/lambda/detail/lambda_traits.hpp +++ b/include/boost/lambda/detail/lambda_traits.hpp @@ -348,16 +348,38 @@ struct array_to_pointer { // from template foo(T& t) : bind_traits::type // Conversions: -// T -> T, +// T -> const T, // cv T -> cv T, // T& -> T& // reference_wrapper -> T& // const reference_wrapper -> T& // array -> const ref array +// make bound arguments const, this is a deliberate design choice, the +// purpose is to prevent side effects to bound arguments that are stored +// as copies template struct bind_traits { - typedef T type; + typedef const T type; +}; + +template +struct bind_traits { + typedef T& type; +}; + +// null_types are an exception, we always want to store them as non const +// so that other templates can assume that null_type is always without const +template<> +struct bind_traits { + typedef null_type type; +}; + +// the bind_tuple_mapper, bind_type_generators may +// introduce const to null_type +template<> +struct bind_traits { + typedef null_type type; }; // Arrays can't be stored as plain types; convert them to references. @@ -392,12 +414,6 @@ struct bind_traits >{ typedef T& type; }; -// the bind_tuple_mapper, bind_type_generators may -// cause const null_type values to appear in tuples -template<> -struct bind_traits { - typedef null_type type; -}; template < @@ -460,7 +476,7 @@ public: } // detail template inline const T& make_const(const T& t) { return t; } -. + } // end of namespace lambda } // end of namespace boost