├── .gitattributes ├── .travis.yml ├── CMakeLists.txt ├── build.jam ├── doc ├── Jamfile.v2 ├── acknowledgements.qbk ├── back_end.qbk ├── calculator.qbk ├── conventions.qbk ├── examples.qbk ├── front_end.qbk ├── getting_started.qbk ├── glossary.qbk ├── hello_world.qbk ├── history.qbk ├── implementation.qbk ├── installation.qbk ├── intermediate_form.qbk ├── preface.qbk ├── propdocs.sh ├── proto.qbk ├── rationale.qbk ├── reference.xml ├── reference │ ├── args.xml │ ├── concepts │ │ ├── BasicPrimitiveTransform.xml │ │ ├── CallableTransform.xml │ │ ├── Domain.xml │ │ ├── Expr.xml │ │ ├── ObjectTransform.xml │ │ ├── PolymorphicFunctionObject.xml │ │ ├── PrimitiveTransform.xml │ │ └── Transform.xml │ ├── context.xml │ ├── context │ │ ├── callable.xml │ │ ├── default.xml │ │ └── null.xml │ ├── core.xml │ ├── debug.xml │ ├── deep_copy.xml │ ├── domain.xml │ ├── eval.xml │ ├── expr.xml │ ├── extends.xml │ ├── functional.xml │ ├── functional │ │ ├── fusion.xml │ │ ├── fusion │ │ │ ├── at.xml │ │ │ ├── pop_back.xml │ │ │ ├── pop_front.xml │ │ │ ├── push_back.xml │ │ │ ├── push_front.xml │ │ │ └── reverse.xml │ │ ├── range.xml │ │ ├── range │ │ │ ├── begin.xml │ │ │ ├── empty.xml │ │ │ ├── end.xml │ │ │ ├── rbegin.xml │ │ │ ├── rend.xml │ │ │ └── size.xml │ │ ├── std.xml │ │ └── std │ │ │ ├── iterator.xml │ │ │ └── utility.xml │ ├── fusion.xml │ ├── generate.xml │ ├── literal.xml │ ├── make_expr.xml │ ├── matches.xml │ ├── operators.xml │ ├── proto.xml │ ├── proto_fwd.xml │ ├── proto_typeof.xml │ ├── repeat.xml │ ├── tags.xml │ ├── traits.xml │ ├── transform.xml │ └── transform │ │ ├── arg.xml │ │ ├── call.xml │ │ ├── default.xml │ │ ├── env.xml │ │ ├── fold.xml │ │ ├── fold_tree.xml │ │ ├── impl.xml │ │ ├── integral_c.xml │ │ ├── lazy.xml │ │ ├── make.xml │ │ ├── pass_through.xml │ │ └── when.xml ├── release_notes.qbk └── resources.qbk ├── example ├── Jamfile.v2 ├── calc1.cpp ├── calc2.cpp ├── calc3.cpp ├── external_transforms.cpp ├── futures.cpp ├── hello.cpp ├── lambda.cpp ├── lambda.hpp ├── lazy_vector.cpp ├── map_assign.cpp ├── mini_lambda.cpp ├── mixed.cpp ├── rgb.cpp ├── tarray.cpp ├── vec3.cpp ├── vector.cpp └── virtual_member.cpp ├── include └── boost │ └── proto │ ├── args.hpp │ ├── context.hpp │ ├── context │ ├── callable.hpp │ ├── default.hpp │ ├── detail │ │ ├── callable_eval.hpp │ │ ├── default_eval.hpp │ │ ├── null_eval.hpp │ │ └── preprocessed │ │ │ ├── callable_eval.hpp │ │ │ ├── default_eval.hpp │ │ │ └── null_eval.hpp │ └── null.hpp │ ├── core.hpp │ ├── debug.hpp │ ├── deep_copy.hpp │ ├── detail │ ├── and_n.hpp │ ├── any.hpp │ ├── args.hpp │ ├── as_expr.hpp │ ├── as_lvalue.hpp │ ├── basic_expr.hpp │ ├── class_member_traits.hpp │ ├── decltype.hpp │ ├── deduce_domain.hpp │ ├── deduce_domain_n.hpp │ ├── deep_copy.hpp │ ├── deprecated.hpp │ ├── dont_care.hpp │ ├── expr.hpp │ ├── expr_funop.hpp │ ├── extends_funop.hpp │ ├── extends_funop_const.hpp │ ├── funop.hpp │ ├── generate_by_value.hpp │ ├── ignore_unused.hpp │ ├── is_noncopyable.hpp │ ├── lambda_matches.hpp │ ├── local.hpp │ ├── make_expr.hpp │ ├── make_expr_.hpp │ ├── make_expr_funop.hpp │ ├── matches_.hpp │ ├── memfun_funop.hpp │ ├── or_n.hpp │ ├── poly_function.hpp │ ├── poly_function_funop.hpp │ ├── poly_function_traits.hpp │ ├── preprocessed │ │ ├── and_n.hpp │ │ ├── args.hpp │ │ ├── basic_expr.hpp │ │ ├── class_member_traits.hpp │ │ ├── deduce_domain_n.hpp │ │ ├── deep_copy.hpp │ │ ├── expr.hpp │ │ ├── expr_variadic.hpp │ │ ├── extends_funop.hpp │ │ ├── extends_funop_const.hpp │ │ ├── funop.hpp │ │ ├── generate_by_value.hpp │ │ ├── lambda_matches.hpp │ │ ├── make_expr.hpp │ │ ├── make_expr_.hpp │ │ ├── make_expr_funop.hpp │ │ ├── matches_.hpp │ │ ├── memfun_funop.hpp │ │ ├── or_n.hpp │ │ ├── poly_function_funop.hpp │ │ ├── poly_function_traits.hpp │ │ ├── template_arity_helper.hpp │ │ ├── traits.hpp │ │ ├── unpack_expr_.hpp │ │ └── vararg_matches_impl.hpp │ ├── remove_typename.hpp │ ├── static_const.hpp │ ├── template_arity.hpp │ ├── template_arity_helper.hpp │ ├── traits.hpp │ ├── unpack_expr_.hpp │ └── vararg_matches_impl.hpp │ ├── domain.hpp │ ├── eval.hpp │ ├── expr.hpp │ ├── extends.hpp │ ├── functional.hpp │ ├── functional │ ├── fusion.hpp │ ├── fusion │ │ ├── at.hpp │ │ ├── pop_back.hpp │ │ ├── pop_front.hpp │ │ ├── push_back.hpp │ │ ├── push_front.hpp │ │ └── reverse.hpp │ ├── range.hpp │ ├── range │ │ ├── begin.hpp │ │ ├── empty.hpp │ │ ├── end.hpp │ │ ├── rbegin.hpp │ │ ├── rend.hpp │ │ └── size.hpp │ ├── std.hpp │ └── std │ │ ├── iterator.hpp │ │ └── utility.hpp │ ├── fusion.hpp │ ├── generate.hpp │ ├── literal.hpp │ ├── make_expr.hpp │ ├── matches.hpp │ ├── operators.hpp │ ├── proto.hpp │ ├── proto_fwd.hpp │ ├── proto_typeof.hpp │ ├── repeat.hpp │ ├── tags.hpp │ ├── traits.hpp │ ├── transform.hpp │ └── transform │ ├── arg.hpp │ ├── call.hpp │ ├── default.hpp │ ├── detail │ ├── call.hpp │ ├── construct_funop.hpp │ ├── construct_pod_funop.hpp │ ├── default_function_impl.hpp │ ├── expand_pack.hpp │ ├── fold_impl.hpp │ ├── lazy.hpp │ ├── make.hpp │ ├── make_gcc_workaround.hpp │ ├── pack.hpp │ ├── pack_impl.hpp │ ├── pass_through_impl.hpp │ ├── preprocessed │ │ ├── call.hpp │ │ ├── construct_funop.hpp │ │ ├── construct_pod_funop.hpp │ │ ├── default_function_impl.hpp │ │ ├── expand_pack.hpp │ │ ├── fold_impl.hpp │ │ ├── lazy.hpp │ │ ├── make.hpp │ │ ├── make_gcc_workaround.hpp │ │ ├── pack_impl.hpp │ │ ├── pass_through_impl.hpp │ │ └── when.hpp │ └── when.hpp │ ├── env.hpp │ ├── fold.hpp │ ├── fold_tree.hpp │ ├── impl.hpp │ ├── integral_c.hpp │ ├── lazy.hpp │ ├── make.hpp │ ├── pass_through.hpp │ └── when.hpp ├── index.html ├── meta └── libraries.json ├── preprocess ├── Jamfile.v2 ├── preprocess_proto.cpp └── wave.cfg └── test ├── Jamfile.v2 ├── bug2407.cpp ├── calculator.cpp ├── constrained_ops.cpp ├── cpp-next_bug.cpp ├── deduce_domain.cpp ├── deep_copy.cpp ├── display_expr.cpp ├── env_var.cpp ├── examples.cpp ├── external_transforms.cpp ├── flatten.cpp ├── lambda.cpp ├── make.cpp ├── make_expr.cpp ├── matches.cpp ├── mem_ptr.cpp ├── mpl.cpp ├── noinvoke.cpp ├── pack_expansion.cpp ├── protect.cpp ├── switch.cpp ├── toy_spirit.cpp └── toy_spirit2.cpp /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Generated by `boostdep --cmake proto` 2 | # Copyright 2020 Peter Dimov 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # https://www.boost.org/LICENSE_1_0.txt 5 | 6 | cmake_minimum_required(VERSION 3.5...3.16) 7 | 8 | project(boost_proto VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) 9 | 10 | add_library(boost_proto INTERFACE) 11 | add_library(Boost::proto ALIAS boost_proto) 12 | 13 | target_include_directories(boost_proto INTERFACE include) 14 | 15 | target_link_libraries(boost_proto 16 | INTERFACE 17 | Boost::config 18 | Boost::core 19 | Boost::fusion 20 | Boost::mpl 21 | Boost::preprocessor 22 | Boost::range 23 | Boost::static_assert 24 | Boost::type_traits 25 | Boost::typeof 26 | Boost::utility 27 | ) 28 | 29 | if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") 30 | 31 | add_subdirectory(test) 32 | 33 | endif() 34 | 35 | -------------------------------------------------------------------------------- /build.jam: -------------------------------------------------------------------------------- 1 | # Copyright René Ferdinand Rivera Morell 2023-2024 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | require-b2 5.2 ; 7 | 8 | constant boost_dependencies : 9 | /boost/config//boost_config 10 | /boost/core//boost_core 11 | /boost/fusion//boost_fusion 12 | /boost/mpl//boost_mpl 13 | /boost/preprocessor//boost_preprocessor 14 | /boost/range//boost_range 15 | /boost/static_assert//boost_static_assert 16 | /boost/type_traits//boost_type_traits 17 | /boost/typeof//boost_typeof 18 | /boost/utility//boost_utility ; 19 | 20 | project /boost/proto 21 | ; 22 | 23 | explicit 24 | [ alias boost_proto : : : 25 | : include $(boost_dependencies) ] 26 | [ alias all : boost_proto example test ] 27 | ; 28 | 29 | call-if : boost-library proto 30 | ; 31 | -------------------------------------------------------------------------------- /doc/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # Copyright Eric Niebler 2007. Use, modification, and distribution are 2 | # subject to the Boost Software License, Version 1.0. (See accompanying 3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | import os ; 6 | import path ; 7 | import quickbook ; 8 | import boostbook ; 9 | 10 | local admon-graphics-path = [ path.join [ boostbook.docbook-xsl-dir ] images ] ; 11 | local callout-graphics-path = [ path.join $(admon-graphics-path) callouts ] ; 12 | 13 | admon-graphics-path = [ path.native $(admon-graphics-path)/ ] ; 14 | callout-graphics-path = [ path.native $(callout-graphics-path)/ ] ; 15 | 16 | if [ os.name ] = CYGWIN 17 | { 18 | admon-graphics-path = $(admon-graphics-path:W) ; 19 | callout-graphics-path = $(callout-graphics-path:W) ; 20 | 21 | admon-graphics-path = $(admon-graphics-path:T) ; 22 | callout-graphics-path = $(callout-graphics-path:T) ; 23 | } 24 | 25 | xml proto 26 | : 27 | proto.qbk 28 | ; 29 | 30 | boostbook standalone 31 | : 32 | proto 33 | : 34 | boost.root=../../../.. 35 | # HTML options first: 36 | # Use graphics not text for navigation: 37 | navig.graphics=1 38 | # How far down we chunk nested sections, basically all of them: 39 | chunk.section.depth=10 40 | # Don't put the first section on the same page as the TOC: 41 | chunk.first.sections=1 42 | # How far down sections get TOC's 43 | toc.section.depth=10 44 | # Max depth in each TOC: 45 | toc.max.depth=4 46 | # How far down we go with TOC's 47 | generate.section.toc.level=10 48 | # Set the path to the boost-root so we find our graphics: 49 | #boost.root=$(BOOST_ROOT) 50 | # location of the main index file so our links work: 51 | #boost.libraries=$(BOOST_ROOT)/libs/libraries.htm 52 | 53 | # PDF Options: 54 | # TOC Generation: this is needed for FOP-0.9 and later: 55 | # fop1.extensions=1 56 | pdf:fop1.extensions=0 57 | pdf:xep.extensions=1 58 | # TOC generation: this is needed for FOP 0.2, but must not be set to zero for FOP-0.9! 59 | pdf:fop.extensions=0 60 | # No indent on body text: 61 | pdf:body.start.indent=0pt 62 | # Margin size: 63 | pdf:page.margin.inner=0.5in 64 | # Margin size: 65 | pdf:page.margin.outer=0.5in 66 | # Yes, we want graphics for admonishments: 67 | pdf:admon.graphics=1 68 | # Set this one for PDF generation *only*: 69 | # default png graphics are awful in PDF form, 70 | # better use SVG's instead: 71 | #pdf:admon.graphics.extension=".svg" 72 | #pdf:admon.graphics.path="$(admon-graphics-path)" 73 | #pdf:callout.graphics.path="$(callout-graphics-path)" 74 | pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html 75 | ; 76 | 77 | ############################################################################### 78 | alias boostdoc 79 | : proto 80 | : 81 | : 82 | : ; 83 | explicit boostdoc ; 84 | alias boostrelease ; 85 | explicit boostrelease ; 86 | -------------------------------------------------------------------------------- /doc/acknowledgements.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | / Copyright (c) 2008 Eric Niebler 3 | / 4 | / Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | /] 7 | 8 | [section:acknowledgements Appendix E: Acknowledgements] 9 | 10 | I'd like to thank Joel de Guzman and Hartmut Kaiser for being willing to take a chance on using Proto for their work on Spirit-2 and Karma when Proto was little more than a vision. Their requirements and feedback have been indespensable. 11 | 12 | Thanks also to Thomas Heller and again to Hartmut for their feedback and suggestions during the redesign of Phoenix. That effort yielded several valuable advanced features such as sub-domains, external transforms, and per-domain `as_child` customization. 13 | 14 | Thanks to Daniel James for providing a patch to remove the dependence on deprecated configuration macros for C++0x features. 15 | 16 | Thanks to Joel Falcou and Christophe Henry for their enthusiasm, support, feedback, and humor; and for volunteering to be Proto's co-maintainers. 17 | 18 | Thanks to Dave Abrahams for an especially detailed review, and for making a VM with msvc-7.1 available so I could track down portability issues on that compiler. 19 | 20 | Many thanks to Daniel Wallin who first implemented the code used to find the common domain among a set, accounting for super- and sub-domains. Thanks also to Jeremiah Willcock, John Bytheway and Krishna Achuthan who offered alternate solutions to this tricky programming problem. 21 | 22 | Thanks also to the developers of _PETE_. I found many good ideas there. 23 | 24 | [endsect] 25 | -------------------------------------------------------------------------------- /doc/conventions.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | / Copyright (c) 2008 Eric Niebler 3 | / 4 | / Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | /] 7 | 8 | [/================================] 9 | [section:naming Naming Conventions] 10 | [/================================] 11 | 12 | Proto is a large library and probably quite unlike any library you've used 13 | before. Proto uses some consistent naming conventions to make it easier to 14 | navigate, and they're described below. 15 | 16 | [/================] 17 | [heading Functions] 18 | [/================] 19 | 20 | All of Proto's functions are defined in the `boost::proto` namespace. For 21 | example, there is a function called `value()` defined in `boost::proto` that 22 | accepts a terminal expression and returns the terminal's value. 23 | 24 | [/====================] 25 | [heading Metafunctions] 26 | [/====================] 27 | 28 | Proto defines /metafunctions/ that correspond to each of Proto's free functions. 29 | The metafunctions are used to compute the functions' return types. All of 30 | Proto's metafunctions live in the `boost::proto::result_of` namespace and 31 | have the same name as the functions to which they correspond. For instance, 32 | there is a class template `boost::proto::result_of::value<>` that you can 33 | use to compute the return type of the `boost::proto::value()` function. 34 | 35 | [/=======================] 36 | [heading Function Objects] 37 | [/=======================] 38 | 39 | Proto defines /function object/ equivalents of all of its free functions. (A 40 | function object is an instance of a class type that defines an `operator()` 41 | member function.) All of Proto's function object types are defined in the 42 | `boost::proto::functional` namespace and have the same name as their 43 | corresponding free functions. For example, `boost::proto::functional::value` 44 | is a class that defines a function object that does the same thing as the 45 | `boost::proto::value()` free function. 46 | 47 | [/===========================] 48 | [heading Primitive Transforms] 49 | [/===========================] 50 | 51 | Proto also defines /primitive transforms/ -- class types that can be used 52 | to compose larger transforms for manipulating expression trees. Many of 53 | Proto's free functions have corresponding primitive transforms. These live 54 | in the `boost::proto` namespace and their names have a leading underscore. 55 | For instance, the transform corresponding to the `value()` function is 56 | called `boost::proto::_value`. 57 | 58 | The following table summarizes the discussion above: 59 | 60 | [table Proto Naming Conventions 61 | [[Entity] [Example] ] 62 | [[Free Function] [`boost::proto::value()`] ] 63 | [[Metafunction] [`boost::proto::result_of::value<>`] ] 64 | [[Function Object] [`boost::proto::functional::value`] ] 65 | [[Transform] [`boost::proto::_value`] ] 66 | ] 67 | 68 | [endsect] 69 | 70 | -------------------------------------------------------------------------------- /doc/getting_started.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | / Copyright (c) 2008 Eric Niebler 3 | / 4 | / Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | /] 7 | 8 | [section:getting_started Getting Started] 9 | 10 | [include installation.qbk] 11 | 12 | [include conventions.qbk] 13 | 14 | [include hello_world.qbk] 15 | 16 | [include calculator.qbk] 17 | 18 | [endsect] 19 | -------------------------------------------------------------------------------- /doc/history.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | / Copyright (c) 2008 Eric Niebler 3 | / 4 | / Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | /] 7 | 8 | [section:history Appendix B: History] 9 | 10 | [variablelist 11 | [ 12 | [August 13, 2010] 13 | [Boost 1.44: Proto gets sub-domains and per-domain control of _as_expr_ 14 | and _as_child_ to meet the needs of Phoenix3.] 15 | ] 16 | [ 17 | [August 11, 2008] 18 | [Proto v4 is merged to Boost trunk with more powerful transform protocol.] 19 | ] 20 | [ 21 | [April 7, 2008] 22 | [Proto is accepted into Boost.] 23 | ] 24 | [ 25 | [March 1, 2008] 26 | [Proto's Boost review begins.] 27 | ] 28 | [ 29 | [January 11, 2008] 30 | [Boost.Proto v3 brings separation of grammars and transforms and a 31 | "round" lambda syntax for defining transforms in-place.] 32 | ] 33 | [ 34 | [April 15, 2007] 35 | [Boost.Xpressive is ported from Proto compilers to Proto transforms. 36 | Support for old Proto compilers is dropped.] 37 | ] 38 | [ 39 | [April 4, 2007] 40 | [Preliminary submission of Proto to Boost.] 41 | ] 42 | [ 43 | [December 11, 2006] 44 | [The idea for transforms that decorate grammar rules is born in a private 45 | email discussion with Joel de Guzman and Hartmut Kaiser. The first 46 | transforms are committed to CVS 5 days later on December 16.] 47 | ] 48 | [ 49 | [November 1, 2006] 50 | [The idea for `proto::matches<>` and the whole grammar facility is 51 | hatched during a discussion with Hartmut Kaiser on the spirit-devel list. 52 | The first version of `proto::matches<>` is checked into CVS 3 days later. 53 | Message is [@http://osdir.com/ml/parsers.spirit.devel/2006-11/msg00003.html here].] 54 | ] 55 | [ 56 | [October 28, 2006] 57 | [Proto is reborn, this time with a uniform expression types that are POD. 58 | Announcement is [@http://lists.boost.org/Archives/boost/2006/10/112453.php here].] 59 | ] 60 | [ 61 | [April 20, 2005] 62 | [Proto is born as a major refactorization of Boost.Xpressive's 63 | meta-programming. Proto offers expression types, operator overloads and 64 | "compilers", an early formulation of what later became transforms. 65 | Announcement is [@http://lists.boost.org/Archives/boost/2005/04/85256.php here].] 66 | ] 67 | ] 68 | 69 | [endsect] 70 | -------------------------------------------------------------------------------- /doc/installation.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | / Copyright (c) 2008 Eric Niebler 3 | / 4 | / Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | /] 7 | 8 | [/=======================] 9 | [section Installing Proto] 10 | [/=======================] 11 | 12 | [/====================] 13 | [heading Getting Proto] 14 | [/====================] 15 | 16 | You can get Proto 17 | by downloading Boost (Proto is in version 1.37 and later), 18 | or by accessing Boost's SVN repository on SourceForge.net. Just go to 19 | [@http://svn.boost.org/trac/boost/wiki/BoostSubversion] 20 | and follow the instructions there for anonymous SVN access. 21 | 22 | [/==========================] 23 | [heading Building with Proto] 24 | [/==========================] 25 | 26 | Proto is a header-only template library, which means you don't need to alter 27 | your build scripts or link to any separate lib file to use it. All you need 28 | to do is `#include `. Or, you might decide to just 29 | include the core of Proto (`#include `) and whichever 30 | contexts and transforms you happen to use. 31 | 32 | [/===================] 33 | [heading Requirements] 34 | [/===================] 35 | 36 | Proto depends on Boost. You must use either Boost version 1.34.1 or higher, 37 | or the version in SVN trunk. 38 | 39 | [/==========================] 40 | [heading Supported Compilers] 41 | [/==========================] 42 | 43 | Currently, Boost.Proto is known to work on the following compilers: 44 | 45 | * Visual C++ 8 and higher 46 | * GNU C++ 3.4 and higher 47 | * Intel on Linux 8.1 and higher 48 | * Intel on Windows 9.1 and higher 49 | 50 | [note Please send any questions, comments and bug reports to eric boostpro com.] 51 | 52 | [endsect] 53 | -------------------------------------------------------------------------------- /doc/propdocs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright 2012 Eric Niebler 4 | # 5 | # Distributed under the Boost Software License, Version 1.0. 6 | # (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | rsync --delete --rsh=ssh --recursive -p html/* eric_niebler,boost-sandbox@web.sourceforge.net:/home/groups/b/bo/boost-sandbox/htdocs/libs/proto/doc/html 9 | 10 | rsync --delete --rsh=ssh --recursive -p src/* eric_niebler,boost-sandbox@web.sourceforge.net:/home/groups/b/bo/boost-sandbox/htdocs/libs/proto/doc/src 11 | -------------------------------------------------------------------------------- /doc/rationale.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | / Copyright (c) 2008 Eric Niebler 3 | / 4 | / Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | /] 7 | 8 | [section:rationale Appendix C: Rationale] 9 | 10 | [/==================================================] 11 | [section:static_initialization Static Initialization] 12 | [/==================================================] 13 | 14 | Proto expression types are PODs (Plain Old Data), and do not have constructors. They are brace-initialized, as follows: 15 | 16 | terminal::type const _i = {1}; 17 | 18 | The reason is so that expression objects like `_i` above can be ['statically 19 | initialized]. Why is static initialization important? The terminals of many embedded 20 | domain-specific languages are likely to be global const objects, like `_1` and 21 | `_2` from the Boost Lambda Library. Were these object to require run-time 22 | initialization, it might be possible to use these objects before they are 23 | initialized. That would be bad. Statically initialized objects cannot be misused 24 | that way. 25 | 26 | [endsect] 27 | 28 | [/=========================================================] 29 | [section:preprocessor Why Not Reuse MPL, Fusion, et cetera?] 30 | [/=========================================================] 31 | 32 | Anyone who has peeked at Proto's source code has probably wondered, "Why all the 33 | dirty preprocessor gunk? Couldn't this have been all implemented cleanly on top of 34 | libraries like MPL and Fusion?" The answer is that Proto could have been 35 | implemented this way, and in fact was at one point. The problem is that template 36 | metaprogramming (TMP) makes for longer compile times. As a foundation upon which 37 | other TMP-heavy libraries will be built, Proto itself should be as lightweight as 38 | possible. That is achieved by prefering preprocessor metaprogramming to template 39 | metaprogramming. Expanding a macro is far more efficient than instantiating a 40 | template. In some cases, the "clean" version takes 10x longer to compile than the 41 | "dirty" version. 42 | 43 | The "clean and slow" version of Proto can still be found at 44 | http://svn.boost.org/svn/boost/branches/proto/v3. Anyone who is interested can 45 | download it and verify that it is, in fact, unusably slow to compile. Note that 46 | this branch's development was abandoned, and it does not conform exactly with 47 | Proto's current interface. 48 | 49 | [endsect] 50 | 51 | [endsect] 52 | -------------------------------------------------------------------------------- /doc/reference/concepts/BasicPrimitiveTransform.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | The type must be a model of . 17 | 18 | 19 | 20 | 21 | A BasicPrimitiveTransform is class type that 22 | has a nested class template called impl that takes 23 | three template parameters representing an expression 24 | type, a state type and a data type. Specializations 25 | of the nested impl template are ternary monomorphic 26 | function objects that accept expression, state, and 27 | data parameters. 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | The return type of the overloaded function call operator. 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | Applies the transform. 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /doc/reference/concepts/CallableTransform.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | The type must be a model of . 18 | The type must be a model of . 19 | 20 | 21 | 22 | 23 | A CallableTransform is a function type or a function 24 | pointer type where the return type Fn is a 25 | PolymorphicFunctionObject and the arguments are 26 | Transforms. is_callable< Fn >::value 27 | must be true. The CallableTransform, when applied, 28 | has the effect of invoking the polymorphic function 29 | object Fn, passing as arguments the result(s) 30 | of applying transform(s) Tn. 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | The result of applying the CallableTransform. 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | Applies the transform. 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /doc/reference/concepts/PolymorphicFunctionObject.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | The type must be a model of . 14 | 15 | 16 | 17 | 18 | A type that can be called and that follows the TR1 ResultOf 19 | protocol for return type calculation. 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | The result of calling the Polymorphic Function Object. 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | Calls the function object. 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /doc/reference/concepts/Transform.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | The type must be a model of . 17 | 18 | 19 | 20 | 21 | A Transform is a PrimitiveTransform, a CallableTransform 22 | or an ObjectTransform. 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | The result of applying the Transform. 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | Applies the transform. 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /doc/reference/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes all the built-in evaluation contexts of Proto. 11 |
12 | -------------------------------------------------------------------------------- /doc/reference/context/null.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | 11 | Definintion of 12 | proto::context::null_context<>, 13 | an evaluation context for 14 | proto::eval() 15 | that simply evaluates each child expression, doesn't combine the results at all, and returns void. 16 | 17 | 18 | 19 | 20 | 21 | 25 | 26 | void 27 | 28 | 29 | 30 | void 31 | 32 | Expr & 33 | 34 | 35 | Context & 36 | 37 | 38 | 39 | For N in [0,Expr arity), 40 | evaluate: 41 | proto::eval(proto::child_c<N>(expr), context) 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | An evaluation context for proto::eval() that simply evaluates 50 | each child expression, doesn't combine the results at all, and returns void. 51 | 52 | 58 | proto::context::null_eval< Expr, ThisContext > 59 | 60 | 61 | 62 | 63 | 64 |
65 | -------------------------------------------------------------------------------- /doc/reference/core.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes all of Proto, except the contexts, transforms, debug utilities and Boost.Typeof registrations. 11 |
12 | -------------------------------------------------------------------------------- /doc/reference/functional.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes all the functional extensions of Proto. 11 |
12 | -------------------------------------------------------------------------------- /doc/reference/functional/fusion.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes all the functional extensions to Proto for the Boost.Fusion library. 11 |
12 | -------------------------------------------------------------------------------- /doc/reference/functional/fusion/push_back.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes Proto callable boost::proto::functional::push_back. 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | A PolymorphicFunctionObject type that invokes the 19 | fusion::push_back() algorithm on its arguments. 20 | 21 | 22 | A PolymorphicFunctionObject type that invokes the 23 | fusion::push_back() algorithm on its arguments. 24 | 25 | 26 | proto::callable 27 | 28 | 29 | 34 | 35 | This(Seq, T) 36 | 37 | 38 | fusion::result_of::push_back< 39 | typename boost::add_const<typename boost::remove_reference<Seq>::type>::type 40 | , typename boost::remove_const<typename boost::remove_reference<T>::type>::type 41 | > 42 | 43 | 44 | 45 | 46 | typename fusion::result_of::push_back< Seq const, T >::type 47 | 51 | 52 | Seq const & 53 | 54 | 55 | T const & 56 | 57 | 58 | fusion::push_back(seq, t) 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
68 | -------------------------------------------------------------------------------- /doc/reference/functional/fusion/push_front.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes Proto callable boost::proto::functional::push_front. 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | A PolymorphicFunctionObject type that invokes the 19 | fusion::push_front() algorithm on its arguments. 20 | 21 | 22 | A PolymorphicFunctionObject type that invokes the 23 | fusion::push_front() algorithm on its arguments. 24 | 25 | 26 | proto::callable 27 | 28 | 29 | 34 | 35 | This(Seq, T) 36 | 37 | 38 | fusion::result_of::push_front< 39 | typename boost::add_const<typename boost::remove_reference<Seq>::type>::type 40 | , typename boost::remove_const<typename boost::remove_reference<T>::type>::type 41 | > 42 | 43 | 44 | 45 | 46 | typename fusion::result_of::push_front< Seq const, T >::type 47 | 51 | 52 | Seq const & 53 | 54 | 55 | T const & 56 | 57 | 58 | fusion::push_front(seq, t) 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
68 | -------------------------------------------------------------------------------- /doc/reference/functional/range.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes all the functional extensions to Proto for the Boost.Range library. 11 |
12 | -------------------------------------------------------------------------------- /doc/reference/functional/range/begin.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes Proto callable boost::proto::functional::begin. 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | A PolymorphicFunctionObject type that invokes the 19 | boost::begin() accessor function on its arguments. 20 | 21 | 22 | A PolymorphicFunctionObject type that invokes the 23 | boost::begin() accessor function on its arguments. 24 | 25 | 26 | proto::callable 27 | 28 | 29 | 33 | 34 | This(Range) 35 | 36 | 37 | boost::range_iterator< 38 | typename boost::remove_reference<Range>::type 39 | > 40 | 41 | 42 | 43 | 44 | typename boost::range_iterator< Range >::type 45 | 48 | 49 | Range & 50 | 51 | 52 | boost::begin(rng) 53 | 54 | 55 | 56 | typename boost::range_iterator< Range const >::type 57 | 60 | 61 | Range const & 62 | 63 | 64 | boost::begin(rng) 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 |
74 | -------------------------------------------------------------------------------- /doc/reference/functional/range/empty.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes Proto callable boost::proto::functional::empty. 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | A PolymorphicFunctionObject type that invokes the 19 | boost::empty() function on its arguments. 20 | 21 | 22 | A PolymorphicFunctionObject type that invokes the 23 | boost::empty() function on its arguments. 24 | 25 | 26 | proto::callable 27 | 28 | 29 | bool 30 | 31 | 32 | 33 | bool 34 | 37 | 38 | Range const & 39 | 40 | 41 | boost::empty(rng) 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
51 | -------------------------------------------------------------------------------- /doc/reference/functional/range/end.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes Proto callable boost::proto::functional::end. 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | A PolymorphicFunctionObject type that invokes the 19 | boost::end() accessor function on its arguments. 20 | 21 | 22 | A PolymorphicFunctionObject type that invokes the 23 | boost::end() accessor function on its arguments. 24 | 25 | 26 | proto::callable 27 | 28 | 29 | 33 | 34 | This(Range) 35 | 36 | 37 | boost::range_iterator< 38 | typename boost::remove_reference<Range>::type 39 | > 40 | 41 | 42 | 43 | 44 | typename boost::range_iterator< Range >::type 45 | 48 | 49 | Range & 50 | 51 | 52 | boost::end(rng) 53 | 54 | 55 | 56 | typename boost::range_iterator< Range const >::type 57 | 60 | 61 | Range const & 62 | 63 | 64 | boost::end(rng) 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 |
74 | -------------------------------------------------------------------------------- /doc/reference/functional/range/rbegin.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes Proto callable boost::proto::functional::rbegin. 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | A PolymorphicFunctionObject type that invokes the 19 | boost::rbegin() accessor function on its arguments. 20 | 21 | 22 | A PolymorphicFunctionObject type that invokes the 23 | boost::rbegin() accessor function on its arguments. 24 | 25 | 26 | proto::callable 27 | 28 | 29 | 33 | 34 | This(Range) 35 | 36 | 37 | boost::range_reverse_iterator< 38 | typename boost::remove_reference<Range>::type 39 | > 40 | 41 | 42 | 43 | 44 | typename boost::range_reverse_iterator< Range >::type 45 | 48 | 49 | Range & 50 | 51 | 52 | boost::rbegin(rng) 53 | 54 | 55 | 56 | typename boost::range_reverse_iterator< Range const >::type 57 | 60 | 61 | Range const & 62 | 63 | 64 | boost::rbegin(rng) 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 |
74 | -------------------------------------------------------------------------------- /doc/reference/functional/range/rend.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes Proto callable boost::proto::functional::rend. 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | A PolymorphicFunctionObject type that invokes the 19 | boost::rend() accessor function on its arguments. 20 | 21 | 22 | A PolymorphicFunctionObject type that invokes the 23 | boost::rend() accessor function on its arguments. 24 | 25 | 26 | proto::callable 27 | 28 | 29 | 33 | 34 | This(Range) 35 | 36 | 37 | boost::range_reverse_iterator< 38 | typename boost::remove_reference<Range>::type 39 | > 40 | 41 | 42 | 43 | 44 | typename boost::range_reverse_iterator< Range >::type 45 | 48 | 49 | Range & 50 | 51 | 52 | boost::rend(rng) 53 | 54 | 55 | 56 | typename boost::range_reverse_iterator< Range const >::type 57 | 60 | 61 | Range const & 62 | 63 | 64 | boost::rend(rng) 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 |
74 | -------------------------------------------------------------------------------- /doc/reference/functional/range/size.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes Proto callable boost::proto::functional::size. 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | A PolymorphicFunctionObject type that invokes the 19 | boost::size() function on its arguments. 20 | 21 | 22 | A PolymorphicFunctionObject type that invokes the 23 | boost::size() function on its arguments. 24 | 25 | 26 | proto::callable 27 | 28 | 29 | 33 | 34 | This(Range) 35 | 36 | 37 | boost::range_size< 38 | typename boost::remove_reference<Range>::type 39 | > 40 | 41 | 42 | 43 | 44 | typename boost::range_size< Range const >::type 45 | 48 | 49 | Range const & 50 | 51 | 52 | boost::size(rng) 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 | -------------------------------------------------------------------------------- /doc/reference/functional/std.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes all the functional extensions to Proto for the standard library. 11 |
12 | -------------------------------------------------------------------------------- /doc/reference/proto.xml: -------------------------------------------------------------------------------- 1 |  2 | 9 |
10 | Includes all of Proto, except the Boost.Typeof registrations. 11 |
12 | -------------------------------------------------------------------------------- /doc/reference/proto_typeof.xml: -------------------------------------------------------------------------------- 1 |  2 | 9 |
10 | Boost.Typeof registrations for Proto's types, and definition of the 11 | BOOST_PROTO_AUTO() macro. 12 | 13 | 14 | 15 | For defining a local variable that stores a Proto expression template, 16 | deep-copying the expression so there are no dangling references. 17 | 18 | 19 | To define a local variable ex that stores the expression 20 | proto::lit(1) + 2, 21 | do the following:BOOST_PROTO_AUTO( ex, proto::lit(1) + 2 );. 22 | The above is equivalent to the following: 23 | BOOST_AUTO( ex, proto::deep_copy( proto::lit(1) + 2 ) ); 24 | 25 | 26 | 27 |
28 | -------------------------------------------------------------------------------- /doc/reference/transform.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 |
10 | Includes all the built-in transforms of Proto. 11 |
12 | -------------------------------------------------------------------------------- /doc/resources.qbk: -------------------------------------------------------------------------------- 1 | [/ 2 | / Copyright (c) 2008 Eric Niebler 3 | / 4 | / Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | /] 7 | 8 | [/=========================================] 9 | [section:resources Background and Resources] 10 | [/=========================================] 11 | 12 | Proto was initially developed as part of _xpressive_ to simplify the job of 13 | transforming an expression template into an executable finite state machine capable 14 | of matching a regular expression. Since then, Proto has found application in the 15 | redesigned and improved Spirit-2 and the related Karma library. As a result of 16 | these efforts, Proto evolved into a generic and abstract grammar and tree 17 | transformation framework applicable in a wide variety of EDSL scenarios. 18 | 19 | The grammar and tree transformation framework is modeled on Spirit's grammar and 20 | semantic action framework. The expression tree data structure is similar to Fusion 21 | data structures in many respects, and is interoperable with Fusion's iterators and 22 | algorithms. 23 | 24 | The syntax for the grammar-matching features of `proto::matches<>` is inspired by 25 | MPL's lambda expressions. 26 | 27 | The idea for using function types for Proto's composite transforms is inspired by Aleksey Gurtovoy's 28 | [@http://lists.boost.org/Archives/boost/2002/11/39718.php "round" lambda] notation. 29 | 30 | [/=================] 31 | [heading References] 32 | [/=================] 33 | 34 | [:[#boost_proto.users_guide.resources.SYB]Ren, D. and Erwig, M. 2006. A generic recursion toolbox for Haskell or: scrap your boilerplate systematically. In ['Proceedings of the 2006 ACM SIGPLAN Workshop on Haskell] (Portland, Oregon, USA, September 17 - 17, 2006). Haskell '06. ACM, New York, NY, 13-24. DOI=[@http://doi.acm.org/10.1145/1159842.1159845]] 35 | 36 | [/======================] 37 | [heading Further Reading] 38 | [/======================] 39 | 40 | A technical paper about an earlier version of Proto was accepted into the 41 | [@http://lcsd.cs.tamu.edu/2007/ ACM SIGPLAN Symposium on Library-Centric Software 42 | Design LCSD'07], and can be found at [@http://lcsd.cs.tamu.edu/2007/final/1/1_Paper.pdf]. 43 | The tree transforms described in that paper differ from what exists today. 44 | 45 | [endsect] 46 | -------------------------------------------------------------------------------- /example/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2004: Eric Niebler 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | project : requirements /boost/proto//boost_proto ; 6 | 7 | exe hello 8 | : 9 | hello.cpp 10 | ; 11 | 12 | 13 | exe calc1 14 | : 15 | calc1.cpp 16 | ; 17 | 18 | exe calc2 19 | : 20 | calc2.cpp 21 | ; 22 | 23 | exe calc3 24 | : 25 | calc3.cpp 26 | ; 27 | 28 | exe lazy_vector 29 | : 30 | lazy_vector.cpp 31 | ; 32 | 33 | exe tarray 34 | : 35 | tarray.cpp 36 | ; 37 | 38 | exe rgb 39 | : 40 | rgb.cpp 41 | ; 42 | 43 | exe vec3 44 | : 45 | vec3.cpp 46 | ; 47 | 48 | exe vector 49 | : 50 | vector.cpp 51 | ; 52 | 53 | exe mixed 54 | : 55 | mixed.cpp 56 | ; 57 | 58 | exe futures 59 | : 60 | futures.cpp 61 | ; 62 | 63 | exe map_assign 64 | : 65 | map_assign.cpp 66 | ; 67 | 68 | exe mini_lambda 69 | : 70 | mini_lambda.cpp 71 | ; 72 | 73 | exe virtual_member 74 | : 75 | virtual_member.cpp 76 | ; 77 | 78 | exe external_transforms 79 | : 80 | external_transforms.cpp 81 | ; 82 | 83 | exe lambda 84 | : 85 | lambda.cpp 86 | : 87 | . 88 | clang:-Wno-unused-local-typedef 89 | ; 90 | -------------------------------------------------------------------------------- /example/calc1.cpp: -------------------------------------------------------------------------------- 1 | //[ Calc1 2 | // Copyright 2008 Eric Niebler. Distributed under the Boost 3 | // Software License, Version 1.0. (See accompanying file 4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | // 6 | // This is a simple example of how to build an arithmetic expression 7 | // evaluator with placeholders. 8 | 9 | #include 10 | #include 11 | #include 12 | namespace proto = boost::proto; 13 | using proto::_; 14 | 15 | template struct placeholder {}; 16 | 17 | // Define some placeholders 18 | proto::terminal< placeholder< 1 > >::type const _1 = {{}}; 19 | proto::terminal< placeholder< 2 > >::type const _2 = {{}}; 20 | 21 | // Define a calculator context, for evaluating arithmetic expressions 22 | struct calculator_context 23 | : proto::callable_context< calculator_context const > 24 | { 25 | // The values bound to the placeholders 26 | double d[2]; 27 | 28 | // The result of evaluating arithmetic expressions 29 | typedef double result_type; 30 | 31 | explicit calculator_context(double d1 = 0., double d2 = 0.) 32 | { 33 | d[0] = d1; 34 | d[1] = d2; 35 | } 36 | 37 | // Handle the evaluation of the placeholder terminals 38 | template 39 | double operator ()(proto::tag::terminal, placeholder) const 40 | { 41 | return d[ I - 1 ]; 42 | } 43 | }; 44 | 45 | template 46 | double evaluate( Expr const &expr, double d1 = 0., double d2 = 0. ) 47 | { 48 | // Create a calculator context with d1 and d2 substituted for _1 and _2 49 | calculator_context const ctx(d1, d2); 50 | 51 | // Evaluate the calculator expression with the calculator_context 52 | return proto::eval(expr, ctx); 53 | } 54 | 55 | int main() 56 | { 57 | // Displays "5" 58 | std::cout << evaluate( _1 + 2.0, 3.0 ) << std::endl; 59 | 60 | // Displays "6" 61 | std::cout << evaluate( _1 * _2, 3.0, 2.0 ) << std::endl; 62 | 63 | // Displays "0.5" 64 | std::cout << evaluate( (_1 - _2) / _2, 3.0, 2.0 ) << std::endl; 65 | 66 | return 0; 67 | } 68 | //] 69 | -------------------------------------------------------------------------------- /example/calc2.cpp: -------------------------------------------------------------------------------- 1 | //[ Calc2 2 | // Copyright 2008 Eric Niebler. Distributed under the Boost 3 | // Software License, Version 1.0. (See accompanying file 4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | // 6 | // This example enhances the simple arithmetic expression evaluator 7 | // in calc1.cpp by using proto::extends to make arithmetic 8 | // expressions immediately evaluable with operator (), a-la a 9 | // function object 10 | 11 | #include 12 | #include 13 | #include 14 | namespace proto = boost::proto; 15 | using proto::_; 16 | 17 | template 18 | struct calculator_expression; 19 | 20 | // Tell proto how to generate expressions in the calculator_domain 21 | struct calculator_domain 22 | : proto::domain > 23 | {}; 24 | 25 | // Will be used to define the placeholders _1 and _2 26 | template struct placeholder {}; 27 | 28 | // Define a calculator context, for evaluating arithmetic expressions 29 | // (This is as before, in calc1.cpp) 30 | struct calculator_context 31 | : proto::callable_context< calculator_context const > 32 | { 33 | // The values bound to the placeholders 34 | double d[2]; 35 | 36 | // The result of evaluating arithmetic expressions 37 | typedef double result_type; 38 | 39 | explicit calculator_context(double d1 = 0., double d2 = 0.) 40 | { 41 | d[0] = d1; 42 | d[1] = d2; 43 | } 44 | 45 | // Handle the evaluation of the placeholder terminals 46 | template 47 | double operator ()(proto::tag::terminal, placeholder) const 48 | { 49 | return d[ I - 1 ]; 50 | } 51 | }; 52 | 53 | // Wrap all calculator expressions in this type, which defines 54 | // operator () to evaluate the expression. 55 | template 56 | struct calculator_expression 57 | : proto::extends, calculator_domain> 58 | { 59 | explicit calculator_expression(Expr const &expr = Expr()) 60 | : calculator_expression::proto_extends(expr) 61 | {} 62 | 63 | BOOST_PROTO_EXTENDS_USING_ASSIGN(calculator_expression) 64 | 65 | // Override operator () to evaluate the expression 66 | double operator ()() const 67 | { 68 | calculator_context const ctx; 69 | return proto::eval(*this, ctx); 70 | } 71 | 72 | double operator ()(double d1) const 73 | { 74 | calculator_context const ctx(d1); 75 | return proto::eval(*this, ctx); 76 | } 77 | 78 | double operator ()(double d1, double d2) const 79 | { 80 | calculator_context const ctx(d1, d2); 81 | return proto::eval(*this, ctx); 82 | } 83 | }; 84 | 85 | // Define some placeholders (notice they're wrapped in calculator_expression<>) 86 | calculator_expression >::type> const _1; 87 | calculator_expression >::type> const _2; 88 | 89 | // Now, our arithmetic expressions are immediately executable function objects: 90 | int main() 91 | { 92 | // Displays "5" 93 | std::cout << (_1 + 2.0)( 3.0 ) << std::endl; 94 | 95 | // Displays "6" 96 | std::cout << ( _1 * _2 )( 3.0, 2.0 ) << std::endl; 97 | 98 | // Displays "0.5" 99 | std::cout << ( (_1 - _2) / _2 )( 3.0, 2.0 ) << std::endl; 100 | 101 | return 0; 102 | } 103 | //] 104 | -------------------------------------------------------------------------------- /example/hello.cpp: -------------------------------------------------------------------------------- 1 | //[ HelloWorld 2 | //////////////////////////////////////////////////////////////////// 3 | // Copyright 2008 Eric Niebler. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include 8 | #include 9 | #include 10 | // This #include is only needed for compilers that use typeof emulation: 11 | #include 12 | namespace proto = boost::proto; 13 | 14 | proto::terminal< std::ostream & >::type cout_ = {std::cout}; 15 | 16 | template< typename Expr > 17 | void evaluate( Expr const & expr ) 18 | { 19 | proto::default_context ctx; 20 | proto::eval(expr, ctx); 21 | } 22 | 23 | int main() 24 | { 25 | evaluate( cout_ << "hello" << ',' << " world" ); 26 | return 0; 27 | } 28 | //] 29 | -------------------------------------------------------------------------------- /example/lambda.cpp: -------------------------------------------------------------------------------- 1 | //[ Lambda 2 | /////////////////////////////////////////////////////////////////////////////// 3 | // Copyright 2008 Eric Niebler. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // This example builds a simple but functional lambda library using Proto. 8 | 9 | #include 10 | #include "./lambda.hpp" 11 | 12 | int main() 13 | { 14 | using namespace boost::lambda; 15 | int i = (_1 + _1)(42); 16 | std::cout << i << std::endl; 17 | } 18 | -------------------------------------------------------------------------------- /example/rgb.cpp: -------------------------------------------------------------------------------- 1 | //[ RGB 2 | /////////////////////////////////////////////////////////////////////////////// 3 | // Copyright 2008 Eric Niebler. Distributed under the Boost 4 | // Software License, Version 1.0. (See accompanying file 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // This is a simple example of doing arbitrary type manipulations with proto 8 | // transforms. It takes some expression involving primary colors and combines 9 | // the colors according to arbitrary rules. It is a port of the RGB example 10 | // from PETE (http://www.codesourcery.com/pooma/download.html). 11 | 12 | #include 13 | #include 14 | #include 15 | namespace proto = boost::proto; 16 | 17 | struct RedTag 18 | { 19 | friend std::ostream &operator <<(std::ostream &sout, RedTag) 20 | { 21 | return sout << "This expression is red."; 22 | } 23 | }; 24 | 25 | struct BlueTag 26 | { 27 | friend std::ostream &operator <<(std::ostream &sout, BlueTag) 28 | { 29 | return sout << "This expression is blue."; 30 | } 31 | }; 32 | 33 | struct GreenTag 34 | { 35 | friend std::ostream &operator <<(std::ostream &sout, GreenTag) 36 | { 37 | return sout << "This expression is green."; 38 | } 39 | }; 40 | 41 | typedef proto::terminal::type RedT; 42 | typedef proto::terminal::type BlueT; 43 | typedef proto::terminal::type GreenT; 44 | 45 | struct Red; 46 | struct Blue; 47 | struct Green; 48 | 49 | /////////////////////////////////////////////////////////////////////////////// 50 | // A transform that produces new colors according to some arbitrary rules: 51 | // red & green give blue, red & blue give green, blue and green give red. 52 | struct Red 53 | : proto::or_< 54 | proto::plus 55 | , proto::plus 56 | , proto::plus 57 | , proto::terminal 58 | > 59 | {}; 60 | 61 | struct Green 62 | : proto::or_< 63 | proto::plus 64 | , proto::plus 65 | , proto::plus 66 | , proto::terminal 67 | > 68 | {}; 69 | 70 | struct Blue 71 | : proto::or_< 72 | proto::plus 73 | , proto::plus 74 | , proto::plus 75 | , proto::terminal 76 | > 77 | {}; 78 | 79 | struct RGB 80 | : proto::or_< 81 | proto::when< Red, RedTag() > 82 | , proto::when< Blue, BlueTag() > 83 | , proto::when< Green, GreenTag() > 84 | > 85 | {}; 86 | 87 | template 88 | void printColor(Expr const & expr) 89 | { 90 | int i = 0; // dummy state and data parameter, not used 91 | std::cout << RGB()(expr, i, i) << std::endl; 92 | } 93 | 94 | int main() 95 | { 96 | printColor(RedT() + GreenT()); 97 | printColor(RedT() + GreenT() + BlueT()); 98 | printColor(RedT() + (GreenT() + BlueT())); 99 | 100 | return 0; 101 | } 102 | //] 103 | -------------------------------------------------------------------------------- /include/boost/proto/context.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file context.hpp 3 | /// Includes all the context classes in the context/ sub-directory. 4 | // 5 | // Copyright 2008 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_CONTEXT_HPP_EAN_06_23_2007 10 | #define BOOST_PROTO_CONTEXT_HPP_EAN_06_23_2007 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /include/boost/proto/context/detail/default_eval.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #define BOOST_PROTO_DEFAULT_EVAL_SHIFTED(Z, M, DATA) \ 8 | BOOST_PROTO_DEFAULT_EVAL(Z, BOOST_PP_ADD(M, 2), DATA) \ 9 | /**/ 10 | 11 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 12 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/default_eval.hpp") 13 | #endif 14 | 15 | /////////////////////////////////////////////////////////////////////////////// 16 | /// \file default_eval.hpp 17 | /// Contains specializations of the default_eval\<\> class template. 18 | // 19 | // Copyright 2008 Eric Niebler. Distributed under the Boost 20 | // Software License, Version 1.0. (See accompanying file 21 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 22 | 23 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 24 | #pragma wave option(preserve: 1) 25 | #endif 26 | 27 | #define BOOST_PP_ITERATION_PARAMS_1 \ 28 | (3, (3, BOOST_PROTO_MAX_ARITY, )) 29 | #include BOOST_PP_ITERATE() 30 | 31 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 32 | #pragma wave option(output: null) 33 | #endif 34 | 35 | #undef BOOST_PROTO_DEFAULT_EVAL_SHIFTED 36 | 37 | #else 38 | 39 | #define N BOOST_PP_ITERATION() 40 | 41 | template 42 | struct default_eval 43 | { 44 | typedef 45 | typename proto::detail::result_of_fixup< 46 | BOOST_PROTO_DEFAULT_EVAL_TYPE(~, 0, Expr) 47 | >::type 48 | function_type; 49 | 50 | typedef 51 | typename BOOST_PROTO_RESULT_OF< 52 | function_type(BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_DEFAULT_EVAL_TYPE, Expr)) 53 | >::type 54 | result_type; 55 | 56 | result_type operator ()(Expr &expr, Context &context) const 57 | { 58 | return this->invoke(expr, context, is_member_function_pointer()); 59 | } 60 | 61 | private: 62 | result_type invoke(Expr &expr, Context &context, mpl::false_) const 63 | { 64 | return BOOST_PROTO_DEFAULT_EVAL(~, 0, expr)( 65 | BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_DEFAULT_EVAL, expr) 66 | ); 67 | } 68 | 69 | result_type invoke(Expr &expr, Context &context, mpl::true_) const 70 | { 71 | BOOST_PROTO_USE_GET_POINTER(); 72 | typedef typename detail::class_member_traits::class_type class_type; 73 | return ( 74 | BOOST_PROTO_GET_POINTER(class_type, (BOOST_PROTO_DEFAULT_EVAL(~, 1, expr))) ->* 75 | BOOST_PROTO_DEFAULT_EVAL(~, 0, expr) 76 | )(BOOST_PP_ENUM(BOOST_PP_SUB(N, 2), BOOST_PROTO_DEFAULT_EVAL_SHIFTED, expr)); 77 | } 78 | }; 79 | 80 | #undef N 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /include/boost/proto/context/detail/null_eval.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #define BOOST_PROTO_EVAL_N(Z, N, DATA) \ 8 | proto::eval(proto::child_c(expr), ctx); \ 9 | /**/ 10 | 11 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 12 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/null_eval.hpp") 13 | #endif 14 | 15 | /////////////////////////////////////////////////////////////////////////////// 16 | /// \file null_eval.hpp 17 | /// Contains specializations of the null_eval\<\> class template. 18 | // 19 | // Copyright 2008 Eric Niebler. Distributed under the Boost 20 | // Software License, Version 1.0. (See accompanying file 21 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 22 | 23 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 24 | #pragma wave option(preserve: 1) 25 | #endif 26 | 27 | #define BOOST_PP_ITERATION_PARAMS_1 \ 28 | (3, (1, BOOST_PROTO_MAX_ARITY, )) 29 | #include BOOST_PP_ITERATE() 30 | 31 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 32 | #pragma wave option(output: null) 33 | #endif 34 | 35 | #undef BOOST_PROTO_EVAL_N 36 | 37 | #else 38 | 39 | #define N BOOST_PP_ITERATION() 40 | 41 | template 42 | struct null_eval 43 | { 44 | typedef void result_type; 45 | 46 | void operator ()(Expr &expr, Context &ctx) const 47 | { 48 | BOOST_PP_REPEAT(N, BOOST_PROTO_EVAL_N, ~) 49 | } 50 | }; 51 | 52 | #undef N 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/boost/proto/context/null.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file null.hpp 3 | /// Definintion of null_context\<\>, an evaluation context for 4 | /// proto::eval() that simply evaluates each child expression, doesn't 5 | /// combine the results at all, and returns void. 6 | // 7 | // Copyright 2008 Eric Niebler. Distributed under the Boost 8 | // Software License, Version 1.0. (See accompanying file 9 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 10 | 11 | #ifndef BOOST_PROTO_CONTEXT_NULL_HPP_EAN_06_24_2007 12 | #define BOOST_PROTO_CONTEXT_NULL_HPP_EAN_06_24_2007 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace boost { namespace proto { namespace context 21 | { 22 | 23 | template< 24 | typename Expr 25 | , typename Context 26 | , long Arity // = Expr::proto_arity_c 27 | > 28 | struct null_eval 29 | {}; 30 | 31 | template 32 | struct null_eval 33 | { 34 | typedef void result_type; 35 | void operator()(Expr &, Context &) const 36 | {} 37 | }; 38 | 39 | // Additional specializations generated by the preprocessor 40 | #include 41 | 42 | /// null_context 43 | /// 44 | struct null_context 45 | { 46 | /// null_context::eval 47 | /// 48 | template 49 | struct eval 50 | : null_eval 51 | {}; 52 | }; 53 | 54 | }}} 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /include/boost/proto/core.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file core.hpp 3 | /// Includes the core of Proto. Not included are the contexts, transforms and 4 | /// debugging utilities. 5 | // 6 | // Copyright 2008 Eric Niebler. Distributed under the Boost 7 | // Software License, Version 1.0. (See accompanying file 8 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #ifndef BOOST_PROTO_CORE_HPP_EAN_04_01_2005 11 | #define BOOST_PROTO_CORE_HPP_EAN_04_01_2005 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/boost/proto/detail/any.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file any.hpp 3 | /// Contains definition the detail::any type 4 | // 5 | // Copyright 2012 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_DETAIL_ANY_HPP_EAN_18_07_2012 10 | #define BOOST_PROTO_DETAIL_ANY_HPP_EAN_18_07_2012 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace boost { namespace proto 18 | { 19 | namespace detail 20 | { 21 | namespace anyns 22 | { 23 | //////////////////////////////////////////////////////////////////////////////////////////// 24 | struct any 25 | { 26 | template any(T const &) {} 27 | any operator[](any); 28 | #define M0(Z, N, DATA) any operator()(BOOST_PP_ENUM_PARAMS_Z(Z, N, any BOOST_PP_INTERCEPT)); 29 | BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, M0, ~) 30 | #undef M0 31 | 32 | template 33 | operator T &() const volatile; 34 | 35 | any operator+(); 36 | any operator-(); 37 | any operator*(); 38 | any operator&(); 39 | any operator~(); 40 | any operator!(); 41 | any operator++(); 42 | any operator--(); 43 | any operator++(int); 44 | any operator--(int); 45 | 46 | friend any operator<<(any, any); 47 | friend any operator>>(any, any); 48 | friend any operator*(any, any); 49 | friend any operator/(any, any); 50 | friend any operator%(any, any); 51 | friend any operator+(any, any); 52 | friend any operator-(any, any); 53 | friend any operator<(any, any); 54 | friend any operator>(any, any); 55 | friend any operator<=(any, any); 56 | friend any operator>=(any, any); 57 | friend any operator==(any, any); 58 | friend any operator!=(any, any); 59 | friend any operator||(any, any); 60 | friend any operator&&(any, any); 61 | friend any operator&(any, any); 62 | friend any operator|(any, any); 63 | friend any operator^(any, any); 64 | friend any operator,(any, any); 65 | friend any operator->*(any, any); 66 | 67 | friend any operator<<=(any, any); 68 | friend any operator>>=(any, any); 69 | friend any operator*=(any, any); 70 | friend any operator/=(any, any); 71 | friend any operator%=(any, any); 72 | friend any operator+=(any, any); 73 | friend any operator-=(any, any); 74 | friend any operator&=(any, any); 75 | friend any operator|=(any, any); 76 | friend any operator^=(any, any); 77 | }; 78 | } 79 | 80 | using anyns::any; 81 | } 82 | }} 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /include/boost/proto/detail/args.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | /// INTERNAL ONLY 8 | /// 9 | #define BOOST_PROTO_DEFINE_CHILD_N(Z, N, DATA) \ 10 | typedef BOOST_PP_CAT(Arg, N) BOOST_PP_CAT(child, N); \ 11 | /**< INTERNAL ONLY */ 12 | 13 | /// INTERNAL ONLY 14 | /// 15 | #define BOOST_PROTO_DEFINE_VOID_N(z, n, data) \ 16 | typedef mpl::void_ BOOST_PP_CAT(child, n); \ 17 | /**< INTERNAL ONLY */ 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/args.hpp") 21 | #endif 22 | 23 | /////////////////////////////////////////////////////////////////////////////// 24 | /// \file args.hpp 25 | /// Contains definition of \c term\<\>, \c list1\<\>, \c list2\<\>, ... 26 | /// class templates. 27 | // 28 | // Copyright 2008 Eric Niebler. Distributed under the Boost 29 | // Software License, Version 1.0. (See accompanying file 30 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 31 | 32 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 33 | #pragma wave option(preserve: 1) 34 | #endif 35 | 36 | /// \brief A type sequence, for use as the 2nd parameter to the \c expr\<\> class template. 37 | /// 38 | /// A type sequence, for use as the 2nd parameter to the \c expr\<\> class template. 39 | /// The types in the sequence correspond to the children of a node in an expression tree. 40 | template< typename Arg0 > 41 | struct term 42 | { 43 | static const long arity = 0; 44 | typedef Arg0 child0; 45 | BOOST_PP_REPEAT_FROM_TO(1, BOOST_PROTO_MAX_ARITY, BOOST_PROTO_DEFINE_VOID_N, ~) 46 | 47 | /// INTERNAL ONLY 48 | /// 49 | typedef Arg0 back_; 50 | }; 51 | 52 | #define BOOST_PP_ITERATION_PARAMS_1 \ 53 | (3, (1, BOOST_PROTO_MAX_ARITY, )) 54 | #include BOOST_PP_ITERATE() 55 | 56 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 57 | #pragma wave option(output: null) 58 | #endif 59 | 60 | #undef BOOST_PROTO_DEFINE_VOID_N 61 | #undef BOOST_PROTO_DEFINE_CHILD_N 62 | 63 | #else 64 | 65 | #define N BOOST_PP_ITERATION() 66 | 67 | /// \brief A type sequence, for use as the 2nd parameter to the \c expr\<\> class template. 68 | /// 69 | /// A type sequence, for use as the 2nd parameter to the \c expr\<\> class template. 70 | /// The types in the sequence correspond to the children of a node in an expression tree. 71 | template< BOOST_PP_ENUM_PARAMS(N, typename Arg) > 72 | struct BOOST_PP_CAT(list, N) 73 | { 74 | static const long arity = N; 75 | BOOST_PP_REPEAT(N, BOOST_PROTO_DEFINE_CHILD_N, ~) 76 | BOOST_PP_REPEAT_FROM_TO(N, BOOST_PROTO_MAX_ARITY, BOOST_PROTO_DEFINE_VOID_N, ~) 77 | 78 | /// INTERNAL ONLY 79 | /// 80 | typedef BOOST_PP_CAT(Arg, BOOST_PP_DEC(N)) back_; 81 | }; 82 | 83 | #undef N 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /include/boost/proto/detail/as_lvalue.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file as_lvalue.hpp 3 | /// Contains definition the as_lvalue() functions. 4 | // 5 | // Copyright 2008 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_TRANSFORM_AS_LVALUE_HPP_EAN_12_27_2007 10 | #define BOOST_PROTO_TRANSFORM_AS_LVALUE_HPP_EAN_12_27_2007 11 | 12 | #include 13 | 14 | #if defined(_MSC_VER) 15 | # pragma warning(push) 16 | # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined 17 | #endif 18 | 19 | namespace boost { namespace proto 20 | { 21 | namespace detail 22 | { 23 | template 24 | BOOST_FORCEINLINE 25 | T &as_lvalue(T &t) 26 | { 27 | return t; 28 | } 29 | 30 | template 31 | BOOST_FORCEINLINE 32 | T const &as_lvalue(T const &t) 33 | { 34 | return t; 35 | } 36 | } 37 | }} 38 | 39 | #if defined(_MSC_VER) 40 | # pragma warning(pop) 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /include/boost/proto/detail/class_member_traits.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/class_member_traits.hpp") 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | // class_member_traits.hpp 13 | // Contains specializations of the class_member_traits\<\> class template. 14 | // 15 | // Copyright 2008 Eric Niebler. Distributed under the Boost 16 | // Software License, Version 1.0. (See accompanying file 17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 1) 21 | #endif 22 | 23 | #define BOOST_PP_ITERATION_PARAMS_1 \ 24 | (3, (0, BOOST_PROTO_MAX_ARITY, )) 25 | #include BOOST_PP_ITERATE() 26 | 27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 28 | #pragma wave option(output: null) 29 | #endif 30 | 31 | #else 32 | 33 | #define N BOOST_PP_ITERATION() 34 | 35 | template 36 | struct class_member_traits 37 | { 38 | typedef U class_type; 39 | typedef T result_type; 40 | }; 41 | 42 | template 43 | struct class_member_traits 44 | { 45 | typedef U class_type; 46 | typedef T result_type; 47 | }; 48 | 49 | #undef N 50 | 51 | #endif // BOOST_PROTO_DONT_USE_PREPROCESSED_FILES 52 | -------------------------------------------------------------------------------- /include/boost/proto/detail/deduce_domain_n.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #define BOOST_PROTO_COMMON_DOMAIN2(Z, N, DATA) \ 8 | typedef \ 9 | typename common_domain2::type \ 10 | BOOST_PP_CAT(common, BOOST_PP_INC(N)); \ 11 | /**/ 12 | 13 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 14 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/deduce_domain_n.hpp") 15 | #endif 16 | 17 | /////////////////////////////////////////////////////////////////////////////// 18 | // deduce_domain_n.hpp 19 | // Definitions of common_domain[n] and deduce_domain[n] class templates. 20 | // 21 | // Copyright 2008 Eric Niebler. Distributed under the Boost 22 | // Software License, Version 1.0. (See accompanying file 23 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 24 | 25 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 26 | #pragma wave option(preserve: 1) 27 | #endif 28 | 29 | #define BOOST_PP_ITERATION_PARAMS_1 \ 30 | (3, (3, BOOST_PROTO_MAX_ARITY, )) 31 | #include BOOST_PP_ITERATE() 32 | 33 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 34 | #pragma wave option(output: null) 35 | #endif 36 | 37 | #undef BOOST_PROTO_COMMON_DOMAIN2 38 | 39 | #else 40 | 41 | #define N BOOST_PP_ITERATION() 42 | 43 | template 44 | struct BOOST_PP_CAT(common_domain, N) 45 | { 46 | typedef A0 common1; 47 | BOOST_PP_REPEAT_FROM_TO(1, N, BOOST_PROTO_COMMON_DOMAIN2, ~) 48 | typedef BOOST_PP_CAT(common, N) type; 49 | BOOST_PROTO_ASSERT_VALID_DOMAIN(type); 50 | }; 51 | 52 | template 53 | struct BOOST_PP_CAT(deduce_domain, N) 54 | : BOOST_PP_CAT(common_domain, N)< 55 | BOOST_PP_ENUM_BINARY_PARAMS( 56 | N 57 | , typename domain_of::type BOOST_PP_INTERCEPT 58 | ) 59 | > 60 | {}; 61 | 62 | #undef N 63 | 64 | #endif // BOOST_PROTO_DONT_USE_PREPROCESSED_FILES 65 | -------------------------------------------------------------------------------- /include/boost/proto/detail/deep_copy.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #define BOOST_PROTO_DEFINE_DEEP_COPY_TYPE(Z, N, DATA) \ 8 | typename deep_copy_impl< \ 9 | typename remove_reference< \ 10 | typename Expr::BOOST_PP_CAT(proto_child, N) \ 11 | >::type::proto_derived_expr \ 12 | >::result_type \ 13 | /**/ 14 | 15 | #define BOOST_PROTO_DEFINE_DEEP_COPY_FUN(Z, N, DATA) \ 16 | proto::deep_copy(e.proto_base().BOOST_PP_CAT(child, N)) \ 17 | /**/ 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/deep_copy.hpp") 21 | #endif 22 | 23 | /////////////////////////////////////////////////////////////////////////////// 24 | /// \file deep_copy.hpp 25 | /// Replace all nodes stored by reference by nodes stored by value. 26 | // 27 | // Copyright 2008 Eric Niebler. Distributed under the Boost 28 | // Software License, Version 1.0. (See accompanying file 29 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 30 | 31 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 32 | #pragma wave option(preserve: 1) 33 | #endif 34 | 35 | #define BOOST_PP_ITERATION_PARAMS_1 \ 36 | (3, (1, BOOST_PROTO_MAX_ARITY, )) 37 | #include BOOST_PP_ITERATE() 38 | 39 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 40 | #pragma wave option(output: null) 41 | #endif 42 | 43 | #undef BOOST_PROTO_DEFINE_DEEP_COPY_FUN 44 | #undef BOOST_PROTO_DEFINE_DEEP_COPY_TYPE 45 | 46 | #else 47 | 48 | #define N BOOST_PP_ITERATION() 49 | 50 | template 51 | struct deep_copy_impl 52 | { 53 | typedef 54 | typename base_expr< 55 | typename Expr::proto_domain 56 | , typename Expr::proto_tag 57 | , BOOST_PP_CAT(list, N)< 58 | BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_DEEP_COPY_TYPE, ~) 59 | > 60 | >::type 61 | expr_type; 62 | 63 | typedef typename Expr::proto_generator proto_generator; 64 | typedef typename proto_generator::template result::type result_type; 65 | 66 | template 67 | result_type operator()(Expr2 const &e, S const &, D const &) const 68 | { 69 | expr_type const that = { 70 | BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_DEEP_COPY_FUN, ~) 71 | }; 72 | 73 | return proto_generator()(that); 74 | } 75 | }; 76 | 77 | #undef N 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /include/boost/proto/detail/dont_care.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file dont_care.hpp 3 | /// Definintion of dont_care, a dummy parameter 4 | // 5 | // Copyright 2008 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_DETAIL_DONT_CARE_HPP_EAN_11_07_2007 10 | #define BOOST_PROTO_DETAIL_DONT_CARE_HPP_EAN_11_07_2007 11 | 12 | #include 13 | 14 | #if defined(_MSC_VER) 15 | # pragma warning(push) 16 | # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined 17 | #endif 18 | 19 | namespace boost { namespace proto 20 | { 21 | namespace detail 22 | { 23 | struct dont_care 24 | { 25 | BOOST_FORCEINLINE dont_care(...); 26 | }; 27 | } 28 | }} 29 | 30 | #if defined(_MSC_VER) 31 | # pragma warning(pop) 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/boost/proto/detail/expr_funop.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // expr1.hpp 3 | // Contains definition of expr\<\>::operator() overloads. 4 | // 5 | // Copyright 2008 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #define N BOOST_PP_ITERATION() 10 | 11 | /// \overload 12 | /// 13 | template 14 | BOOST_FORCEINLINE 15 | typename result_of::BOOST_PP_CAT(funop, N)< 16 | expr const 17 | , default_domain BOOST_PP_ENUM_TRAILING_PARAMS(N, const A) 18 | >::type const 19 | operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const &a)) const 20 | { 21 | return result_of::BOOST_PP_CAT(funop, N)< 22 | expr const 23 | , default_domain BOOST_PP_ENUM_TRAILING_PARAMS(N, const A) 24 | >::call(*this BOOST_PP_ENUM_TRAILING_PARAMS(N, a)); 25 | } 26 | 27 | #ifdef BOOST_PROTO_DEFINE_TERMINAL 28 | /// \overload 29 | /// 30 | template 31 | BOOST_FORCEINLINE 32 | typename result_of::BOOST_PP_CAT(funop, N)< 33 | expr 34 | , default_domain BOOST_PP_ENUM_TRAILING_PARAMS(N, const A) 35 | >::type const 36 | operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const &a)) 37 | { 38 | return result_of::BOOST_PP_CAT(funop, N)< 39 | expr 40 | , default_domain BOOST_PP_ENUM_TRAILING_PARAMS(N, const A) 41 | >::call(*this BOOST_PP_ENUM_TRAILING_PARAMS(N, a)); 42 | } 43 | #endif 44 | 45 | #undef N 46 | -------------------------------------------------------------------------------- /include/boost/proto/detail/extends_funop.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES 4 | BOOST_PROTO_EXTENDS_FUNCTION_() 5 | BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(BOOST_PP_EMPTY) 6 | BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(BOOST_PROTO_CONST) 7 | #else 8 | #include 9 | #endif 10 | 11 | #else 12 | 13 | #define BOOST_PP_LOCAL_MACRO(N) \ 14 | BOOST_PROTO_DEFINE_FUN_OP(1, N, ~) \ 15 | /**/ 16 | 17 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) && !defined(BOOST_PROTO_NO_WAVE_OUTPUT) 18 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/extends_funop.hpp") 19 | #endif 20 | 21 | /////////////////////////////////////////////////////////////////////////////// 22 | /// \file extends_funop.hpp 23 | /// Definitions for extends\<\>::operator() 24 | // 25 | // Copyright 2008 Eric Niebler. Distributed under the Boost 26 | // Software License, Version 1.0. (See accompanying file 27 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 28 | 29 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) && !defined(BOOST_PROTO_NO_WAVE_OUTPUT) 30 | #pragma wave option(preserve: 1) 31 | #endif 32 | 33 | BOOST_PROTO_EXTENDS_FUNCTION_() 34 | 35 | #define BOOST_PP_LOCAL_LIMITS \ 36 | (0, BOOST_PP_DEC(BOOST_PROTO_MAX_FUNCTION_CALL_ARITY)) 37 | #include BOOST_PP_LOCAL_ITERATE() 38 | 39 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) && !defined(BOOST_PROTO_NO_WAVE_OUTPUT) 40 | #pragma wave option(output: null) 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /include/boost/proto/detail/extends_funop_const.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES 4 | BOOST_PROTO_EXTENDS_FUNCTION_() 5 | BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(BOOST_PROTO_CONST) 6 | #else 7 | #include 8 | #endif 9 | 10 | #else 11 | 12 | #define BOOST_PP_LOCAL_MACRO(N) \ 13 | BOOST_PROTO_DEFINE_FUN_OP_CONST(1, N, ~) \ 14 | /**/ 15 | 16 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 17 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/extends_funop_const.hpp") 18 | #endif 19 | 20 | /////////////////////////////////////////////////////////////////////////////// 21 | /// \file extends_funop_const.hpp 22 | /// Definitions for extends\<\>::operator() 23 | // 24 | // Copyright 2008 Eric Niebler. Distributed under the Boost 25 | // Software License, Version 1.0. (See accompanying file 26 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 27 | 28 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 29 | #pragma wave option(preserve: 1) 30 | #endif 31 | 32 | BOOST_PROTO_EXTENDS_FUNCTION_() 33 | 34 | #define BOOST_PP_LOCAL_LIMITS \ 35 | (0, BOOST_PP_DEC(BOOST_PROTO_MAX_FUNCTION_CALL_ARITY)) 36 | #include BOOST_PP_LOCAL_ITERATE() 37 | 38 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 39 | #pragma wave option(output: null) 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/boost/proto/detail/generate_by_value.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/generate_by_value.hpp") 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | /// \file generate_by_value.hpp 13 | /// Contains definition of by_value_generator_\<\> class template. 14 | // 15 | // Copyright 2008 Eric Niebler. Distributed under the Boost 16 | // Software License, Version 1.0. (See accompanying file 17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 1) 21 | #endif 22 | 23 | #define BOOST_PP_ITERATION_PARAMS_1 \ 24 | (3, (1, BOOST_PROTO_MAX_ARITY, )) 25 | #include BOOST_PP_ITERATE() 26 | 27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 28 | #pragma wave option(output: null) 29 | #endif 30 | 31 | #else // BOOST_PP_IS_ITERATING 32 | 33 | #define N BOOST_PP_ITERATION() 34 | 35 | template 36 | struct by_value_generator_< 37 | proto::expr, N> 38 | > 39 | { 40 | typedef 41 | BOOST_PP_CAT(list, N) 42 | src_args; 43 | 44 | typedef 45 | BOOST_PP_CAT(list, N)< 46 | BOOST_PP_ENUM_BINARY_PARAMS(N, typename uncvref::type BOOST_PP_INTERCEPT) 47 | > 48 | dst_args; 49 | 50 | typedef proto::expr src_type; 51 | typedef proto::expr type; 52 | 53 | BOOST_FORCEINLINE 54 | static type const call(src_type const &e) 55 | { 56 | type that = { 57 | BOOST_PP_ENUM_PARAMS(N, e.child) 58 | }; 59 | return that; 60 | } 61 | }; 62 | 63 | template 64 | struct by_value_generator_< 65 | proto::basic_expr, N> 66 | > 67 | { 68 | typedef 69 | BOOST_PP_CAT(list, N) 70 | src_args; 71 | 72 | typedef 73 | BOOST_PP_CAT(list, N)< 74 | BOOST_PP_ENUM_BINARY_PARAMS(N, typename uncvref::type BOOST_PP_INTERCEPT) 75 | > 76 | dst_args; 77 | 78 | typedef proto::basic_expr src_type; 79 | typedef proto::basic_expr type; 80 | 81 | BOOST_FORCEINLINE 82 | static type const call(src_type const &e) 83 | { 84 | type that = { 85 | BOOST_PP_ENUM_PARAMS(N, e.child) 86 | }; 87 | return that; 88 | } 89 | }; 90 | 91 | #undef N 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /include/boost/proto/detail/ignore_unused.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file ignore_unused.hpp 3 | /// Definintion of ignore_unused, a dummy function for suppressing compiler 4 | /// warnings 5 | // 6 | // Copyright 2008 Eric Niebler. Distributed under the Boost 7 | // Software License, Version 1.0. (See accompanying file 8 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #ifndef BOOST_PROTO_DETAIL_IGNORE_UNUSED_HPP_EAN_03_03_2008 11 | #define BOOST_PROTO_DETAIL_IGNORE_UNUSED_HPP_EAN_03_03_2008 12 | 13 | #include 14 | 15 | #if defined(_MSC_VER) 16 | # pragma warning(push) 17 | # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined 18 | #endif 19 | 20 | namespace boost { namespace proto 21 | { 22 | namespace detail 23 | { 24 | template 25 | BOOST_FORCEINLINE void ignore_unused(T const &) 26 | {} 27 | } 28 | }} 29 | 30 | #if defined(_MSC_VER) 31 | # pragma warning(pop) 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/boost/proto/detail/is_noncopyable.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file is_noncopyable.hpp 3 | /// Utility for detecting when types are non-copyable 4 | // 5 | // Copyright 2008 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_DETAIL_IS_NONCOPYABLE_HPP_EAN_19_07_2012 10 | #define BOOST_PROTO_DETAIL_IS_NONCOPYABLE_HPP_EAN_19_07_2012 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace boost { namespace proto { namespace detail 21 | { 22 | // All classes derived from std::ios_base have these public nested types, 23 | // and are non-copyable. This is an imperfect test, but it's the best we 24 | // we can do. 25 | template 26 | yes_type check_is_iostream( 27 | typename T::failure * 28 | , typename T::Init * 29 | , typename T::fmtflags * 30 | , typename T::iostate * 31 | , typename T::openmode * 32 | , typename T::seekdir * 33 | ); 34 | 35 | template 36 | no_type check_is_iostream(...); 37 | 38 | template 39 | struct is_iostream 40 | { 41 | static bool const value = sizeof(yes_type) == sizeof(check_is_iostream(0,0,0,0,0,0)); 42 | typedef mpl::bool_ type; 43 | }; 44 | 45 | /// INTERNAL ONLY 46 | // This should be a customization point. And it serves the same purpose 47 | // as the is_noncopyable trait in Boost.Foreach. 48 | template 49 | struct is_noncopyable 50 | : mpl::or_< 51 | is_function 52 | , is_abstract 53 | , is_iostream 54 | , is_base_of 55 | > 56 | {}; 57 | 58 | template 59 | struct is_noncopyable 60 | : mpl::true_ 61 | {}; 62 | 63 | }}} 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /include/boost/proto/detail/lambda_matches.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #define BOOST_PROTO_DEFINE_LAMBDA_MATCHES(Z, N, DATA) \ 8 | lambda_matches< \ 9 | BOOST_PP_CAT(Expr, N) \ 10 | , BOOST_PP_CAT(Grammar, N) \ 11 | > 12 | 13 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 14 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/lambda_matches.hpp") 15 | #endif 16 | 17 | /////////////////////////////////////////////////////////////////////////////// 18 | /// \file lambda_matches.hpp 19 | /// Specializations of the lambda_matches template 20 | // 21 | // Copyright 2008 Eric Niebler. Distributed under the Boost 22 | // Software License, Version 1.0. (See accompanying file 23 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 24 | 25 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 26 | #pragma wave option(preserve: 1) 27 | #endif 28 | 29 | #define BOOST_PP_ITERATION_PARAMS_1 \ 30 | (3, (2, BOOST_PROTO_MAX_ARITY, )) 31 | #include BOOST_PP_ITERATE() 32 | 33 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 34 | #pragma wave option(output: null) 35 | #endif 36 | 37 | #undef BOOST_PROTO_DEFINE_LAMBDA_MATCHES 38 | 39 | #else // BOOST_PP_IS_ITERATING 40 | 41 | #define N BOOST_PP_ITERATION() 42 | 43 | template< 44 | template class T 45 | BOOST_PP_ENUM_TRAILING_PARAMS(N, typename Expr) 46 | BOOST_PP_ENUM_TRAILING_PARAMS(N, typename Grammar) 47 | > 48 | struct lambda_matches< 49 | T 50 | , T 51 | BOOST_PROTO_TEMPLATE_ARITY_PARAM(N) 52 | > 53 | : BOOST_PP_CAT(and_, N)< 54 | BOOST_PROTO_DEFINE_LAMBDA_MATCHES(~, 0, ~)::value, 55 | BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_DEFINE_LAMBDA_MATCHES, ~) 56 | > 57 | {}; 58 | 59 | #undef N 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /include/boost/proto/detail/local.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file local.hpp 3 | /// Contains macros to ease the generation of repetitious code constructs 4 | // 5 | // Copyright 2008 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_LOCAL_MACRO 10 | # error "local iteration target macro is not defined" 11 | #endif 12 | 13 | #ifndef BOOST_PROTO_LOCAL_LIMITS 14 | # define BOOST_PROTO_LOCAL_LIMITS (1, BOOST_PROTO_MAX_ARITY) 15 | #endif 16 | 17 | #ifndef BOOST_PROTO_LOCAL_typename_A 18 | # define BOOST_PROTO_LOCAL_typename_A BOOST_PROTO_typename_A 19 | #endif 20 | 21 | #ifndef BOOST_PROTO_LOCAL_A 22 | # define BOOST_PROTO_LOCAL_A BOOST_PROTO_A_const_ref 23 | #endif 24 | 25 | #ifndef BOOST_PROTO_LOCAL_A_a 26 | # define BOOST_PROTO_LOCAL_A_a BOOST_PROTO_A_const_ref_a 27 | #endif 28 | 29 | #ifndef BOOST_PROTO_LOCAL_a 30 | # define BOOST_PROTO_LOCAL_a BOOST_PROTO_ref_a 31 | #endif 32 | 33 | #define BOOST_PP_LOCAL_LIMITS BOOST_PROTO_LOCAL_LIMITS 34 | 35 | #define BOOST_PP_LOCAL_MACRO(N) \ 36 | BOOST_PROTO_LOCAL_MACRO( \ 37 | N \ 38 | , BOOST_PROTO_LOCAL_typename_A \ 39 | , BOOST_PROTO_LOCAL_A \ 40 | , BOOST_PROTO_LOCAL_A_a \ 41 | , BOOST_PROTO_LOCAL_a \ 42 | ) \ 43 | /**/ 44 | 45 | #include BOOST_PP_LOCAL_ITERATE() 46 | 47 | #undef BOOST_PROTO_LOCAL_MACRO 48 | #undef BOOST_PROTO_LOCAL_LIMITS 49 | #undef BOOST_PROTO_LOCAL_typename_A 50 | #undef BOOST_PROTO_LOCAL_A 51 | #undef BOOST_PROTO_LOCAL_A_a 52 | #undef BOOST_PROTO_LOCAL_a 53 | -------------------------------------------------------------------------------- /include/boost/proto/detail/make_expr.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/make_expr.hpp") 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | /// \file make_expr.hpp 13 | /// Contains overloads of make_expr() free function. 14 | // 15 | // Copyright 2008 Eric Niebler. Distributed under the Boost 16 | // Software License, Version 1.0. (See accompanying file 17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 1) 21 | #endif 22 | 23 | #define BOOST_PP_ITERATION_PARAMS_1 \ 24 | (3, (2, BOOST_PROTO_MAX_ARITY, )) 25 | #include BOOST_PP_ITERATE() 26 | 27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 28 | #pragma wave option(output: null) 29 | #endif 30 | 31 | #else // BOOST_PP_IS_ITERATING 32 | 33 | #define N BOOST_PP_ITERATION() 34 | 35 | /// \overload 36 | /// 37 | template 38 | BOOST_FORCEINLINE 39 | typename lazy_disable_if< 40 | is_domain 41 | , result_of::make_expr< 42 | Tag 43 | BOOST_PP_ENUM_TRAILING_PARAMS(N, const A) 44 | > 45 | >::type const 46 | make_expr(BOOST_PP_ENUM_BINARY_PARAMS(N, const A, &a)) 47 | { 48 | return proto::detail::make_expr_< 49 | Tag 50 | , deduce_domain 51 | BOOST_PP_ENUM_TRAILING_PARAMS(N, const A) 52 | >()(BOOST_PP_ENUM_PARAMS(N, a)); 53 | } 54 | 55 | /// \overload 56 | /// 57 | template 58 | BOOST_FORCEINLINE 59 | typename result_of::make_expr< 60 | Tag 61 | , Domain 62 | BOOST_PP_ENUM_TRAILING_PARAMS(N, const C) 63 | >::type const 64 | make_expr(BOOST_PP_ENUM_BINARY_PARAMS(N, const C, &c)) 65 | { 66 | return proto::detail::make_expr_< 67 | Tag 68 | , Domain 69 | BOOST_PP_ENUM_TRAILING_PARAMS(N, const C) 70 | >()(BOOST_PP_ENUM_PARAMS(N, c)); 71 | } 72 | 73 | #undef N 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /include/boost/proto/detail/make_expr_funop.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/make_expr_funop.hpp") 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | /// \file make_expr_funop.hpp 13 | /// Contains definition of make_expr\<\>::operator() member functions. 14 | // 15 | // Copyright 2008 Eric Niebler. Distributed under the Boost 16 | // Software License, Version 1.0. (See accompanying file 17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 1) 21 | #endif 22 | 23 | #define BOOST_PP_ITERATION_PARAMS_1 \ 24 | (3, (2, BOOST_PROTO_MAX_ARITY, )) 25 | #include BOOST_PP_ITERATE() 26 | 27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 28 | #pragma wave option(output: null) 29 | #endif 30 | 31 | #else // BOOST_PP_IS_ITERATING 32 | 33 | #define N BOOST_PP_ITERATION() 34 | 35 | template 36 | struct result 37 | { 38 | typedef 39 | typename result_of::make_expr< 40 | Tag 41 | , Domain 42 | BOOST_PP_ENUM_TRAILING_PARAMS(N, A) 43 | >::type 44 | type; 45 | }; 46 | 47 | /// \overload 48 | /// 49 | template 50 | BOOST_FORCEINLINE 51 | typename result_of::make_expr< 52 | Tag 53 | , Domain 54 | BOOST_PP_ENUM_TRAILING_PARAMS(N, const A) 55 | >::type const 56 | operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, const A, &a)) const 57 | { 58 | return proto::detail::make_expr_< 59 | Tag 60 | , Domain 61 | BOOST_PP_ENUM_TRAILING_PARAMS(N, const A) 62 | >()(BOOST_PP_ENUM_PARAMS(N, a)); 63 | } 64 | 65 | #undef N 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /include/boost/proto/detail/memfun_funop.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/memfun_funop.hpp") 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | // memfun_funop.hpp 13 | // Contains overloads of memfun::operator(). 14 | // 15 | // Copyright 2008 Eric Niebler. Distributed under the Boost 16 | // Software License, Version 1.0. (See accompanying file 17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 1) 21 | #endif 22 | 23 | #define BOOST_PP_ITERATION_PARAMS_1 \ 24 | (3, (1, BOOST_PROTO_MAX_ARITY, )) 25 | #include BOOST_PP_ITERATE() 26 | 27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 28 | #pragma wave option(output: null) 29 | #endif 30 | 31 | #else 32 | 33 | #define N BOOST_PP_ITERATION() 34 | 35 | template 36 | BOOST_FORCEINLINE 37 | result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const &a)) const 38 | { 39 | BOOST_PROTO_USE_GET_POINTER(); 40 | return (BOOST_PROTO_GET_POINTER(V, obj) ->* pmf)(BOOST_PP_ENUM_PARAMS(N, a)); 41 | } 42 | 43 | #undef N 44 | 45 | #endif // BOOST_PROTO_DONT_USE_PREPROCESSED_FILES 46 | -------------------------------------------------------------------------------- /include/boost/proto/detail/or_n.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/or_n.hpp") 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | /// \file or_n.hpp 13 | /// Definitions of or_N 14 | // 15 | // Copyright 2008 Eric Niebler. Distributed under the Boost 16 | // Software License, Version 1.0. (See accompanying file 17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 1) 21 | #endif 22 | 23 | #define BOOST_PP_ITERATION_PARAMS_1 \ 24 | (3, (2, BOOST_PROTO_MAX_LOGICAL_ARITY, )) 25 | #include BOOST_PP_ITERATE() 26 | 27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 28 | #pragma wave option(output: null) 29 | #endif 30 | 31 | #else // BOOST_PP_IS_ITERATING 32 | 33 | #define N BOOST_PP_ITERATION() 34 | 35 | template 36 | struct BOOST_PP_CAT(or_, N) 37 | #if 2 == N 38 | : mpl::bool_::value> 39 | { 40 | typedef G1 which; 41 | }; 42 | #else 43 | : BOOST_PP_CAT(or_, BOOST_PP_DEC(N))< 44 | matches_::value 45 | , Expr, BasicExpr, BOOST_PP_ENUM_SHIFTED_PARAMS(N, G) 46 | > 47 | {}; 48 | #endif 49 | 50 | template 51 | struct BOOST_PP_CAT(or_, N) 52 | : mpl::true_ 53 | { 54 | typedef G0 which; 55 | }; 56 | 57 | #undef N 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /include/boost/proto/detail/poly_function_funop.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #define BOOST_PROTO_NORMALIZE_ARG(Z, N, DATA) \ 8 | static_cast \ 9 | ::reference>(BOOST_PP_CAT(a, N)) \ 10 | /**/ 11 | 12 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 13 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/poly_function_funop.hpp") 14 | #endif 15 | 16 | /////////////////////////////////////////////////////////////////////////////// 17 | // poly_function_funop.hpp 18 | // Contains overloads of poly_function\<\>::operator() 19 | // 20 | // Copyright 2008 Eric Niebler. Distributed under the Boost 21 | // Software License, Version 1.0. (See accompanying file 22 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 23 | 24 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 25 | #pragma wave option(preserve: 1) 26 | #endif 27 | 28 | #define BOOST_PP_ITERATION_PARAMS_1 \ 29 | (3, (1, BOOST_PROTO_MAX_ARITY, )) 30 | #include BOOST_PP_ITERATE() 31 | 32 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 33 | #pragma wave option(output: null) 34 | #endif 35 | 36 | #undef BOOST_PROTO_NORMALIZE_ARG 37 | 38 | #else 39 | 40 | #define N BOOST_PP_ITERATION() 41 | 42 | template 43 | struct result 44 | : Derived::template impl< 45 | BOOST_PP_ENUM_BINARY_PARAMS( 46 | N 47 | , typename normalize_arg::type BOOST_PP_INTERCEPT 49 | ) 50 | > 51 | { 52 | typedef typename result::result_type type; 53 | }; 54 | 55 | template 56 | typename result< 57 | Derived const( 58 | BOOST_PP_ENUM_BINARY_PARAMS(N, A, const & BOOST_PP_INTERCEPT) 59 | ) 60 | >::type 61 | operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const &a)) const 62 | { 63 | result< 64 | Derived const( 65 | BOOST_PP_ENUM_BINARY_PARAMS(N, A, const & BOOST_PP_INTERCEPT) 66 | ) 67 | > impl; 68 | 69 | return impl(BOOST_PP_ENUM(N, BOOST_PROTO_NORMALIZE_ARG, ~)); 70 | } 71 | 72 | #undef N 73 | 74 | #endif // BOOST_PROTO_DONT_USE_PREPROCESSED_FILES 75 | -------------------------------------------------------------------------------- /include/boost/proto/detail/poly_function_traits.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/poly_function_traits.hpp") 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | // poly_function_traits.hpp 13 | // Contains specializations of poly_function_traits and as_mono_function 14 | // 15 | // Copyright 2008 Eric Niebler. Distributed under the Boost 16 | // Software License, Version 1.0. (See accompanying file 17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 1) 21 | #endif 22 | 23 | #define BOOST_PP_ITERATION_PARAMS_1 \ 24 | (3, (1, BOOST_PROTO_MAX_ARITY, )) 25 | #include BOOST_PP_ITERATE() 26 | 27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 28 | #pragma wave option(output: null) 29 | #endif 30 | 31 | #else 32 | 33 | #define N BOOST_PP_ITERATION() 34 | 35 | //////////////////////////////////////////////////////////////////////////////////////////////// 36 | template 37 | struct poly_function_traits > 38 | { 39 | typedef typename PolyFun::template impl function_type; 40 | typedef typename function_type::result_type result_type; 41 | }; 42 | 43 | //////////////////////////////////////////////////////////////////////////////////////////////// 44 | template 45 | struct as_mono_function_impl 46 | { 47 | typedef typename PolyFun::template impl type; 48 | }; 49 | 50 | //////////////////////////////////////////////////////////////////////////////////////////////// 51 | template 52 | struct as_mono_function_impl 53 | { 54 | typedef PolyFun type; 55 | }; 56 | 57 | //////////////////////////////////////////////////////////////////////////////////////////////// 58 | template 59 | struct as_mono_function 60 | : as_mono_function_impl::value> 61 | {}; 62 | 63 | #undef N 64 | 65 | #endif // BOOST_PROTO_DONT_USE_PREPROCESSED_FILES 66 | -------------------------------------------------------------------------------- /include/boost/proto/detail/static_const.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file static_const.hpp 3 | /// Contains definition of static_const for declaring static constants that 4 | // 5 | // Copyright 2008 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_DETAIL_STATIC_CONST_HPP_EAN_20_07_2012 10 | #define BOOST_PROTO_DETAIL_STATIC_CONST_HPP_EAN_20_07_2012 11 | 12 | namespace boost { namespace proto 13 | { 14 | namespace detail 15 | { 16 | template 17 | struct static_const 18 | { 19 | static T const value; 20 | }; 21 | 22 | template 23 | T const static_const::value = {}; 24 | } 25 | }} 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/boost/proto/detail/template_arity.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file template_arity.hpp 3 | /// Replace all nodes stored by reference by nodes stored by value. 4 | // 5 | // Copyright 2011 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | // 9 | // This file is based on a similar one in MPL from Aleksey Gurtovoy. 10 | 11 | #ifndef BOOST_PROTO_DETAIL_TEMPLATE_ARITY_HPP_EAN_2011_05_07 12 | #define BOOST_PROTO_DETAIL_TEMPLATE_ARITY_HPP_EAN_2011_05_07 13 | 14 | // Somewhat indirect definition of BOOST_PROTO_TEMPLATE_ARITY_PARAM is 15 | // to overcome a shortcoming of the Wave tool used to generate the 16 | // pre-preprocessed headers. 17 | #define BOOST_PROTO_TEMPLATE_ARITY_PARAM BOOST_PROTO_TEMPLATE_ARITY_PARAM2 18 | #define BOOST_PROTO_TEMPLATE_ARITY_PARAM2(param) 19 | 20 | #if defined(BOOST_PROTO_EXTENDED_TEMPLATE_PARAMETERS_MATCHING) || \ 21 | (defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)) 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #undef BOOST_PROTO_TEMPLATE_ARITY_PARAM2 31 | #define BOOST_PROTO_TEMPLATE_ARITY_PARAM2(param) , param 32 | 33 | namespace boost { namespace proto { namespace detail 34 | { 35 | sized_type<1>::type template_arity_helper(...); 36 | 37 | // Other overloads generated by the preprocessor 38 | #include 39 | 40 | template 41 | struct template_arity_impl2 42 | : mpl::int_ 43 | {}; 44 | 45 | template 46 | struct template_arity 47 | : template_arity_impl2< 48 | F 49 | , N 50 | , sizeof(detail::template_arity_helper((F **)0, (mpl::int_ *)0)) 51 | > 52 | {}; 53 | 54 | template 55 | struct template_arity_impl2 56 | : template_arity 57 | {}; 58 | 59 | template 60 | struct template_arity_impl2 61 | : mpl::int_<-1> 62 | {}; 63 | 64 | }}} 65 | 66 | #endif // BOOST_PROTO_EXTENDED_TEMPLATE_PARAMETERS_MATCHING 67 | #endif // BOOST_PROTO_DETAIL_TEMPLATE_ARITY_HPP_EAN_2011_05_07 68 | -------------------------------------------------------------------------------- /include/boost/proto/detail/template_arity_helper.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/template_arity_helper.hpp") 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | // template_arity_helper.hpp 13 | // Overloads of template_arity_helper, used by the template_arity\<\> class template 14 | // 15 | // Copyright 2008 Eric Niebler. Distributed under the Boost 16 | // Software License, Version 1.0. (See accompanying file 17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 1) 21 | #endif 22 | 23 | #define BOOST_PP_ITERATION_PARAMS_1 \ 24 | (3, (1, BOOST_PROTO_MAX_ARITY, )) 25 | #include BOOST_PP_ITERATE() 26 | 27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 28 | #pragma wave option(output: null) 29 | #endif 30 | 31 | #else 32 | 33 | #define N BOOST_PP_ITERATION() 34 | 35 | template< 36 | template class F 37 | , BOOST_PP_ENUM_PARAMS(N, typename T) 38 | > 39 | sized_type::type 40 | template_arity_helper(F **, mpl::int_ *); 41 | 42 | #undef N 43 | 44 | #endif // BOOST_PROTO_DONT_USE_PREPROCESSED_FILES 45 | -------------------------------------------------------------------------------- /include/boost/proto/detail/vararg_matches_impl.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/vararg_matches_impl.hpp") 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | /// \file vararg_matches_impl.hpp 13 | /// Specializations of the vararg_matches_impl template 14 | // 15 | // Copyright 2008 Eric Niebler. Distributed under the Boost 16 | // Software License, Version 1.0. (See accompanying file 17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 1) 21 | #endif 22 | 23 | #define BOOST_PP_ITERATION_PARAMS_1 \ 24 | (3, (2, BOOST_PROTO_MAX_ARITY, )) 25 | #include BOOST_PP_ITERATE() 26 | 27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 28 | #pragma wave option(output: null) 29 | #endif 30 | 31 | #else // BOOST_PP_IS_ITERATING 32 | 33 | #define N BOOST_PP_ITERATION() 34 | 35 | template 36 | struct vararg_matches_impl 37 | : and_2< 38 | matches_< 39 | typename detail::expr_traits::value_type::proto_derived_expr 40 | , typename detail::expr_traits::value_type::proto_grammar 41 | , Back 42 | >::value 43 | , vararg_matches_impl 44 | > 45 | {}; 46 | 47 | template 48 | struct vararg_matches_impl 49 | : matches_< 50 | typename detail::expr_traits::value_type::proto_derived_expr 51 | , typename detail::expr_traits::value_type::proto_grammar 52 | , Back 53 | > 54 | {}; 55 | 56 | #undef N 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /include/boost/proto/functional.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file functional.hpp 3 | /// Proto callables for various things 4 | // 5 | // Copyright 2010 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_HPP_EAN_11_27_2010 10 | #define BOOST_PROTO_FUNCTIONAL_HPP_EAN_11_27_2010 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /include/boost/proto/functional/fusion.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file fusion.hpp 3 | /// Proto callables for things found in the Fusion library 4 | // 5 | // Copyright 2010 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_FUSION_HPP_EAN_11_27_2010 10 | #define BOOST_PROTO_FUNCTIONAL_FUSION_HPP_EAN_11_27_2010 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/boost/proto/functional/fusion/at.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file at.hpp 3 | /// Proto callables Fusion at 4 | // 5 | // Copyright 2010 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_FUSION_AT_HPP_EAN_11_27_2010 10 | #define BOOST_PROTO_FUNCTIONAL_FUSION_AT_HPP_EAN_11_27_2010 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace boost { namespace proto { namespace functional 19 | { 20 | /// \brief A PolymorphicFunctionObject type that invokes the 21 | /// \c fusion::at() accessor on its argument. 22 | /// 23 | /// A PolymorphicFunctionObject type that invokes the 24 | /// \c fusion::at() accessor on its argument. 25 | struct at 26 | { 27 | BOOST_PROTO_CALLABLE() 28 | 29 | template 30 | struct result; 31 | 32 | template 33 | struct result 34 | : fusion::result_of::at< 35 | typename boost::remove_reference::type 36 | , typename boost::remove_const::type>::type 37 | > 38 | {}; 39 | 40 | template 41 | typename fusion::result_of::at::type 42 | operator ()(Seq &seq, N const & BOOST_PROTO_DISABLE_IF_IS_CONST(Seq)) const 43 | { 44 | return fusion::at(seq); 45 | } 46 | 47 | template 48 | typename fusion::result_of::at::type 49 | operator ()(Seq const &seq, N const &) const 50 | { 51 | return fusion::at(seq); 52 | } 53 | }; 54 | }}} 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /include/boost/proto/functional/fusion/pop_back.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file pop_back.hpp 3 | /// Proto callables Fusion pop_back 4 | // 5 | // Copyright 2010 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_FUSION_POP_BACK_HPP_EAN_11_27_2010 10 | #define BOOST_PROTO_FUNCTIONAL_FUSION_POP_BACK_HPP_EAN_11_27_2010 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace boost { namespace proto { namespace functional 19 | { 20 | /// \brief A PolymorphicFunctionObject type that invokes the 21 | /// \c fusion::pop_back() algorithm on its argument. 22 | /// 23 | /// A PolymorphicFunctionObject type that invokes the 24 | /// \c fusion::pop_back() algorithm on its argument. 25 | struct pop_back 26 | { 27 | BOOST_PROTO_CALLABLE() 28 | 29 | template 30 | struct result; 31 | 32 | template 33 | struct result 34 | : result 35 | {}; 36 | 37 | template 38 | struct result 39 | : fusion::result_of::pop_back 40 | {}; 41 | 42 | template 43 | typename fusion::result_of::pop_back::type 44 | operator ()(Seq &seq) const 45 | { 46 | // Work around a const-correctness issue in Fusion 47 | typedef typename fusion::result_of::pop_back::type result_type; 48 | return result_type(fusion::begin(seq), fusion::prior(fusion::end(seq))); 49 | } 50 | 51 | template 52 | typename fusion::result_of::pop_back::type 53 | operator ()(Seq const &seq) const 54 | { 55 | return fusion::pop_back(seq); 56 | } 57 | }; 58 | }}} 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /include/boost/proto/functional/fusion/pop_front.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file pop_front.hpp 3 | /// Proto callables Fusion pop_front 4 | // 5 | // Copyright 2010 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_FUSION_POP_FRONT_HPP_EAN_11_27_2010 10 | #define BOOST_PROTO_FUNCTIONAL_FUSION_POP_FRONT_HPP_EAN_11_27_2010 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace boost { namespace proto { namespace functional 19 | { 20 | /// \brief A PolymorphicFunctionObject type that invokes the 21 | /// \c fusion::pop_front() algorithm on its argument. 22 | /// 23 | /// A PolymorphicFunctionObject type that invokes the 24 | /// \c fusion::pop_front() algorithm on its argument. This is 25 | /// useful for defining a CallableTransform like \c pop_front(_) 26 | /// which removes the first child from a Proto expression node. 27 | /// Such a transform might be used as the first argument to the 28 | /// \c proto::fold\<\> transform; that is, fold all but 29 | /// the first child. 30 | struct pop_front 31 | { 32 | BOOST_PROTO_CALLABLE() 33 | 34 | template 35 | struct result; 36 | 37 | template 38 | struct result 39 | : result 40 | {}; 41 | 42 | template 43 | struct result 44 | : fusion::result_of::pop_front 45 | {}; 46 | 47 | template 48 | typename fusion::result_of::pop_front::type 49 | operator ()(Seq &seq) const 50 | { 51 | // Work around a const-correctness issue in Fusion 52 | typedef typename fusion::result_of::pop_front::type result_type; 53 | return result_type(fusion::next(fusion::begin(seq)), fusion::end(seq)); 54 | } 55 | 56 | template 57 | typename fusion::result_of::pop_front::type 58 | operator ()(Seq const &seq) const 59 | { 60 | return fusion::pop_front(seq); 61 | } 62 | }; 63 | }}} 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /include/boost/proto/functional/fusion/push_back.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file push_back.hpp 3 | /// Proto callables Fusion push_back 4 | // 5 | // Copyright 2010 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_FUSION_PUSH_BACK_HPP_EAN_11_27_2010 10 | #define BOOST_PROTO_FUNCTIONAL_FUSION_PUSH_BACK_HPP_EAN_11_27_2010 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace boost { namespace proto { namespace functional 19 | { 20 | /// \brief A PolymorphicFunctionObject type that invokes the 21 | /// \c fusion::push_back() algorithm on its argument. 22 | /// 23 | /// A PolymorphicFunctionObject type that invokes the 24 | /// \c fusion::push_back() algorithm on its argument. 25 | struct push_back 26 | { 27 | BOOST_PROTO_CALLABLE() 28 | 29 | template 30 | struct result; 31 | 32 | template 33 | struct result 34 | : fusion::result_of::push_back< 35 | typename boost::add_const::type>::type 36 | , typename boost::remove_const::type>::type 37 | > 38 | {}; 39 | 40 | template 41 | typename fusion::result_of::push_back::type 42 | operator ()(Seq const &seq, T const &t) const 43 | { 44 | return fusion::push_back(seq, t); 45 | } 46 | }; 47 | }}} 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /include/boost/proto/functional/fusion/push_front.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file push_front.hpp 3 | /// Proto callables Fusion push_front 4 | // 5 | // Copyright 2010 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_FUSION_PUSH_FRONT_HPP_EAN_11_27_2010 10 | #define BOOST_PROTO_FUNCTIONAL_FUSION_PUSH_FRONT_HPP_EAN_11_27_2010 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace boost { namespace proto { namespace functional 19 | { 20 | /// \brief A PolymorphicFunctionObject type that invokes the 21 | /// \c fusion::push_front() algorithm on its argument. 22 | /// 23 | /// A PolymorphicFunctionObject type that invokes the 24 | /// \c fusion::push_front() algorithm on its argument. 25 | struct push_front 26 | { 27 | BOOST_PROTO_CALLABLE() 28 | 29 | template 30 | struct result; 31 | 32 | template 33 | struct result 34 | : fusion::result_of::push_front< 35 | typename boost::add_const::type>::type 36 | , typename boost::remove_const::type>::type 37 | > 38 | {}; 39 | 40 | template 41 | typename fusion::result_of::push_front::type 42 | operator ()(Seq const &seq, T const &t) const 43 | { 44 | return fusion::push_front(seq, t); 45 | } 46 | }; 47 | }}} 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /include/boost/proto/functional/fusion/reverse.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file reverse.hpp 3 | /// Proto callables Fusion reverse 4 | // 5 | // Copyright 2010 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_FUSION_REVERSE_HPP_EAN_11_27_2010 10 | #define BOOST_PROTO_FUNCTIONAL_FUSION_REVERSE_HPP_EAN_11_27_2010 11 | 12 | #include 13 | #include 14 | 15 | namespace boost { namespace proto { namespace functional 16 | { 17 | /// \brief A PolymorphicFunctionObject type that invokes the 18 | /// \c fusion::reverse() algorithm on its argument. 19 | /// 20 | /// A PolymorphicFunctionObject type that invokes the 21 | /// \c fusion::reverse() algorithm on its argument. This is 22 | /// useful for defining a CallableTransform like \c reverse(_) 23 | /// which reverses the order of the children of a Proto 24 | /// expression node. 25 | struct reverse 26 | { 27 | BOOST_PROTO_CALLABLE() 28 | 29 | template 30 | struct result; 31 | 32 | template 33 | struct result 34 | : result 35 | {}; 36 | 37 | template 38 | struct result 39 | : fusion::result_of::reverse 40 | {}; 41 | 42 | template 43 | typename fusion::result_of::reverse::type 44 | operator ()(Seq &seq) const 45 | { 46 | // Work around a const-correctness issue in Fusion 47 | typedef typename fusion::result_of::reverse::type result_type; 48 | return result_type(seq); 49 | } 50 | 51 | template 52 | typename fusion::result_of::reverse::type 53 | operator ()(Seq const &seq) const 54 | { 55 | return fusion::reverse(seq); 56 | } 57 | }; 58 | }}} 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /include/boost/proto/functional/range.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file range.hpp 3 | /// Proto callables for things found in the boost range library 4 | // 5 | // Copyright 2012 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_RANGE_HPP_EAN_27_08_2012 10 | #define BOOST_PROTO_FUNCTIONAL_RANGE_HPP_EAN_27_08_2012 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/boost/proto/functional/range/begin.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file begin.hpp 3 | /// Proto callables for boost::begin() 4 | // 5 | // Copyright 2012 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_RANGE_BEGIN_HPP_EAN_27_08_2012 10 | #define BOOST_PROTO_FUNCTIONAL_RANGE_BEGIN_HPP_EAN_27_08_2012 11 | 12 | #include 13 | #include 14 | 15 | namespace boost { namespace proto { namespace functional 16 | { 17 | 18 | // A PolymorphicFunctionObject that wraps boost::begin() 19 | struct begin 20 | { 21 | BOOST_PROTO_CALLABLE() 22 | 23 | template 24 | struct result; 25 | 26 | template 27 | struct result 28 | : boost::range_iterator 29 | {}; 30 | 31 | template 32 | struct result 33 | : boost::range_iterator 34 | {}; 35 | 36 | template 37 | typename boost::range_iterator::type operator()(Rng &rng) const 38 | { 39 | return boost::begin(rng); 40 | } 41 | 42 | template 43 | typename boost::range_iterator::type operator()(Rng const &rng) const 44 | { 45 | return boost::begin(rng); 46 | } 47 | }; 48 | 49 | }}} 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/boost/proto/functional/range/empty.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file empty.hpp 3 | /// Proto callables for boost::empty() 4 | // 5 | // Copyright 2012 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_RANGE_EMPTY_HPP_EAN_27_08_2012 10 | #define BOOST_PROTO_FUNCTIONAL_RANGE_EMPTY_HPP_EAN_27_08_2012 11 | 12 | #include 13 | #include 14 | 15 | namespace boost { namespace proto { namespace functional 16 | { 17 | 18 | // A PolymorphicFunctionObject that wraps boost::empty() 19 | struct empty 20 | { 21 | BOOST_PROTO_CALLABLE() 22 | 23 | typedef bool result_type; 24 | 25 | template 26 | bool operator()(Rng const &rng) const 27 | { 28 | return boost::empty(rng); 29 | } 30 | }; 31 | 32 | }}} 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/boost/proto/functional/range/end.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file end.hpp 3 | /// Proto callables for boost::end() 4 | // 5 | // Copyright 2012 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_RANGE_END_HPP_EAN_27_08_2012 10 | #define BOOST_PROTO_FUNCTIONAL_RANGE_END_HPP_EAN_27_08_2012 11 | 12 | #include 13 | #include 14 | 15 | namespace boost { namespace proto { namespace functional 16 | { 17 | 18 | // A PolymorphicFunctionObject that wraps boost::end() 19 | struct end 20 | { 21 | BOOST_PROTO_CALLABLE() 22 | 23 | template 24 | struct result; 25 | 26 | template 27 | struct result 28 | : boost::range_iterator 29 | {}; 30 | 31 | template 32 | struct result 33 | : boost::range_iterator 34 | {}; 35 | 36 | template 37 | typename boost::range_iterator::type operator()(Rng &rng) const 38 | { 39 | return boost::end(rng); 40 | } 41 | 42 | template 43 | typename boost::range_iterator::type operator()(Rng const &rng) const 44 | { 45 | return boost::end(rng); 46 | } 47 | }; 48 | 49 | }}} 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/boost/proto/functional/range/rbegin.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file rbegin.hpp 3 | /// Proto callables for boost::rbegin() 4 | // 5 | // Copyright 2012 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_RANGE_RBEGIN_HPP_EAN_27_08_2012 10 | #define BOOST_PROTO_FUNCTIONAL_RANGE_RBEGIN_HPP_EAN_27_08_2012 11 | 12 | #include 13 | #include 14 | 15 | namespace boost { namespace proto { namespace functional 16 | { 17 | 18 | // A PolymorphicFunctionObject that wraps boost::rbegin() 19 | struct rbegin 20 | { 21 | BOOST_PROTO_CALLABLE() 22 | 23 | template 24 | struct result; 25 | 26 | template 27 | struct result 28 | : boost::range_reverse_iterator 29 | {}; 30 | 31 | template 32 | struct result 33 | : boost::range_reverse_iterator 34 | {}; 35 | 36 | template 37 | typename boost::range_reverse_iterator::type operator()(Rng &rng) const 38 | { 39 | return boost::rbegin(rng); 40 | } 41 | 42 | template 43 | typename boost::range_reverse_iterator::type operator()(Rng const &rng) const 44 | { 45 | return boost::rbegin(rng); 46 | } 47 | }; 48 | 49 | }}} 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/boost/proto/functional/range/rend.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file rend.hpp 3 | /// Proto callables for boost::rend() 4 | // 5 | // Copyright 2012 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_RANGE_REND_HPP_EAN_27_08_2012 10 | #define BOOST_PROTO_FUNCTIONAL_RANGE_REND_HPP_EAN_27_08_2012 11 | 12 | #include 13 | #include 14 | 15 | namespace boost { namespace proto { namespace functional 16 | { 17 | 18 | // A PolymorphicFunctionObject that wraps boost::rend() 19 | struct rend 20 | { 21 | BOOST_PROTO_CALLABLE() 22 | 23 | template 24 | struct result; 25 | 26 | template 27 | struct result 28 | : boost::range_reverse_iterator 29 | {}; 30 | 31 | template 32 | struct result 33 | : boost::range_reverse_iterator 34 | {}; 35 | 36 | template 37 | typename boost::range_reverse_iterator::type operator()(Rng &rng) const 38 | { 39 | return boost::rend(rng); 40 | } 41 | 42 | template 43 | typename boost::range_reverse_iterator::type operator()(Rng const &rng) const 44 | { 45 | return boost::rend(rng); 46 | } 47 | }; 48 | 49 | }}} 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/boost/proto/functional/range/size.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file size.hpp 3 | /// Proto callables for boost::size() 4 | // 5 | // Copyright 2012 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_RANGE_SIZE_HPP_EAN_27_08_2012 10 | #define BOOST_PROTO_FUNCTIONAL_RANGE_SIZE_HPP_EAN_27_08_2012 11 | 12 | #include 13 | #include 14 | 15 | namespace boost { namespace proto { namespace functional 16 | { 17 | 18 | // A PolymorphicFunctionObject that wraps boost::size() 19 | struct size 20 | { 21 | BOOST_PROTO_CALLABLE() 22 | 23 | template 24 | struct result; 25 | 26 | template 27 | struct result 28 | : boost::range_size 29 | {}; 30 | 31 | template 32 | struct result 33 | : boost::range_size 34 | {}; 35 | 36 | template 37 | typename boost::range_size::type operator()(Rng const &rng) const 38 | { 39 | return boost::size(rng); 40 | } 41 | }; 42 | 43 | }}} 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/boost/proto/functional/std.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file std.hpp 3 | /// Proto callables for things found in the std library 4 | // 5 | // Copyright 2010 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_FUNCTIONAL_STD_HPP_EAN_11_27_2010 10 | #define BOOST_PROTO_FUNCTIONAL_STD_HPP_EAN_11_27_2010 11 | 12 | #include 13 | #include 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /include/boost/proto/proto.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file proto.hpp 3 | /// Includes all of Proto. 4 | // 5 | // Copyright 2008 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_HPP_EAN_04_01_2005 10 | #define BOOST_PROTO_HPP_EAN_04_01_2005 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/boost/proto/transform.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file transform.hpp 3 | /// Includes all the transforms in the transform/ sub-directory. 4 | // 5 | // Copyright 2008 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_TRANSFORM_HPP_EAN_06_23_2007 10 | #define BOOST_PROTO_TRANSFORM_HPP_EAN_06_23_2007 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/boost/proto/transform/detail/construct_funop.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/construct_funop.hpp") 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | /// \file construct_funop.hpp 13 | /// Overloads of construct_\<\>::operator(). 14 | // 15 | // Copyright 2008 Eric Niebler. Distributed under the Boost 16 | // Software License, Version 1.0. (See accompanying file 17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 1) 21 | #endif 22 | 23 | #define BOOST_PP_ITERATION_PARAMS_1 \ 24 | (3, (1, BOOST_PROTO_MAX_ARITY, )) 25 | #include BOOST_PP_ITERATE() 26 | 27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 28 | #pragma wave option(output: null) 29 | #endif 30 | 31 | #else 32 | 33 | #define N BOOST_PP_ITERATION() 34 | 35 | template 36 | BOOST_FORCEINLINE 37 | Type operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, &a)) const 38 | { 39 | return Type(BOOST_PP_ENUM_PARAMS(N, a)); 40 | } 41 | 42 | #undef N 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /include/boost/proto/transform/detail/construct_pod_funop.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/construct_pod_funop.hpp") 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | /// \file construct_pod_funop.hpp 13 | /// Overloads of construct_\<\>::operator(). 14 | // 15 | // Copyright 2008 Eric Niebler. Distributed under the Boost 16 | // Software License, Version 1.0. (See accompanying file 17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 1) 21 | #endif 22 | 23 | #define BOOST_PP_ITERATION_PARAMS_1 \ 24 | (3, (1, BOOST_PROTO_MAX_ARITY, )) 25 | #include BOOST_PP_ITERATE() 26 | 27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 28 | #pragma wave option(output: null) 29 | #endif 30 | 31 | #else 32 | 33 | #define N BOOST_PP_ITERATION() 34 | 35 | template 36 | BOOST_FORCEINLINE 37 | Type operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, &a)) const 38 | { 39 | Type that = {BOOST_PP_ENUM_PARAMS(N, a)}; 40 | return that; 41 | } 42 | 43 | #undef N 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/boost/proto/transform/detail/expand_pack.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/expand_pack.hpp") 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | /// \file expand_pack.hpp 13 | /// Contains helpers for pseudo-pack expansion. 14 | // 15 | // Copyright 2012 Eric Niebler. Distributed under the Boost 16 | // Software License, Version 1.0. (See accompanying file 17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 1) 21 | #endif 22 | 23 | #define BOOST_PP_ITERATION_PARAMS_1 \ 24 | (3, (0, BOOST_PROTO_MAX_ARITY, )) 25 | #include BOOST_PP_ITERATE() 26 | 27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 28 | #pragma wave option(output: null) 29 | #endif 30 | 31 | #else 32 | #define N BOOST_PP_ITERATION() 33 | #define M0(Z, X, DATA) typename expand_pattern_helper::type 34 | #define M1(Z, X, DATA) expand_pattern_helper::applied::value || 35 | 36 | template 37 | struct expand_pattern_helper 38 | { 39 | typedef Ret (*type)(BOOST_PP_ENUM(N, M0, ~)); 40 | typedef mpl::bool_ applied; 41 | }; 42 | 43 | #undef M1 44 | #undef M0 45 | #undef N 46 | #endif 47 | -------------------------------------------------------------------------------- /include/boost/proto/transform/detail/lazy.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/lazy.hpp") 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | /// \file lazy.hpp 13 | /// Contains definition of the lazy<> transform. 14 | // 15 | // Copyright 2008 Eric Niebler. Distributed under the Boost 16 | // Software License, Version 1.0. (See accompanying file 17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 1) 21 | #endif 22 | 23 | #define BOOST_PP_ITERATION_PARAMS_1 \ 24 | (3, (0, BOOST_PROTO_MAX_ARITY, )) 25 | #include BOOST_PP_ITERATE() 26 | 27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 28 | #pragma wave option(output: null) 29 | #endif 30 | 31 | #else 32 | 33 | #define N BOOST_PP_ITERATION() 34 | 35 | /// \brief A PrimitiveTransform that uses make\<\> to build 36 | /// a CallableTransform, and then uses call\<\> to apply it. 37 | /// 38 | /// lazy\<\> is useful as a higher-order transform, when the 39 | /// transform to be applied depends on the current state of the 40 | /// transformation. The invocation of the make\<\> transform 41 | /// evaluates any nested transforms, and the resulting type is treated 42 | /// as a CallableTransform, which is evaluated with call\<\>. 43 | template 44 | struct lazy 45 | : transform > 46 | { 47 | template 48 | struct impl 49 | : call< 50 | typename make::template impl::result_type 51 | (BOOST_PP_ENUM_PARAMS(N, A)) 52 | >::template impl 53 | {}; 54 | }; 55 | 56 | #if N > 0 57 | template 58 | struct lazy 59 | : transform > 60 | { 61 | template 62 | struct impl 63 | : lazy< 64 | typename detail::expand_pattern< 65 | proto::arity_of::value 66 | , BOOST_PP_CAT(A, BOOST_PP_DEC(N)) 67 | , detail::BOOST_PP_CAT(expand_pattern_rest_, BOOST_PP_DEC(N))< 68 | Object 69 | BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_DEC(N), A) 70 | > 71 | >::type 72 | >::template impl 73 | {}; 74 | }; 75 | #endif 76 | 77 | #undef N 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /include/boost/proto/transform/detail/pack.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file pack.hpp 3 | /// Contains helpers for pseudo-pack expansion. 4 | // 5 | // Copyright 2012 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_TRANSFORM_DETAIL_PACK_HPP_EAN_2012_07_11 10 | #define BOOST_PROTO_TRANSFORM_DETAIL_PACK_HPP_EAN_2012_07_11 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #if defined(_MSC_VER) 30 | # pragma warning(push) 31 | # pragma warning(disable: 4348) // redefinition of default parameter 32 | #endif 33 | 34 | namespace boost { namespace proto 35 | { 36 | namespace detail 37 | { 38 | template 39 | struct msvc_fun_workaround; 40 | 41 | template 42 | struct expand_pattern_helper 43 | { 44 | typedef T type; 45 | typedef mpl::false_ applied; 46 | }; 47 | 48 | template 49 | struct expand_pattern_helper 50 | : expand_pattern_helper 51 | {}; 52 | 53 | template 54 | struct expand_pattern_helper 55 | { 56 | // BUGBUG fix me. See comment in transform/detail/call.hpp 57 | BOOST_MPL_ASSERT_MSG( 58 | (is_same::value) 59 | , PACK_EXPANSIONS_OF_EXPRESSIONS_OTHER_THAN_THE_CURRENT_NOT_YET_SUPPORTED 60 | , (T) 61 | ); 62 | typedef Tfx type(T); 63 | typedef mpl::true_ applied; 64 | }; 65 | 66 | template 67 | struct expand_pattern_helper 68 | { 69 | typedef Tfx type; 70 | typedef mpl::true_ applied; 71 | }; 72 | 73 | #include 74 | 75 | template 76 | struct expand_pattern; 77 | 78 | template 79 | struct expand_pattern<0, Fun, Cont> 80 | : Cont::template cat::type> 81 | { 82 | BOOST_MPL_ASSERT_MSG( 83 | (expand_pattern_helper::applied::value) 84 | , NO_PACK_EXPRESSION_FOUND_IN_PACK_EXPANSION 85 | , (Fun) 86 | ); 87 | }; 88 | 89 | #include 90 | } 91 | }} 92 | 93 | #if defined(_MSC_VER) 94 | # pragma warning(pop) 95 | #endif 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /include/boost/proto/transform/detail/pack_impl.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) 2 | 3 | #include 4 | 5 | #elif !defined(BOOST_PP_IS_ITERATING) 6 | 7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/pack_impl.hpp") 9 | #endif 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | /// \file pack_impl.hpp 13 | /// Contains helpers for pseudo-pack expansion. 14 | // 15 | // Copyright 2012 Eric Niebler. Distributed under the Boost 16 | // Software License, Version 1.0. (See accompanying file 17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 18 | 19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 20 | #pragma wave option(preserve: 1) 21 | #endif 22 | 23 | #define BOOST_PP_ITERATION_PARAMS_1 \ 24 | (3, (0, BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY), )) 25 | #include BOOST_PP_ITERATE() 26 | 27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) 28 | #pragma wave option(output: null) 29 | #endif 30 | 31 | #else 32 | #if BOOST_PP_ITERATION_DEPTH() == 1 33 | #define N BOOST_PP_ITERATION() 34 | #define M BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N) 35 | #define M0(Z, X, D) typename expand_pattern_helper, Fun>::type 36 | 37 | template 38 | struct expand_pattern 39 | : Cont::template cat 40 | { 41 | BOOST_MPL_ASSERT_MSG( 42 | (expand_pattern_helper, Fun>::applied::value) 43 | , NO_PACK_EXPRESSION_FOUND_IN_UNPACKING_PATTERN 44 | , (Fun) 45 | ); 46 | }; 47 | 48 | template 49 | struct BOOST_PP_CAT(expand_pattern_rest_, N) 50 | { 51 | template 52 | struct cat; 53 | 54 | #define BOOST_PP_ITERATION_PARAMS_2 \ 55 | (3, (1, M, )) 56 | #include BOOST_PP_ITERATE() 57 | }; 58 | #undef M0 59 | #undef M 60 | #undef N 61 | #else 62 | #define I BOOST_PP_ITERATION() 63 | #define J BOOST_PP_RELATIVE_ITERATION(1) 64 | template 65 | struct cat 66 | { 67 | typedef msvc_fun_workaround type; 68 | }; 69 | #undef J 70 | #undef I 71 | #endif 72 | #endif 73 | -------------------------------------------------------------------------------- /include/boost/proto/transform/detail/preprocessed/construct_funop.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file construct_funop.hpp 3 | /// Overloads of construct_\<\>::operator(). 4 | // 5 | // Copyright 2008 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | template 9 | BOOST_FORCEINLINE 10 | Type operator ()(A0 &a0) const 11 | { 12 | return Type(a0); 13 | } 14 | template 15 | BOOST_FORCEINLINE 16 | Type operator ()(A0 &a0 , A1 &a1) const 17 | { 18 | return Type(a0 , a1); 19 | } 20 | template 21 | BOOST_FORCEINLINE 22 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2) const 23 | { 24 | return Type(a0 , a1 , a2); 25 | } 26 | template 27 | BOOST_FORCEINLINE 28 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3) const 29 | { 30 | return Type(a0 , a1 , a2 , a3); 31 | } 32 | template 33 | BOOST_FORCEINLINE 34 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4) const 35 | { 36 | return Type(a0 , a1 , a2 , a3 , a4); 37 | } 38 | template 39 | BOOST_FORCEINLINE 40 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4 , A5 &a5) const 41 | { 42 | return Type(a0 , a1 , a2 , a3 , a4 , a5); 43 | } 44 | template 45 | BOOST_FORCEINLINE 46 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4 , A5 &a5 , A6 &a6) const 47 | { 48 | return Type(a0 , a1 , a2 , a3 , a4 , a5 , a6); 49 | } 50 | template 51 | BOOST_FORCEINLINE 52 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4 , A5 &a5 , A6 &a6 , A7 &a7) const 53 | { 54 | return Type(a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7); 55 | } 56 | template 57 | BOOST_FORCEINLINE 58 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4 , A5 &a5 , A6 &a6 , A7 &a7 , A8 &a8) const 59 | { 60 | return Type(a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8); 61 | } 62 | template 63 | BOOST_FORCEINLINE 64 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4 , A5 &a5 , A6 &a6 , A7 &a7 , A8 &a8 , A9 &a9) const 65 | { 66 | return Type(a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9); 67 | } 68 | -------------------------------------------------------------------------------- /include/boost/proto/transform/detail/preprocessed/construct_pod_funop.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file construct_pod_funop.hpp 3 | /// Overloads of construct_\<\>::operator(). 4 | // 5 | // Copyright 2008 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | template 9 | BOOST_FORCEINLINE 10 | Type operator ()(A0 &a0) const 11 | { 12 | Type that = {a0}; 13 | return that; 14 | } 15 | template 16 | BOOST_FORCEINLINE 17 | Type operator ()(A0 &a0 , A1 &a1) const 18 | { 19 | Type that = {a0 , a1}; 20 | return that; 21 | } 22 | template 23 | BOOST_FORCEINLINE 24 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2) const 25 | { 26 | Type that = {a0 , a1 , a2}; 27 | return that; 28 | } 29 | template 30 | BOOST_FORCEINLINE 31 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3) const 32 | { 33 | Type that = {a0 , a1 , a2 , a3}; 34 | return that; 35 | } 36 | template 37 | BOOST_FORCEINLINE 38 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4) const 39 | { 40 | Type that = {a0 , a1 , a2 , a3 , a4}; 41 | return that; 42 | } 43 | template 44 | BOOST_FORCEINLINE 45 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4 , A5 &a5) const 46 | { 47 | Type that = {a0 , a1 , a2 , a3 , a4 , a5}; 48 | return that; 49 | } 50 | template 51 | BOOST_FORCEINLINE 52 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4 , A5 &a5 , A6 &a6) const 53 | { 54 | Type that = {a0 , a1 , a2 , a3 , a4 , a5 , a6}; 55 | return that; 56 | } 57 | template 58 | BOOST_FORCEINLINE 59 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4 , A5 &a5 , A6 &a6 , A7 &a7) const 60 | { 61 | Type that = {a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7}; 62 | return that; 63 | } 64 | template 65 | BOOST_FORCEINLINE 66 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4 , A5 &a5 , A6 &a6 , A7 &a7 , A8 &a8) const 67 | { 68 | Type that = {a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8}; 69 | return that; 70 | } 71 | template 72 | BOOST_FORCEINLINE 73 | Type operator ()(A0 &a0 , A1 &a1 , A2 &a2 , A3 &a3 , A4 &a4 , A5 &a5 , A6 &a6 , A7 &a7 , A8 &a8 , A9 &a9) const 74 | { 75 | Type that = {a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9}; 76 | return that; 77 | } 78 | -------------------------------------------------------------------------------- /include/boost/proto/transform/integral_c.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file integral_c.hpp 3 | /// Contains definition of the integral_c transform and friends. 4 | // 5 | // Copyright 2011 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_TRANSFORM_INTEGRAL_C_HPP_EAN_04_28_2011 10 | #define BOOST_PROTO_TRANSFORM_INTEGRAL_C_HPP_EAN_04_28_2011 11 | 12 | #include 13 | #include 14 | 15 | namespace boost { namespace proto 16 | { 17 | 18 | /// \brief A PrimitiveTransform that returns a specified 19 | /// integral constant 20 | /// 21 | template 22 | struct integral_c : transform > 23 | { 24 | template 25 | struct impl : transform_impl 26 | { 27 | typedef T result_type; 28 | 29 | /// \return \c I 30 | /// \throw nothrow 31 | T operator()( 32 | typename impl::expr_param 33 | , typename impl::state_param 34 | , typename impl::data_param 35 | ) const 36 | { 37 | return I; 38 | } 39 | }; 40 | }; 41 | 42 | /// \brief A PrimitiveTransform that returns a specified 43 | /// char 44 | /// 45 | template 46 | struct char_ 47 | : integral_c 48 | {}; 49 | 50 | /// \brief A PrimitiveTransform that returns a specified 51 | /// int 52 | /// 53 | template 54 | struct int_ 55 | : integral_c 56 | {}; 57 | 58 | /// \brief A PrimitiveTransform that returns a specified 59 | /// long 60 | /// 61 | template 62 | struct long_ 63 | : integral_c 64 | {}; 65 | 66 | /// \brief A PrimitiveTransform that returns a specified 67 | /// std::size_t 68 | /// 69 | template 70 | struct size_t 71 | : integral_c 72 | {}; 73 | 74 | /// INTERNAL ONLY 75 | /// 76 | template 77 | struct is_callable > 78 | : mpl::true_ 79 | {}; 80 | 81 | /// INTERNAL ONLY 82 | /// 83 | template 84 | struct is_callable > 85 | : mpl::true_ 86 | {}; 87 | 88 | /// INTERNAL ONLY 89 | /// 90 | template 91 | struct is_callable > 92 | : mpl::true_ 93 | {}; 94 | 95 | /// INTERNAL ONLY 96 | /// 97 | template 98 | struct is_callable > 99 | : mpl::true_ 100 | {}; 101 | 102 | /// INTERNAL ONLY 103 | /// 104 | template 105 | struct is_callable > 106 | : mpl::true_ 107 | {}; 108 | 109 | }} 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /include/boost/proto/transform/lazy.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file lazy.hpp 3 | /// Contains definition of the lazy<> transform. 4 | // 5 | // Copyright 2008 Eric Niebler. Distributed under the Boost 6 | // Software License, Version 1.0. (See accompanying file 7 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | 9 | #ifndef BOOST_PROTO_TRANSFORM_LAZY_HPP_EAN_12_02_2007 10 | #define BOOST_PROTO_TRANSFORM_LAZY_HPP_EAN_12_02_2007 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | namespace boost { namespace proto 22 | { 23 | /// \brief A PrimitiveTransform that uses make\<\> to build 24 | /// a CallableTransform, and then uses call\<\> to apply it. 25 | /// 26 | /// lazy\<\> is useful as a higher-order transform, when the 27 | /// transform to be applied depends on the current state of the 28 | /// transformation. The invocation of the make\<\> transform 29 | /// evaluates any nested transforms, and the resulting type is treated 30 | /// as a CallableTransform, which is evaluated with call\<\>. 31 | template 32 | struct lazy : transform > 33 | { 34 | template 35 | struct impl 36 | : call< 37 | typename make::template impl::result_type 38 | >::template impl 39 | {}; 40 | }; 41 | 42 | /// INTERNAL ONLY 43 | template 44 | struct lazy > 45 | : lazy 46 | {}; 47 | 48 | #include 49 | 50 | /// INTERNAL ONLY 51 | /// 52 | template 53 | struct is_callable > 54 | : mpl::true_ 55 | {}; 56 | 57 | }} 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Automatic redirection failed, please go to 7 | ../../doc/html/proto.html 8 |

Copyright Eric Niebler 2006

9 |

Distributed under the Boost Software License, Version 1.0. (See accompanying file 10 | LICENSE_1_0.txt or copy at 11 | www.boost.org/LICENSE_1_0.txt). 12 |

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /meta/libraries.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "proto", 3 | "name": "Proto", 4 | "authors": [ 5 | "Eric Niebler" 6 | ], 7 | "description": "Expression template library and compiler construction toolkit for domain-specific embedded languages.", 8 | "category": [ 9 | "Metaprogramming" 10 | ], 11 | "maintainers": [ 12 | "Eric Niebler " 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /preprocess/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2012: Eric Niebler 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | # Generates preprocessed files with wave. 6 | 7 | project : requirements static release ; 8 | 9 | actions wave 10 | { 11 | $(>[2]) -o- -DBOOST_PROTO_MAX_ARITY=10 --config-file wave.cfg $(>[1]) 12 | } 13 | 14 | W = /boost/libs/wave/tool//wave ; 15 | 16 | make preprocess_proto 17 | : preprocess_proto.cpp $(W) : wave : wave.cfg 18 | ; 19 | -------------------------------------------------------------------------------- /preprocess/preprocess_proto.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Copyright 2011 Eric Niebler. Distributed under the Boost 3 | // Software License, Version 1.0. (See accompanying file 4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include "../include/boost/proto/core.hpp" 7 | #include "../include/boost/proto/debug.hpp" 8 | #include "../include/boost/proto/context.hpp" 9 | #include "../include/boost/proto/transform.hpp" 10 | #include "../include/boost/proto/functional.hpp" 11 | -------------------------------------------------------------------------------- /preprocess/wave.cfg: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2012: Eric Niebler 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | # NOTE: Some of the paths in this file may need to be changed for your system. 6 | 7 | -DBOOST_PROTO_DONT_USE_PREPROCESSED_FILES 8 | -DBOOST_PROTO_CREATE_PREPROCESSED_FILES 9 | -D_WIN32 10 | -NBOOST_STATIC_ASSERT 11 | -NBOOST_PROTO_TEMPLATE_ARITY_PARAM 12 | -NBOOST_PROTO_RESULT_OF 13 | -NBOOST_PROTO_DISABLE_IF_IS_CONST 14 | -NBOOST_PROTO_DISABLE_IF_IS_FUNCTION 15 | -NBOOST_PROTO_USE_GET_POINTER 16 | -NBOOST_PROTO_GET_POINTER 17 | -NBOOST_PROTO_ASSERT_VALID_DOMAIN 18 | -NBOOST_PROTO_RETURN_TYPE_STRICT_LOOSE 19 | -NBOOST_FORCEINLINE 20 | -NBOOST_MPL_ASSERT 21 | -NBOOST_MPL_ASSERT_MSG 22 | -NBOOST_MPL_ASSERT_RELATION 23 | -S../include 24 | -S../../.. 25 | -S"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include" 26 | -S. 27 | --variadics 28 | -------------------------------------------------------------------------------- /test/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2004: Eric Niebler 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | # bring in rules for testing 6 | import testing ; 7 | 8 | project 9 | : requirements 10 | /boost/proto//boost_proto 11 | intel:off 12 | msvc-7.1:off 13 | msvc-8.0:_SCL_SECURE_NO_DEPRECATE 14 | msvc-8.0:_CRT_SECURE_NO_DEPRECATE 15 | msvc-9.0:_SCL_SECURE_NO_DEPRECATE 16 | msvc-10.0:_SCL_SECURE_NO_DEPRECATE 17 | msvc-11.0:_SCL_SECURE_NO_DEPRECATE 18 | msvc-11.0:_SCL_SECURE_NO_WARNINGS 19 | gcc:-ftemplate-depth-1024 20 | /boost/test//boost_unit_test_framework 21 | static 22 | # BOOST_PROTO_DONT_USE_PREPROCESSED_FILES 23 | ; 24 | 25 | test-suite "proto" 26 | : 27 | [ run calculator.cpp ] 28 | [ run constrained_ops.cpp ] 29 | [ run cpp-next_bug.cpp ] 30 | [ run deep_copy.cpp ] 31 | [ run display_expr.cpp ] 32 | [ run deduce_domain.cpp ] 33 | [ run env_var.cpp ] 34 | [ run examples.cpp ] 35 | [ run external_transforms.cpp ] 36 | [ run lambda.cpp ] 37 | [ run make_expr.cpp ] 38 | [ run matches.cpp ] 39 | [ run flatten.cpp ] 40 | [ run switch.cpp ] 41 | [ run toy_spirit.cpp ] 42 | [ run toy_spirit2.cpp ] 43 | [ run make.cpp ] 44 | [ run mem_ptr.cpp : : : msvc:/wd4355 ] 45 | [ run mpl.cpp ] 46 | [ run noinvoke.cpp ] 47 | [ run pack_expansion.cpp ] 48 | [ run protect.cpp ] 49 | [ compile bug2407.cpp ] 50 | ; 51 | 52 | -------------------------------------------------------------------------------- /test/bug2407.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // bug2407.hpp 3 | // 4 | // Copyright 2008 Eric Niebler. Distributed under the Boost 5 | // Software License, Version 1.0. (See accompanying file 6 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | 11 | namespace mpl = boost::mpl; 12 | namespace proto = boost::proto; 13 | using proto::_; 14 | 15 | template 16 | struct e; 17 | 18 | struct g 19 | : proto::or_< 20 | proto::terminal 21 | , proto::plus 22 | > 23 | {}; 24 | 25 | struct d 26 | : proto::domain, g> 27 | {}; 28 | 29 | template 30 | struct e 31 | : proto::extends, d> 32 | { 33 | BOOST_MPL_ASSERT((proto::matches)); 34 | 35 | e(E const &x = E()) 36 | : proto::extends, d>(x) 37 | {} 38 | }; 39 | 40 | e::type> i; 41 | 42 | template 43 | std::ostream &operator<<(std::ostream &sout, e const &x) 44 | { 45 | return sout; 46 | } 47 | 48 | int main() 49 | { 50 | std::cout << (i+i); 51 | } 52 | -------------------------------------------------------------------------------- /test/calculator.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // calculator.hpp 3 | // 4 | // Copyright 2008 Eric Niebler. Distributed under the Boost 5 | // Software License, Version 1.0. (See accompanying file 6 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace boost; 13 | 14 | struct placeholder {}; 15 | proto::terminal::type const _1 = {{}}; 16 | 17 | struct calculator : proto::callable_context 18 | { 19 | typedef int result_type; 20 | 21 | calculator(int i) 22 | : i_(i) 23 | {} 24 | 25 | int operator ()(proto::tag::terminal, placeholder) const 26 | { 27 | return this->i_; 28 | } 29 | 30 | int operator ()(proto::tag::terminal, int j) const 31 | { 32 | return j; 33 | } 34 | 35 | template 36 | int operator ()(proto::tag::plus, Left const &left, Right const &right) const 37 | { 38 | return proto::eval(left, *this) + proto::eval(right, *this); 39 | } 40 | 41 | template 42 | int operator ()(proto::tag::minus, Left const &left, Right const &right) const 43 | { 44 | return proto::eval(left, *this) - proto::eval(right, *this); 45 | } 46 | 47 | template 48 | int operator ()(proto::tag::multiplies, Left const &left, Right const &right) const 49 | { 50 | return proto::eval(left, *this) * proto::eval(right, *this); 51 | } 52 | 53 | template 54 | int operator ()(proto::tag::divides, Left const &left, Right const &right) const 55 | { 56 | return proto::eval(left, *this) / proto::eval(right, *this); 57 | } 58 | 59 | private: 60 | int i_; 61 | }; 62 | 63 | template 64 | struct functional 65 | { 66 | typedef typename proto::result_of::eval::type result_type; 67 | 68 | functional(Expr const &expr) 69 | : expr_(expr) 70 | {} 71 | 72 | template 73 | result_type operator ()(T const &t) const 74 | { 75 | Fun fun(t); 76 | return proto::eval(this->expr_, fun); 77 | } 78 | 79 | private: 80 | Expr const &expr_; 81 | }; 82 | 83 | template 84 | functional as(Expr const &expr) 85 | { 86 | return functional(expr); 87 | } 88 | 89 | void test_calculator() 90 | { 91 | BOOST_CHECK_EQUAL(10, proto::eval(((_1 + 42)-3)/4, calculator(1))); 92 | BOOST_CHECK_EQUAL(11, proto::eval(((_1 + 42)-3)/4, calculator(5))); 93 | 94 | BOOST_CHECK_EQUAL(10, as(((_1 + 42)-3)/4)(1)); 95 | BOOST_CHECK_EQUAL(11, as(((_1 + 42)-3)/4)(5)); 96 | } 97 | 98 | using namespace unit_test; 99 | /////////////////////////////////////////////////////////////////////////////// 100 | // init_unit_test_suite 101 | // 102 | test_suite* init_unit_test_suite( int argc, char* argv[] ) 103 | { 104 | test_suite *test = BOOST_TEST_SUITE("test immediate evaluation of proto parse trees"); 105 | 106 | test->add(BOOST_TEST_CASE(&test_calculator)); 107 | 108 | return test; 109 | } 110 | -------------------------------------------------------------------------------- /test/cpp-next_bug.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // cpp-next_bug.hpp 3 | // 4 | // Copyright 2012 Eric Niebler. Distributed under the Boost 5 | // Software License, Version 1.0. (See accompanying file 6 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | namespace mpl = boost::mpl; 12 | namespace proto = boost::proto; 13 | using proto::_; 14 | 15 | namespace linear_algebra 16 | { 17 | // A trait that returns true only for std::vector 18 | template 19 | struct is_std_vector 20 | : mpl::false_ 21 | {}; 22 | 23 | template 24 | struct is_std_vector > 25 | : mpl::true_ 26 | {}; 27 | 28 | // A type used as a domain for linear algebra expressions 29 | struct linear_algebra_domain 30 | : proto::domain<> 31 | {}; 32 | 33 | // Define all the operator overloads for combining std::vectors 34 | BOOST_PROTO_DEFINE_OPERATORS(is_std_vector, linear_algebra_domain) 35 | 36 | // Take any expression and turn each node 37 | // into a subscript expression, using the 38 | // state as the RHS. 39 | struct Distribute 40 | : proto::or_< 41 | proto::when, proto::_make_subscript(_, proto::_state)> 42 | , proto::plus 43 | > 44 | {}; 45 | 46 | struct Optimize 47 | : proto::or_< 48 | proto::when< 49 | proto::subscript >, 50 | Distribute(proto::_left, proto::_right) 51 | > 52 | , proto::plus 53 | , proto::terminal<_> 54 | > 55 | {}; 56 | } 57 | 58 | static const int celems = 4; 59 | static int const value[celems] = {1,2,3,4}; 60 | std::vector A(value, value+celems), B(A); 61 | 62 | void test1() 63 | { 64 | using namespace linear_algebra; 65 | proto::_default<> eval; 66 | BOOST_CHECK_EQUAL(8, eval(Optimize()((A + B)[3]))); 67 | } 68 | 69 | using namespace boost::unit_test; 70 | /////////////////////////////////////////////////////////////////////////////// 71 | // init_unit_test_suite 72 | // 73 | test_suite* init_unit_test_suite( int argc, char* argv[] ) 74 | { 75 | test_suite *test = BOOST_TEST_SUITE("test for a problem reported on the cpp-next.com blog"); 76 | 77 | test->add(BOOST_TEST_CASE(&test1)); 78 | 79 | return test; 80 | } 81 | -------------------------------------------------------------------------------- /test/deep_copy.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // deep_copy.hpp 3 | // 4 | // Copyright 2008 Eric Niebler. Distributed under the Boost 5 | // Software License, Version 1.0. (See accompanying file 6 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | using namespace boost; 14 | 15 | void foo() {} 16 | 17 | void test1() 18 | { 19 | using namespace proto; 20 | 21 | int i = 42; 22 | terminal::type t1 = {i}; 23 | terminal::type r1 = deep_copy(t1); 24 | BOOST_CHECK_EQUAL(42, value(r1)); 25 | 26 | plus::type, terminal::type>::type r2 = deep_copy(t1 + 24); 27 | BOOST_CHECK_EQUAL(42, value(left(r2))); 28 | BOOST_CHECK_EQUAL(24, value(right(r2))); 29 | 30 | char buf[16] = {'\0'}; 31 | terminal::type t3 = {buf}; 32 | terminal::type r3 = deep_copy(t3); 33 | 34 | terminal::type t4 = {foo}; 35 | plus::type, terminal::type>::type r4 = deep_copy(t4 + t1); 36 | BOOST_CHECK_EQUAL(42, value(right(r4))); 37 | BOOST_CHECK_EQUAL(&foo, &value(left(r4))); 38 | 39 | terminal::type cout_ = {std::cout}; 40 | shift_left::type, terminal::type>::type r5 = deep_copy(cout_ << t1); 41 | BOOST_CHECK_EQUAL(42, value(right(r5))); 42 | BOOST_CHECK_EQUAL(boost::addressof(std::cout), boost::addressof(value(left(r5)))); 43 | } 44 | 45 | using namespace unit_test; 46 | /////////////////////////////////////////////////////////////////////////////// 47 | // init_unit_test_suite 48 | // 49 | test_suite* init_unit_test_suite( int argc, char* argv[] ) 50 | { 51 | test_suite *test = BOOST_TEST_SUITE("test deep_copy of proto parse trees"); 52 | 53 | test->add(BOOST_TEST_CASE(&test1)); 54 | 55 | return test; 56 | } 57 | -------------------------------------------------------------------------------- /test/display_expr.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // display_expr.cpp 3 | // 4 | // Copyright 2010 Eric Niebler. Distributed under the Boost 5 | // Software License, Version 1.0. (See accompanying file 6 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace mpl = boost::mpl; 13 | namespace proto = boost::proto; 14 | using proto::_; 15 | 16 | struct A {}; 17 | struct B : A {}; 18 | std::ostream& operator<<( std::ostream& out, const A& ) { return out << "this is A!"; } 19 | 20 | struct C {}; 21 | 22 | void test_display_expr() 23 | { 24 | // https://svn.boost.org/trac/boost/ticket/4910 25 | proto::terminal::type i = {0}; 26 | 27 | { 28 | std::stringstream sout; 29 | proto::display_expr(i + A(), sout); 30 | BOOST_CHECK_EQUAL(sout.str(), std::string( 31 | "plus(\n" 32 | " terminal(0)\n" 33 | " , terminal(this is A!)\n" 34 | ")\n")); 35 | } 36 | 37 | { 38 | std::stringstream sout; 39 | proto::display_expr(i + B(), sout); 40 | BOOST_CHECK_EQUAL(sout.str(), std::string( 41 | "plus(\n" 42 | " terminal(0)\n" 43 | " , terminal(this is A!)\n" 44 | ")\n")); 45 | } 46 | 47 | { 48 | std::stringstream sout; 49 | char const * Cname = BOOST_CORE_TYPEID(C).name(); 50 | proto::display_expr(i + C(), sout); 51 | BOOST_CHECK_EQUAL(sout.str(), std::string( 52 | "plus(\n" 53 | " terminal(0)\n" 54 | " , terminal(") + Cname + std::string(")\n" 55 | ")\n")); 56 | } 57 | } 58 | 59 | using namespace boost::unit_test; 60 | /////////////////////////////////////////////////////////////////////////////// 61 | // init_unit_test_suite 62 | // 63 | test_suite* init_unit_test_suite( int argc, char* argv[] ) 64 | { 65 | test_suite *test = BOOST_TEST_SUITE("test display_expr() function"); 66 | test->add(BOOST_TEST_CASE(&test_display_expr)); 67 | return test; 68 | } 69 | -------------------------------------------------------------------------------- /test/make.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // make.hpp 3 | // 4 | // Copyright 2008 Eric Niebler. Distributed under the Boost 5 | // Software License, Version 1.0. (See accompanying file 6 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace mpl = boost::mpl; 15 | namespace proto = boost::proto; 16 | using proto::_; 17 | 18 | template 19 | struct type2type {}; 20 | 21 | template 22 | struct wrapper 23 | { 24 | T t_; 25 | explicit wrapper(T const & t = T()) : t_(t) {} 26 | }; 27 | 28 | template 29 | struct careful 30 | { 31 | typedef typename T::not_there not_there; 32 | }; 33 | 34 | // Test that when no substitution is done, we don't instantiate templates 35 | struct MakeTest1 36 | : proto::make< type2type< careful > > 37 | {}; 38 | 39 | void make_test1() 40 | { 41 | proto::terminal::type i = {42}; 42 | type2type< careful > res = MakeTest1()(i); 43 | } 44 | 45 | // Test that when substitution is done, and there is no nested ::type 46 | // typedef, the result is the wrapper 47 | struct MakeTest2 48 | : proto::make< wrapper< proto::_value > > 49 | {}; 50 | 51 | void make_test2() 52 | { 53 | proto::terminal::type i = {42}; 54 | wrapper res = MakeTest2()(i); 55 | BOOST_CHECK_EQUAL(res.t_, 0); 56 | } 57 | 58 | // Test that when substitution is done, and there is no nested ::type 59 | // typedef, the result is the wrapper 60 | struct MakeTest3 61 | : proto::make< wrapper< proto::_value >(proto::_value) > 62 | {}; 63 | 64 | void make_test3() 65 | { 66 | proto::terminal::type i = {42}; 67 | wrapper res = MakeTest3()(i); 68 | BOOST_CHECK_EQUAL(res.t_, 42); 69 | } 70 | 71 | // Test that when substitution is done, and there is no nested ::type 72 | // typedef, the result is the wrapper 73 | struct MakeTest4 74 | : proto::make< mpl::identity< proto::_value >(proto::_value) > 75 | {}; 76 | 77 | void make_test4() 78 | { 79 | proto::terminal::type i = {42}; 80 | int res = MakeTest4()(i); 81 | BOOST_CHECK_EQUAL(res, 42); 82 | } 83 | 84 | using namespace boost::unit_test; 85 | /////////////////////////////////////////////////////////////////////////////// 86 | // init_unit_test_suite 87 | // 88 | test_suite* init_unit_test_suite( int argc, char* argv[] ) 89 | { 90 | test_suite *test = BOOST_TEST_SUITE("test the make transform"); 91 | 92 | test->add(BOOST_TEST_CASE(&make_test1)); 93 | test->add(BOOST_TEST_CASE(&make_test2)); 94 | test->add(BOOST_TEST_CASE(&make_test3)); 95 | test->add(BOOST_TEST_CASE(&make_test4)); 96 | 97 | return test; 98 | } 99 | -------------------------------------------------------------------------------- /test/mpl.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // mpl.hpp 3 | // 4 | // Copyright 2012 Eric Niebler. Distributed under the Boost 5 | // Software License, Version 1.0. (See accompanying file 6 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | namespace mpl = boost::mpl; 15 | namespace proto = boost::proto; 16 | namespace fusion = boost::fusion; 17 | using proto::_; 18 | 19 | template 20 | struct my_expr; 21 | 22 | struct my_domain 23 | : proto::domain > 24 | {}; 25 | 26 | template 27 | struct my_expr 28 | : proto::extends, my_domain> 29 | { 30 | my_expr(E const &e = E()) 31 | : proto::extends, my_domain>(e) 32 | {} 33 | 34 | typedef fusion::fusion_sequence_tag tag; 35 | }; 36 | 37 | template 38 | void test_impl(T const &) 39 | { 40 | typedef typename mpl::pop_back::type result_type; 41 | BOOST_STATIC_ASSERT( 42 | (boost::is_same< 43 | result_type 44 | , my_expr::type>&> > > 45 | >::value) 46 | ); 47 | } 48 | 49 | // Test that we can call mpl algorithms on proto expression types, and get proto expression types back 50 | void test_mpl() 51 | { 52 | my_expr::type> i; 53 | test_impl(i + i); 54 | } 55 | 56 | using namespace boost::unit_test; 57 | /////////////////////////////////////////////////////////////////////////////// 58 | // init_unit_test_suite 59 | // 60 | test_suite* init_unit_test_suite( int argc, char* argv[] ) 61 | { 62 | test_suite *test = BOOST_TEST_SUITE("test proto mpl integration via fusion"); 63 | 64 | test->add(BOOST_TEST_CASE(&test_mpl)); 65 | 66 | return test; 67 | } 68 | -------------------------------------------------------------------------------- /test/protect.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // protect.hpp 3 | // 4 | // Copyright 2012 Eric Niebler. Distributed under the Boost 5 | // Software License, Version 1.0. (See accompanying file 6 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | namespace proto=boost::proto; 14 | using proto::_; 15 | 16 | template 17 | struct identity 18 | { 19 | typedef T type; 20 | }; 21 | 22 | struct TestWithMake 23 | : proto::make< proto::protect<_> > 24 | {}; 25 | 26 | struct TestWithMake1 27 | : proto::make< identity > > 28 | {}; 29 | 30 | struct TestWithMake2 31 | : proto::make< identity > > 32 | {}; 33 | 34 | struct TestWithMake3 35 | : proto::make< identity > > > 36 | {}; 37 | 38 | struct TestWithMake4 39 | : proto::make< identity > > > 40 | {}; 41 | 42 | struct TestWithMake5 43 | : proto::make< identity > > > > 44 | {}; 45 | 46 | void test_protect_with_make() 47 | { 48 | proto::terminal::type i = {42}; 49 | 50 | _ t = TestWithMake()(i); 51 | _ t1 = TestWithMake1()(i); 52 | int t2 = TestWithMake2()(i); 53 | identity<_> t3 = TestWithMake3()(i); 54 | identity t4 = TestWithMake4()(i); 55 | identity > t5 = TestWithMake5()(i); 56 | } 57 | 58 | //struct TestWithWhen 59 | // : proto::when<_, proto::protect<_>() > 60 | //{}; 61 | 62 | struct TestWithWhen1 63 | : proto::when<_, identity >() > 64 | {}; 65 | 66 | struct TestWithWhen2 67 | : proto::when<_, identity >() > 68 | {}; 69 | 70 | struct TestWithWhen3 71 | : proto::when<_, identity > >() > 72 | {}; 73 | 74 | struct TestWithWhen4 75 | : proto::when<_, identity > >() > 76 | {}; 77 | 78 | struct TestWithWhen5 79 | : proto::when<_, identity > > >() > 80 | {}; 81 | 82 | void test_protect_with_when() 83 | { 84 | proto::terminal::type i = {42}; 85 | 86 | //_ t = TestWithWhen()(i); 87 | _ t1 = TestWithWhen1()(i); 88 | int t2 = TestWithWhen2()(i); 89 | identity<_> t3 = TestWithWhen3()(i); 90 | identity t4 = TestWithWhen4()(i); 91 | identity > t5 = TestWithWhen5()(i); 92 | } 93 | 94 | using namespace boost::unit_test; 95 | /////////////////////////////////////////////////////////////////////////////// 96 | // init_unit_test_suite 97 | // 98 | test_suite* init_unit_test_suite( int argc, char* argv[] ) 99 | { 100 | test_suite *test = BOOST_TEST_SUITE("test proto::protect"); 101 | 102 | test->add(BOOST_TEST_CASE(&test_protect_with_make)); 103 | test->add(BOOST_TEST_CASE(&test_protect_with_when)); 104 | 105 | return test; 106 | } 107 | -------------------------------------------------------------------------------- /test/switch.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // new_switch.cpp 3 | // 4 | // Copyright 2011 Eric Niebler 5 | // Copyright Pierre Esterie & Joel Falcou. 6 | // Distributed under the Boost 7 | // Software License, Version 1.0. (See accompanying file 8 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace proto = boost::proto; 19 | 20 | struct MyCases 21 | { 22 | template 23 | struct case_ 24 | : proto::not_ 25 | {}; 26 | }; 27 | 28 | template<> 29 | struct MyCases::case_ 30 | : proto::_ 31 | {}; 32 | 33 | template<> 34 | struct MyCases::case_ 35 | : proto::_ 36 | {}; 37 | 38 | struct ArityOf; 39 | 40 | struct ArityOfCases 41 | { 42 | template 43 | struct case_ 44 | : proto::not_ 45 | {}; 46 | }; 47 | 48 | 49 | template<> 50 | struct ArityOfCases::case_ > 51 | : boost::proto::when 52 | {}; 53 | 54 | template<> 55 | struct ArityOfCases::case_ > 56 | : boost::proto::when 57 | {}; 58 | 59 | struct ArityOf 60 | : boost::proto::switch_< 61 | ArityOfCases 62 | , proto::arity_of() 63 | > 64 | {}; 65 | 66 | void test_switch() 67 | { 68 | // Tests for backward compatibility 69 | proto::assert_matches >(proto::lit(1) >> 'a'); 70 | proto::assert_matches >(proto::lit(1) + 'a'); 71 | proto::assert_matches_not >(proto::lit(1) << 'a'); 72 | 73 | //Test new matching on the Transform result type 74 | ArityOf ar; 75 | 76 | proto::assert_matches_not(proto::lit(1)); 77 | proto::assert_matches(proto::lit(1) + 2); 78 | proto::assert_matches(!proto::lit(1)); 79 | BOOST_CHECK_EQUAL(ar(!proto::lit(1)), false); 80 | BOOST_CHECK_EQUAL(ar(proto::lit(1) + 2), true); 81 | } 82 | 83 | using namespace boost::unit_test; 84 | /////////////////////////////////////////////////////////////////////////////// 85 | // init_unit_test_suite 86 | // 87 | test_suite* init_unit_test_suite(int argc, char* argv[]) 88 | { 89 | test_suite *test = BOOST_TEST_SUITE("test proto::switch_<>"); 90 | 91 | test->add(BOOST_TEST_CASE(&test_switch)); 92 | 93 | return test; 94 | } 95 | 96 | --------------------------------------------------------------------------------