Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-05-21 17:01:59


Author: eric_niebler
Date: 2008-05-21 17:01:58 EDT (Wed, 21 May 2008)
New Revision: 45624
URL: http://svn.boost.org/trac/boost/changeset/45624

Log:
add the various phoenix object utilities
Added:
   branches/proto/v4/boost/phoenix/object/
   branches/proto/v4/boost/phoenix/object.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/object/const_cast.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/object/construct.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/object/delete.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/object/dynamic_cast.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/object/new.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/object/reinterpret_cast.hpp (contents, props changed)
   branches/proto/v4/boost/phoenix/object/static_cast.hpp (contents, props changed)

Added: branches/proto/v4/boost/phoenix/object.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/object.hpp 2008-05-21 17:01:58 EDT (Wed, 21 May 2008)
@@ -0,0 +1,19 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2008 Eric Niebler
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#ifndef BOOST_PHOENIX_OBJECT_HPP_EAN_2008_05_21
+#define BOOST_PHOENIX_OBJECT_HPP_EAN_2008_05_21
+
+#include <boost/phoenix/object/new.hpp>
+#include <boost/phoenix/object/delete.hpp>
+#include <boost/phoenix/object/construct.hpp>
+#include <boost/phoenix/object/const_cast.hpp>
+#include <boost/phoenix/object/static_cast.hpp>
+#include <boost/phoenix/object/dynamic_cast.hpp>
+#include <boost/phoenix/object/reinterpret_cast.hpp>
+
+#endif

Added: branches/proto/v4/boost/phoenix/object/const_cast.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/object/const_cast.hpp 2008-05-21 17:01:58 EDT (Wed, 21 May 2008)
@@ -0,0 +1,49 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2008 Eric Niebler
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#ifndef BOOST_PHOENIX_OBJECT_CONST_CAST_HPP_EAN_2008_05_21
+#define BOOST_PHOENIX_OBJECT_CONST_CAST_HPP_EAN_2008_05_21
+
+#include <boost/proto/proto.hpp>
+#include <boost/phoenix/core/actor.hpp>
+
+namespace boost { namespace phoenix
+{
+
+ namespace detail
+ {
+ template<typename T>
+ struct const_cast_
+ {
+ typedef T result_type;
+
+ template<typename U>
+ T operator()(U &u) const
+ {
+ return const_cast<T>(u);
+ }
+ };
+ }
+
+ template<typename T, typename U>
+ actor<
+ typename proto::result_of::make_expr<
+ proto::tag::function
+ , proto::default_domain
+ , detail::const_cast_<T>
+ , U
+ >::type
+ > const
+ const_cast_(U const &u)
+ {
+ detail::const_cast_<T> cast;
+ return proto::implicit_expr(cast, u);
+ }
+
+}}
+
+#endif

Added: branches/proto/v4/boost/phoenix/object/construct.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/object/construct.hpp 2008-05-21 17:01:58 EDT (Wed, 21 May 2008)
@@ -0,0 +1,59 @@
+#ifndef BOOST_PP_IS_ITERATING
+ /*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2008 Eric Niebler
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ ==============================================================================*/
+ #ifndef BOOST_PHOENIX_OBJECT_CONSTRUCT_HPP_EAN_2008_05_21
+ #define BOOST_PHOENIX_OBJECT_CONSTRUCT_HPP_EAN_2008_05_21
+
+ #include <boost/proto/proto.hpp>
+ #include <boost/phoenix/core/actor.hpp>
+
+ namespace boost { namespace phoenix
+ {
+
+ namespace detail
+ {
+ template<typename T>
+ struct construct
+ {
+ typedef T result_type;
+
+ T operator()() const
+ {
+ return T();
+ }
+
+ #define BOOST_PP_ITERATION_PARAMS_1 \
+ (3, (1, PHOENIX_LIMIT, <boost/phoenix/object/construct.hpp>))
+ #include BOOST_PP_ITERATE()
+ };
+ }
+
+ BOOST_PROTO_DEFINE_VARARG_FUNCTION_TEMPLATE(
+ construct
+ , detail::domain
+ , (proto::tag::function)
+ , ((detail::construct)(typename))
+ )
+
+ }}
+
+ #endif
+
+#else
+
+ #define N BOOST_PP_ITERATION()
+
+ template<BOOST_PP_ENUM_PARAMS(N, typename A)>
+ T operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const &a)) const
+ {
+ return T(BOOST_PP_ENUM_PARAMS(N, a));
+ }
+
+ #undef N
+
+#endif

Added: branches/proto/v4/boost/phoenix/object/delete.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/object/delete.hpp 2008-05-21 17:01:58 EDT (Wed, 21 May 2008)
@@ -0,0 +1,47 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2008 Eric Niebler
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#ifndef BOOST_PHOENIX_OBJECT_DELETE_HPP_EAN_2008_05_21
+#define BOOST_PHOENIX_OBJECT_DELETE_HPP_EAN_2008_05_21
+
+#include <boost/proto/proto.hpp>
+#include <boost/checked_delete.hpp>
+#include <boost/phoenix/core/actor.hpp>
+
+namespace boost { namespace phoenix
+{
+
+ namespace detail
+ {
+ struct delete_
+ {
+ typedef void result_type;
+
+ template<typename T>
+ void operator()(T const *t) const
+ {
+ boost::checked_delete(t);
+ }
+ };
+ }
+
+ template<typename T>
+ typename proto::result_of::make_expr<
+ proto::tag::function
+ , detail::domain
+ , detail::delete_
+ , T const &
+ >::type const
+ delete_(T const &t)
+ {
+ detail::delete_ del;
+ return proto::implicit_expr(del, t);
+ }
+
+}}
+
+#endif

Added: branches/proto/v4/boost/phoenix/object/dynamic_cast.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/object/dynamic_cast.hpp 2008-05-21 17:01:58 EDT (Wed, 21 May 2008)
@@ -0,0 +1,49 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2008 Eric Niebler
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#ifndef BOOST_PHOENIX_OBJECT_DYNAMIC_CAST_HPP_EAN_2008_05_21
+#define BOOST_PHOENIX_OBJECT_DYNAMIC_CAST_HPP_EAN_2008_05_21
+
+#include <boost/proto/proto.hpp>
+#include <boost/phoenix/core/actor.hpp>
+
+namespace boost { namespace phoenix
+{
+
+ namespace detail
+ {
+ template<typename T>
+ struct dynamic_cast_
+ {
+ typedef T result_type;
+
+ template<typename U>
+ T operator()(U &u) const
+ {
+ return dynamic_cast<T>(u);
+ }
+ };
+ }
+
+ template<typename T, typename U>
+ actor<
+ typename proto::result_of::make_expr<
+ proto::tag::function
+ , proto::default_domain
+ , detail::dynamic_cast_<T>
+ , U
+ >::type
+ > const
+ dynamic_cast_(U const &u)
+ {
+ detail::dynamic_cast_<T> cast;
+ return proto::implicit_expr(cast, u);
+ }
+
+}}
+
+#endif

Added: branches/proto/v4/boost/phoenix/object/new.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/object/new.hpp 2008-05-21 17:01:58 EDT (Wed, 21 May 2008)
@@ -0,0 +1,59 @@
+#ifndef BOOST_PP_IS_ITERATING
+ /*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2008 Eric Niebler
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ ==============================================================================*/
+ #ifndef BOOST_PHOENIX_OBJECT_NEW_HPP_EAN_2008_05_21
+ #define BOOST_PHOENIX_OBJECT_NEW_HPP_EAN_2008_05_21
+
+ #include <boost/proto/proto.hpp>
+ #include <boost/phoenix/core/actor.hpp>
+
+ namespace boost { namespace phoenix
+ {
+
+ namespace detail
+ {
+ template<typename T>
+ struct new_
+ {
+ typedef T *result_type;
+
+ T *operator()() const
+ {
+ return new T;
+ }
+
+ #define BOOST_PP_ITERATION_PARAMS_1 \
+ (3, (1, PHOENIX_LIMIT, <boost/phoenix/object/new.hpp>))
+ #include BOOST_PP_ITERATE()
+ };
+ }
+
+ BOOST_PROTO_DEFINE_VARARG_FUNCTION_TEMPLATE(
+ new_
+ , detail::domain
+ , (proto::tag::function)
+ , ((detail::new_)(typename))
+ )
+
+ }}
+
+ #endif
+
+#else
+
+ #define N BOOST_PP_ITERATION()
+
+ template<BOOST_PP_ENUM_PARAMS(N, typename A)>
+ T *operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const &a)) const
+ {
+ return new T(BOOST_PP_ENUM_PARAMS(N, a));
+ }
+
+ #undef N
+
+#endif

Added: branches/proto/v4/boost/phoenix/object/reinterpret_cast.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/object/reinterpret_cast.hpp 2008-05-21 17:01:58 EDT (Wed, 21 May 2008)
@@ -0,0 +1,49 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2008 Eric Niebler
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#ifndef BOOST_PHOENIX_OBJECT_REINTERPRET_CAST_HPP_EAN_2008_05_21
+#define BOOST_PHOENIX_OBJECT_REINTERPRET_CAST_HPP_EAN_2008_05_21
+
+#include <boost/proto/proto.hpp>
+#include <boost/phoenix/core/actor.hpp>
+
+namespace boost { namespace phoenix
+{
+
+ namespace detail
+ {
+ template<typename T>
+ struct reinterpret_cast_
+ {
+ typedef T result_type;
+
+ template<typename U>
+ T operator()(U &u) const
+ {
+ return reinterpret_cast<T>(u);
+ }
+ };
+ }
+
+ template<typename T, typename U>
+ actor<
+ typename proto::result_of::make_expr<
+ proto::tag::function
+ , proto::default_domain
+ , detail::reinterpret_cast_<T>
+ , U
+ >::type
+ > const
+ reinterpret_cast_(U const &u)
+ {
+ detail::reinterpret_cast_<T> cast;
+ return proto::implicit_expr(cast, u);
+ }
+
+}}
+
+#endif

Added: branches/proto/v4/boost/phoenix/object/static_cast.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v4/boost/phoenix/object/static_cast.hpp 2008-05-21 17:01:58 EDT (Wed, 21 May 2008)
@@ -0,0 +1,49 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2008 Eric Niebler
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#ifndef BOOST_PHOENIX_OBJECT_STATIC_CAST_HPP_EAN_2008_05_21
+#define BOOST_PHOENIX_OBJECT_STATIC_CAST_HPP_EAN_2008_05_21
+
+#include <boost/proto/proto.hpp>
+#include <boost/phoenix/core/actor.hpp>
+
+namespace boost { namespace phoenix
+{
+
+ namespace detail
+ {
+ template<typename T>
+ struct static_cast_
+ {
+ typedef T result_type;
+
+ template<typename U>
+ T operator()(U &u) const
+ {
+ return static_cast<T>(u);
+ }
+ };
+ }
+
+ template<typename T, typename U>
+ actor<
+ typename proto::result_of::make_expr<
+ proto::tag::function
+ , proto::default_domain
+ , detail::static_cast_<T>
+ , U
+ >::type
+ > const
+ static_cast_(U const &u)
+ {
+ detail::static_cast_<T> cast;
+ return proto::implicit_expr(cast, u);
+ }
+
+}}
+
+#endif


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