Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71535 - in trunk: boost/proto boost/proto/transform libs/proto/doc libs/proto/doc/reference/transform
From: eric_at_[hidden]
Date: 2011-04-27 12:14:49


Author: eric_niebler
Date: 2011-04-27 12:14:47 EDT (Wed, 27 Apr 2011)
New Revision: 71535
URL: http://svn.boost.org/trac/boost/changeset/71535

Log:
add integral_c transform and friends
Added:
   trunk/boost/proto/transform/integral_c.hpp (contents, props changed)
   trunk/libs/proto/doc/reference/transform/integral_c.xml (contents, props changed)
Text files modified:
   trunk/boost/proto/proto_fwd.hpp | 15 +++++++++++++++
   trunk/boost/proto/transform.hpp | 1 +
   trunk/libs/proto/doc/reference.xml | 31 ++++++++++++++++++++++++++-----
   3 files changed, 42 insertions(+), 5 deletions(-)

Modified: trunk/boost/proto/proto_fwd.hpp
==============================================================================
--- trunk/boost/proto/proto_fwd.hpp (original)
+++ trunk/boost/proto/proto_fwd.hpp 2011-04-27 12:14:47 EDT (Wed, 27 Apr 2011)
@@ -724,6 +724,21 @@
 
     struct _void;
 
+ template<typename T, T I>
+ struct integral_c;
+
+ template<char I>
+ struct char_;
+
+ template<int I>
+ struct int_;
+
+ template<long I>
+ struct long_;
+
+ template<std::size_t I>
+ struct size_t;
+
     template<int I>
     struct _child_c;
 

Modified: trunk/boost/proto/transform.hpp
==============================================================================
--- trunk/boost/proto/transform.hpp (original)
+++ trunk/boost/proto/transform.hpp 2011-04-27 12:14:47 EDT (Wed, 27 Apr 2011)
@@ -14,6 +14,7 @@
 #include <boost/proto/transform/default.hpp>
 #include <boost/proto/transform/fold.hpp>
 #include <boost/proto/transform/fold_tree.hpp>
+#include <boost/proto/transform/integral_c.hpp>
 #include <boost/proto/transform/lazy.hpp>
 #include <boost/proto/transform/make.hpp>
 #include <boost/proto/transform/pass_through.hpp>

Added: trunk/boost/proto/transform/integral_c.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/proto/transform/integral_c.hpp 2011-04-27 12:14:47 EDT (Wed, 27 Apr 2011)
@@ -0,0 +1,113 @@
+///////////////////////////////////////////////////////////////////////////////
+/// \file arg.hpp
+/// Contains definition of the argN transforms.
+//
+// Copyright 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_PROTO_TRANSFORM_ARG_HPP_EAN_11_01_2007
+#define BOOST_PROTO_TRANSFORM_ARG_HPP_EAN_11_01_2007
+
+#include <boost/proto/proto_fwd.hpp>
+#include <boost/proto/transform/impl.hpp>
+
+namespace boost { namespace proto
+{
+
+ /// \brief A PrimitiveTransform that returns a specified
+ /// integral constant
+ ///
+ template<typename T, T I>
+ struct integral_c : transform<integral_c<T, I> >
+ {
+ template<typename Expr, typename State, typename Data>
+ struct impl : transform_impl<Expr, State, Data>
+ {
+ typedef T result_type;
+
+ /// Returns I.
+ /// \param e The current expression.
+ /// \return \c e
+ /// \throw nothrow
+ T operator()(
+ typename impl::expr_param
+ , typename impl::state_param
+ , typename impl::data_param
+ ) const
+ {
+ return I;
+ }
+ };
+ };
+
+ /// \brief A PrimitiveTransform that returns a specified
+ /// char
+ ///
+ template<char I>
+ struct char_
+ : integral_c<char, I>
+ {};
+
+ /// \brief A PrimitiveTransform that returns a specified
+ /// int
+ ///
+ template<int I>
+ struct int_
+ : integral_c<int, I>
+ {};
+
+ /// \brief A PrimitiveTransform that returns a specified
+ /// long
+ ///
+ template<long I>
+ struct long_
+ : integral_c<long, I>
+ {};
+
+ /// \brief A PrimitiveTransform that returns a specified
+ /// std::size_t
+ ///
+ template<std::size_t I>
+ struct size_t
+ : integral_c<std::size_t, I>
+ {};
+
+ /// INTERNAL ONLY
+ ///
+ template<typename T, T I>
+ struct is_callable<integral_c<T, I> >
+ : mpl::true_
+ {};
+
+ /// INTERNAL ONLY
+ ///
+ template<char I>
+ struct is_callable<char_<I> >
+ : mpl::true_
+ {};
+
+ /// INTERNAL ONLY
+ ///
+ template<int I>
+ struct is_callable<int_<I> >
+ : mpl::true_
+ {};
+
+ /// INTERNAL ONLY
+ ///
+ template<long I>
+ struct is_callable<long_<I> >
+ : mpl::true_
+ {};
+
+ /// INTERNAL ONLY
+ ///
+ template<std::size_t I>
+ struct is_callable<size_t<I> >
+ : mpl::true_
+ {};
+
+}}
+
+#endif

Modified: trunk/libs/proto/doc/reference.xml
==============================================================================
--- trunk/libs/proto/doc/reference.xml (original)
+++ trunk/libs/proto/doc/reference.xml 2011-04-27 12:14:47 EDT (Wed, 27 Apr 2011)
@@ -75,11 +75,6 @@
           <classname alt="boost::proto::assign">proto::assign</classname>
         </computeroutput>
       </listitem>
- <!--<listitem>
- <computeroutput>
- <classname alt="boost::proto::base_expr">proto::base_expr</classname>
- </computeroutput>
- </listitem>-->
       <listitem>
         <computeroutput>
           <classname alt="boost::proto::basic_expr">proto::basic_expr</classname>
@@ -137,6 +132,11 @@
       </listitem>
       <listitem>
         <computeroutput>
+ <classname alt="boost::proto::char_">proto::char_</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
           <classname alt="boost::proto::comma">proto::comma</classname>
         </computeroutput>
       </listitem>
@@ -417,6 +417,16 @@
       </listitem>
       <listitem>
         <computeroutput>
+ <classname alt="boost::proto::int_">proto::int_</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
+ <classname alt="boost::proto::integral_c">proto::integral_c</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
           <classname alt="boost::proto::is_aggregate">proto::is_aggregate</classname>
         </computeroutput>
       </listitem>
@@ -492,6 +502,11 @@
       </listitem>
       <listitem>
         <computeroutput>
+ <classname alt="boost::proto::long_">proto::long_</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
           <classname alt="boost::proto::make">proto::make</classname>
         </computeroutput>
       </listitem>
@@ -712,6 +727,11 @@
       </listitem>
       <listitem>
         <computeroutput>
+ <classname alt="boost::proto::size_t">proto::size_t</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
           <classname alt="boost::proto::subscript">proto::subscript</classname>
         </computeroutput>
       </listitem>
@@ -1136,6 +1156,7 @@
   <xi:include href="reference/transform/fold.xml"/>
   <xi:include href="reference/transform/fold_tree.xml"/>
   <xi:include href="reference/transform/impl.xml"/>
+ <xi:include href="reference/transform/integral_c.xml"/>
   <xi:include href="reference/transform/lazy.xml"/>
   <xi:include href="reference/transform/make.xml"/>
   <xi:include href="reference/transform/pass_through.xml"/>

Added: trunk/libs/proto/doc/reference/transform/integral_c.xml
==============================================================================
--- (empty file)
+++ trunk/libs/proto/doc/reference/transform/integral_c.xml 2011-04-27 12:14:47 EDT (Wed, 27 Apr 2011)
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="utf-8"?>
+<header name="boost/proto/transform/integral_c.hpp">
+ <para>Contains definition of the integral_c transform and friends.</para>
+ <namespace name="boost">
+ <namespace name="proto">
+
+ <struct name="integral_c">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="I">
+ <type>T</type>
+ </template-nontype-parameter>
+ </template>
+ <inherit><classname>proto::transform</classname>&lt; integral_c&lt; T, I &gt; &gt;</inherit>
+ <purpose>A <conceptname>PrimitiveTransform</conceptname> that returns the specified integral constant.</purpose>
+ <struct name="impl">
+ <template>
+ <template-type-parameter name="Expr"/>
+ <template-type-parameter name="State"/>
+ <template-type-parameter name="Data"/>
+ </template>
+ <inherit><classname>proto::transform_impl</classname>&lt; Expr, State, Data &gt;</inherit>
+ <typedef name="result_type">
+ <type>T</type>
+ </typedef>
+ <method-group name="public member functions">
+ <method name="operator()" cv="const">
+ <type>T</type>
+ <parameter name="">
+ <paramtype>typename impl::expr_param</paramtype>
+ </parameter>
+ <parameter name="">
+ <paramtype>typename impl::state_param</paramtype>
+ </parameter>
+ <parameter name="">
+ <paramtype>typename impl::data_param</paramtype>
+ </parameter>
+ <returns>
+ <para>
+ <computeroutput>I</computeroutput>
+ </para>
+ </returns>
+ <throws>
+ <simpara>Will not throw.</simpara>
+ </throws>
+ </method>
+ </method-group>
+ </struct>
+ </struct>
+
+ <struct name="char_">
+ <template>
+ <template-nontype-parameter name="I">
+ <type>char</type>
+ </template-nontype-parameter>
+ </template>
+ <inherit><classname>proto::integral_c</classname>&lt; char, I &gt;</inherit>
+ <purpose>A <conceptname>PrimitiveTransform</conceptname> that returns the specified char.</purpose>
+ </struct>
+
+ <struct name="int_">
+ <template>
+ <template-nontype-parameter name="I">
+ <type>int</type>
+ </template-nontype-parameter>
+ </template>
+ <inherit><classname>proto::integral_c</classname>&lt; int, I &gt;</inherit>
+ <purpose>A <conceptname>PrimitiveTransform</conceptname> that returns the specified int.</purpose>
+ </struct>
+
+ <struct name="long_">
+ <template>
+ <template-nontype-parameter name="I">
+ <type>long</type>
+ </template-nontype-parameter>
+ </template>
+ <inherit><classname>proto::integral_c</classname>&lt; long, I &gt;</inherit>
+ <purpose>A <conceptname>PrimitiveTransform</conceptname> that returns the specified long.</purpose>
+ </struct>
+
+ <struct name="size_t">
+ <template>
+ <template-nontype-parameter name="I">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+ <inherit><classname>proto::integral_c</classname>&lt; std::size_t, I &gt;</inherit>
+ <purpose>A <conceptname>PrimitiveTransform</conceptname> that returns the specified std::size_t.</purpose>
+ </struct>
+
+ </namespace>
+ </namespace>
+</header>


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