|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2008-05-28 11:51:16
Author: eric_niebler
Date: 2008-05-28 11:51:15 EDT (Wed, 28 May 2008)
New Revision: 45871
URL: http://svn.boost.org/trac/boost/changeset/45871
Log:
s/detail::deref/get_pointer/
Text files modified:
branches/proto/v4/boost/proto/context/default.hpp | 9 ++++--
branches/proto/v4/boost/proto/detail/decltype.hpp | 55 ++++++++++++++++++++++++++-------------
branches/proto/v4/boost/proto/transform/default.hpp | 10 +++++--
3 files changed, 49 insertions(+), 25 deletions(-)
Modified: branches/proto/v4/boost/proto/context/default.hpp
==============================================================================
--- branches/proto/v4/boost/proto/context/default.hpp (original)
+++ branches/proto/v4/boost/proto/context/default.hpp 2008-05-28 11:51:15 EDT (Wed, 28 May 2008)
@@ -354,12 +354,14 @@
result_type invoke(Expr &expr, Context &context, mpl::true_, mpl::false_) const
{
- return (detail::deref(EVAL(~, 1, expr)) .* EVAL(~, 0, expr))();
+ using namespace detail::get_pointer_;
+ return (get_pointer(EVAL(~, 1, expr)) ->* EVAL(~, 0, expr))();
}
result_type invoke(Expr &expr, Context &context, mpl::false_, mpl::true_) const
{
- return (detail::deref(EVAL(~, 1, expr)) .* EVAL(~, 0, expr));
+ using namespace detail::get_pointer_;
+ return (get_pointer(EVAL(~, 1, expr)) ->* EVAL(~, 0, expr));
}
};
@@ -420,7 +422,8 @@
result_type invoke(Expr &expr, Context &context, mpl::true_) const
{
#define M0(Z, M, expr) BOOST_PP_COMMA_IF(BOOST_PP_SUB(M, 2)) EVAL(Z, M, expr)
- return (detail::deref(EVAL(~, 1, expr)) .* EVAL(~, 0, expr))(
+ using namespace detail::get_pointer_;
+ return (get_pointer(EVAL(~, 1, expr)) ->* EVAL(~, 0, expr))(
BOOST_PP_REPEAT_FROM_TO(2, N, M0, expr)
);
#undef M0
Modified: branches/proto/v4/boost/proto/detail/decltype.hpp
==============================================================================
--- branches/proto/v4/boost/proto/detail/decltype.hpp (original)
+++ branches/proto/v4/boost/proto/detail/decltype.hpp 2008-05-28 11:51:15 EDT (Wed, 28 May 2008)
@@ -11,14 +11,17 @@
#include <boost/proto/detail/prefix.hpp> // must be first include
#include <boost/config.hpp>
+#include <boost/get_pointer.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/remove_cv.hpp>
+#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_function.hpp>
#include <boost/typeof/typeof.hpp>
+#include <boost/utility/addressof.hpp>
#include <boost/utility/result_of.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/proto/detail/suffix.hpp> // must be last include
@@ -88,29 +91,41 @@
template<typename T>
char (&check_reference(T const &))[2];
- ////////////////////////////////////////////////////////////////////////////////////////////
- template<typename T>
- T &deref(T &t)
+ namespace has_get_pointer_
{
- return t;
+ using boost::get_pointer;
+ void *(&get_pointer(...))[2];
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename T>
+ struct has_get_pointer
+ {
+ static T &t;
+ BOOST_STATIC_CONSTANT(bool, value = sizeof(void *) == sizeof(get_pointer(t)));
+ typedef mpl::bool_<value> type;
+ };
}
- template<typename T>
- T const &deref(T const &t)
+ using has_get_pointer_::has_get_pointer;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ namespace get_pointer_
{
- return t;
- }
+ using boost::get_pointer;
- template<typename T>
- T &deref(T *&t)
- {
- return *t;
- }
+ template<typename T>
+ typename disable_if<has_get_pointer<T>, T *>::type
+ get_pointer(T &t)
+ {
+ return boost::addressof(t);
+ }
- template<typename T>
- T &deref(T *const &t)
- {
- return *t;
+ template<typename T>
+ typename disable_if<has_get_pointer<T>, T const *>::type
+ get_pointer(T const &t)
+ {
+ return boost::addressof(t);
+ }
}
////////////////////////////////////////////////////////////////////////////////////////////
@@ -212,14 +227,16 @@
result_type operator()() const
{
- return (detail::deref(obj).*pmf)();
+ using namespace get_pointer_;
+ return (get_pointer(obj) ->* pmf)();
}
#define M0(Z, N, DATA) \
template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)> \
result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, const &a)) const \
{ \
- return (detail::deref(obj).*pmf)(BOOST_PP_ENUM_PARAMS_Z(Z, N, a)); \
+ using namespace get_pointer_; \
+ return (get_pointer(obj) ->* pmf)(BOOST_PP_ENUM_PARAMS_Z(Z, N, a)); \
} \
/**/
BOOST_PP_REPEAT_FROM_TO(1, BOOST_PROTO_MAX_ARITY, M0, ~)
Modified: branches/proto/v4/boost/proto/transform/default.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/default.hpp (original)
+++ branches/proto/v4/boost/proto/transform/default.hpp 2008-05-28 11:51:15 EDT (Wed, 28 May 2008)
@@ -17,6 +17,7 @@
#include <boost/preprocessor/repetition/enum_shifted.hpp>
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
#include <boost/ref.hpp>
+ #include <boost/get_pointer.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_member_pointer.hpp>
#include <boost/type_traits/is_member_object_pointer.hpp>
@@ -420,7 +421,8 @@
, mpl::false_
) const
{
- return (detail::deref(EVAL(~, 1, expr)) .* EVAL(~, 0, expr))();
+ using namespace detail::get_pointer_;
+ return (get_pointer(EVAL(~, 1, expr)) ->* EVAL(~, 0, expr))();
}
result_type invoke(
@@ -431,7 +433,8 @@
, mpl::true_
) const
{
- return (detail::deref(EVAL(~, 1, expr)) .* EVAL(~, 0, expr));
+ using namespace detail::get_pointer_;
+ return (get_pointer(EVAL(~, 1, expr)) ->* EVAL(~, 0, expr));
}
};
@@ -510,7 +513,8 @@
) const
{
#define M0(Z, M, expr) BOOST_PP_COMMA_IF(BOOST_PP_SUB(M, 2)) EVAL(Z, M, expr)
- return (detail::deref(EVAL(~, 1, expr)) .* EVAL(~, 0, expr))(
+ using namespace detail::get_pointer_;
+ return (get_pointer(EVAL(~, 1, expr)) ->* EVAL(~, 0, expr))(
BOOST_PP_REPEAT_FROM_TO(2, N, M0, expr)
);
#undef M0
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