1
0
mirror of https://git.suyu.dev/suyu/suyu synced 2025-09-20 21:12:09 -05:00

Initial commit

This commit is contained in:
Crimson-Hawk
2024-03-05 16:42:40 +08:00
commit f1e4595ebf
39576 changed files with 7006612 additions and 0 deletions

View File

View File

View File

@@ -0,0 +1,64 @@
# Use, modification, and distribution are
# subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE.txt)
#
# Copyright Rene Rivera 2020.
# For Drone CI we use the Starlark scripting language to reduce duplication.
# As the yaml syntax for Drone CI is rather limited.
#
#
globalenv={}
linuxglobalimage="cppalliance/droneubuntu1604:1"
windowsglobalimage="cppalliance/dronevs2019"
def main(ctx):
return [
linux_cxx("TOOLSET=gcc-4.4 CXXSTD=98,0x Job 0", "g++", packages="g++-4.4", buildtype="boost", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'gcc-4.4', 'CXXSTD': '98,0x', 'DRONE_JOB_UUID': 'b6589fc6ab'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-4.6 CXXSTD=03,0x Job 1", "g++", packages="g++-4.6", buildtype="boost", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'gcc-4.6', 'CXXSTD': '03,0x', 'DRONE_JOB_UUID': '356a192b79'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-4.7 CXXSTD=03,11 Job 2", "g++", packages="g++-4.7", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-4.7', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'da4b9237ba'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-4.8 CXXSTD=03,11 Job 3", "g++", packages="g++-4.8", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-4.8', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '77de68daec'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-4.8 CXXSTD=1y Job 4", "g++", packages="g++-4.8", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-4.8', 'CXXSTD': '1y', 'DRONE_JOB_UUID': '1b64538924'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-4.9 CXXSTD=03,11 Job 5", "g++", packages="g++-4.9", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-4.9', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'ac3478d69a'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-4.9 CXXSTD=14 Job 6", "g++", packages="g++-4.9", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-4.9', 'CXXSTD': '14', 'DRONE_JOB_UUID': 'c1dfd96eea'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-5 CXXSTD=03,11 Job 7", "g++", packages="g++-5", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-5', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '902ba3cda1'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-5 CXXSTD=14,17 Job 8", "g++", packages="g++-5", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-5', 'CXXSTD': '14,17', 'DRONE_JOB_UUID': 'fe5dbbcea5'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-6 CXXSTD=03,11 Job 9", "g++", packages="g++-6", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-6', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '0ade7c2cf9'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-6 CXXSTD=14,17 Job 10", "g++", packages="g++-6", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-6', 'CXXSTD': '14,17', 'DRONE_JOB_UUID': 'b1d5781111'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-7 CXXSTD=03,11 Job 11", "g++", packages="g++-7", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-7', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '17ba079149'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-7 CXXSTD=14,17 Job 12", "g++", packages="g++-7", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-7', 'CXXSTD': '14,17', 'DRONE_JOB_UUID': '7b52009b64'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-8 CXXSTD=03,11 Job 13", "g++", packages="g++-8", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-8', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'bd307a3ec3'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-8 CXXSTD=14,17 Job 14", "g++", packages="g++-8", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-8', 'CXXSTD': '14,17', 'DRONE_JOB_UUID': 'fa35e19212'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-8 CXXSTD=2a Job 15", "g++", packages="g++-8", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-8', 'CXXSTD': '2a', 'DRONE_JOB_UUID': 'f1abd67035'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-9 CXXSTD=03,11,14 SANITIZED Job 16", "g++", packages="g++-9", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-9', 'CXXSTD': '03,11,14', 'DRONE_JOB_UUID': '1574bddb75'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc-9 CXXSTD=17,2a SANITIZED Job 17", "g++", packages="g++-9", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'gcc-9', 'CXXSTD': '17,2a', 'DRONE_JOB_UUID': '0716d9708d'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-3.5 CXXSTD=03,11 Job 18", "g++", packages="clang-3.5", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-3.5', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '9e6a55b6b4'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-3.6 CXXSTD=03,11 Job 19", "g++", packages="clang-3.6", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-3.6', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'b3f0c7f6bb'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-3.6 CXXSTD=14,1z Job 20", "g++", packages="clang-3.6", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-3.6', 'CXXSTD': '14,1z', 'DRONE_JOB_UUID': '91032ad7bb'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-3.7 CXXSTD=03,11 Job 21", "g++", packages="clang-3.7", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-3.7', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '472b07b9fc'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-3.7 CXXSTD=14,1z Job 22", "g++", packages="clang-3.7", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-3.7', 'CXXSTD': '14,1z', 'DRONE_JOB_UUID': '12c6fc06c9'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-3.8 CXXSTD=03,11 Job 23", "g++", packages="clang-3.8", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-3.8', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'd435a6cdd7'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-3.8 CXXSTD=14,1z Job 24", "g++", packages="clang-3.8", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-3.8', 'CXXSTD': '14,1z', 'DRONE_JOB_UUID': '4d134bc072'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-3.9 CXXSTD=03,11 Job 25", "g++", packages="clang-3.9", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-3.9', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'f6e1126ced'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-3.9 CXXSTD=14,1z Job 26", "g++", packages="clang-3.9", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-3.9', 'CXXSTD': '14,1z', 'DRONE_JOB_UUID': '887309d048'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-4.0 CXXSTD=03,11 Job 27", "g++", packages="clang-4.0", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-4.0', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'bc33ea4e26'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-4.0 CXXSTD=14,1z Job 28", "g++", packages="clang-4.0", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-4.0', 'CXXSTD': '14,1z', 'DRONE_JOB_UUID': '0a57cb53ba'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-5.0 CXXSTD=03,11 Job 29", "g++", packages="clang-5.0", llvm_os="xenial", llvm_ver="5.0", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-5.0', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '7719a1c782'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-5.0 CXXSTD=14,17 Job 30", "g++", packages="clang-5.0", llvm_os="xenial", llvm_ver="5.0", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-5.0', 'CXXSTD': '14,17', 'DRONE_JOB_UUID': '22d200f867'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-5.0 CXXSTD=2a Job 31", "g++", packages="clang-5.0", llvm_os="xenial", llvm_ver="5.0", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-5.0', 'CXXSTD': '2a', 'DRONE_JOB_UUID': '632667547e'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-6.0 CXXSTD=03,11 Job 32", "g++", packages="clang-6.0", llvm_os="xenial", llvm_ver="6.0", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-6.0', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'cb4e5208b4'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-6.0 CXXSTD=14,17 Job 33", "g++", packages="clang-6.0", llvm_os="xenial", llvm_ver="6.0", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-6.0', 'CXXSTD': '14,17', 'DRONE_JOB_UUID': 'b6692ea5df'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-6.0 CXXSTD=2a Job 34", "g++", packages="clang-6.0", llvm_os="xenial", llvm_ver="6.0", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-6.0', 'CXXSTD': '2a', 'DRONE_JOB_UUID': 'f1f836cb4e'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-7 CXXSTD=03,11 Job 35", "g++", packages="clang-7", llvm_os="xenial", llvm_ver="7", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-7', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '972a67c481'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-7 CXXSTD=14,17 Job 36", "g++", packages="clang-7", llvm_os="xenial", llvm_ver="7", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-7', 'CXXSTD': '14,17', 'DRONE_JOB_UUID': 'fc074d5013'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-7 CXXSTD=2a Job 37", "g++", packages="clang-7", llvm_os="xenial", llvm_ver="7", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-7', 'CXXSTD': '2a', 'DRONE_JOB_UUID': 'cb7a1d775e'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-8 CXXSTD=03,11,14 Job 38", "g++", packages="clang-8", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-8', 'CXXSTD': '03,11,14', 'DRONE_JOB_UUID': '5b384ce32d'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-8 CXXSTD=17,2a Job 39", "g++", packages="clang-8", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'TOOLSET': 'clang-8', 'CXXSTD': '17,2a', 'DRONE_JOB_UUID': 'ca3512f4df'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-9 CXXSTD=03,11,14 SANITIZED Job 40", "g++", packages="clang-9", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang-9', 'CXXSTD': '03,11,14', 'DRONE_JOB_UUID': 'af3e133428'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang-9 CXXSTD=17,2a SANITIZED Job 41", "g++", packages="clang-9", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang-9', 'CXXSTD': '17,2a', 'DRONE_JOB_UUID': '761f22b2c1'}, globalenv=globalenv),
osx_cxx("TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 Job 42", "clang++", packages="", buildtype="boost", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '92cfceb39d'}, globalenv=globalenv),
osx_cxx("TOOLSET=clang COMPILER=clang++ CXXSTD=14,1z Job 43", "clang++", packages="", buildtype="boost", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '14,1z', 'DRONE_JOB_UUID': '0286dd552c'}, globalenv=globalenv),
]
# from https://github.com/boostorg/boost-ci
load("@boost_ci//ci/drone/:functions.star", "linux_cxx","windows_cxx","osx_cxx","freebsd_cxx")

View File

@@ -0,0 +1,3 @@
#!/bin/bash

View File

@@ -0,0 +1,3 @@
#!/bin/bash

View File

@@ -0,0 +1,3 @@
#!/bin/bash

View File

@@ -0,0 +1,120 @@
#!/bin/bash
set -ex
export TRAVIS_BUILD_DIR=$(pwd)
export DRONE_BUILD_DIR=$(pwd)
export TRAVIS_BRANCH=$DRONE_BRANCH
export VCS_COMMIT_ID=$DRONE_COMMIT
export GIT_COMMIT=$DRONE_COMMIT
export REPO_NAME=$DRONE_REPO
export PATH=~/.local/bin:/usr/local/bin:$PATH
echo '==================================> BEFORE_INSTALL'
. .drone/before-install.sh
echo '==================================> INSTALL'
BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
cd ..
git clone --depth 1 -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule init libs/algorithm
git submodule init libs/any
git submodule init libs/array
git submodule init libs/assert
git submodule init libs/assign
git submodule init libs/atomic
git submodule init libs/bind
git submodule init libs/chrono
git submodule init libs/circular_buffer
git submodule init libs/concept_check
git submodule init libs/config
git submodule init libs/container
git submodule init libs/container_hash
git submodule init libs/conversion
git submodule init libs/core
git submodule init libs/date_time
git submodule init libs/detail
git submodule init libs/endian
git submodule init libs/exception
git submodule init libs/filesystem
git submodule init libs/foreach
git submodule init libs/format
git submodule init libs/function
git submodule init libs/function_types
git submodule init libs/functional
git submodule init libs/fusion
git submodule init libs/integer
git submodule init libs/intrusive
git submodule init libs/io
git submodule init libs/iostreams
git submodule init libs/iterator
git submodule init libs/lambda
git submodule init libs/lexical_cast
git submodule init libs/locale
git submodule init libs/log
git submodule init libs/math
git submodule init libs/move
git submodule init libs/mp11
git submodule init libs/mpl
git submodule init libs/multi_index
git submodule init libs/numeric/conversion
git submodule init libs/optional
git submodule init libs/parameter
git submodule init libs/pool
git submodule init libs/predef
git submodule init libs/preprocessor
git submodule init libs/property_tree
git submodule init libs/proto
git submodule init libs/ptr_container
git submodule init libs/python
git submodule init libs/random
git submodule init libs/range
git submodule init libs/ratio
git submodule init libs/rational
git submodule init libs/regex
git submodule init libs/serialization
git submodule init libs/signals2
git submodule init libs/smart_ptr
git submodule init libs/spirit
git submodule init libs/static_assert
git submodule init libs/system
git submodule init libs/thread
git submodule init libs/throw_exception
git submodule init libs/tokenizer
git submodule init libs/tti
git submodule init libs/tuple
git submodule init libs/type_index
git submodule init libs/type_traits
git submodule init libs/typeof
git submodule init libs/unordered
git submodule init libs/utility
git submodule init libs/variant
git submodule init libs/winapi
git submodule init libs/xpressive
git submodule init libs/headers tools/boost_install tools/build
git submodule update --jobs 8
rm -rf libs/phoenix
cp -rp $TRAVIS_BUILD_DIR libs/phoenix
ln -s $(pwd)/libs/phoenix $TRAVIS_BUILD_DIR
./bootstrap.sh
./b2 headers
if [ $TRAVIS_OS_NAME = osx ]; then
export PATH="/usr/local/opt/ccache/libexec:$PATH"
true brew install ccache
fi
echo "using ${TOOLSET%%-*} : ${TOOLSET#*-} : ccache `echo $TOOLSET | sed 's/clang/clang++/;s/gcc/g++/'` ;" > ~/user-config.jam
echo '==================================> BEFORE_SCRIPT'
. $DRONE_BUILD_DIR/.drone/before-script.sh
echo '==================================> SCRIPT'
./b2 libs/phoenix/test toolset=$TOOLSET cxxstd=$CXXSTD ${SANITIZED+cxxflags=-fsanitize=address,undefined} ${SANITIZED+'linkflags=-fsanitize=address,undefined -fuse-ld=gold'}
echo '==================================> AFTER_SUCCESS'
. $DRONE_BUILD_DIR/.drone/after-success.sh

View File

@@ -0,0 +1,96 @@
* text=auto !eol svneol=native#text/plain
*.gitattributes text svneol=native#text/plain
# Scriptish formats
*.bat text svneol=native#text/plain
*.bsh text svneol=native#text/x-beanshell
*.cgi text svneol=native#text/plain
*.cmd text svneol=native#text/plain
*.js text svneol=native#text/javascript
*.php text svneol=native#text/x-php
*.pl text svneol=native#text/x-perl
*.pm text svneol=native#text/x-perl
*.py text svneol=native#text/x-python
*.sh eol=lf svneol=LF#text/x-sh
configure eol=lf svneol=LF#text/x-sh
# Image formats
*.bmp binary svneol=unset#image/bmp
*.gif binary svneol=unset#image/gif
*.ico binary svneol=unset#image/ico
*.jpeg binary svneol=unset#image/jpeg
*.jpg binary svneol=unset#image/jpeg
*.png binary svneol=unset#image/png
*.tif binary svneol=unset#image/tiff
*.tiff binary svneol=unset#image/tiff
*.svg text svneol=native#image/svg%2Bxml
# Data formats
*.pdf binary svneol=unset#application/pdf
*.avi binary svneol=unset#video/avi
*.doc binary svneol=unset#application/msword
*.dsp text svneol=crlf#text/plain
*.dsw text svneol=crlf#text/plain
*.eps binary svneol=unset#application/postscript
*.gz binary svneol=unset#application/gzip
*.mov binary svneol=unset#video/quicktime
*.mp3 binary svneol=unset#audio/mpeg
*.ppt binary svneol=unset#application/vnd.ms-powerpoint
*.ps binary svneol=unset#application/postscript
*.psd binary svneol=unset#application/photoshop
*.rdf binary svneol=unset#text/rdf
*.rss text svneol=unset#text/xml
*.rtf binary svneol=unset#text/rtf
*.sln text svneol=native#text/plain
*.swf binary svneol=unset#application/x-shockwave-flash
*.tgz binary svneol=unset#application/gzip
*.vcproj text svneol=native#text/xml
*.vcxproj text svneol=native#text/xml
*.vsprops text svneol=native#text/xml
*.wav binary svneol=unset#audio/wav
*.xls binary svneol=unset#application/vnd.ms-excel
*.zip binary svneol=unset#application/zip
# Text formats
.htaccess text svneol=native#text/plain
*.bbk text svneol=native#text/xml
*.cmake text svneol=native#text/plain
*.css text svneol=native#text/css
*.dtd text svneol=native#text/xml
*.htm text svneol=native#text/html
*.html text svneol=native#text/html
*.ini text svneol=native#text/plain
*.log text svneol=native#text/plain
*.mak text svneol=native#text/plain
*.qbk text svneol=native#text/plain
*.rst text svneol=native#text/plain
*.sql text svneol=native#text/x-sql
*.txt text svneol=native#text/plain
*.xhtml text svneol=native#text/xhtml%2Bxml
*.xml text svneol=native#text/xml
*.xsd text svneol=native#text/xml
*.xsl text svneol=native#text/xml
*.xslt text svneol=native#text/xml
*.xul text svneol=native#text/xul
*.yml text svneol=native#text/plain
boost-no-inspect text svneol=native#text/plain
CHANGES text svneol=native#text/plain
COPYING text svneol=native#text/plain
INSTALL text svneol=native#text/plain
Jamfile text svneol=native#text/plain
Jamroot text svneol=native#text/plain
Jamfile.v2 text svneol=native#text/plain
Jamrules text svneol=native#text/plain
Makefile* text svneol=native#text/plain
README text svneol=native#text/plain
TODO text svneol=native#text/plain
# Code formats
*.c text svneol=native#text/plain
*.cpp text svneol=native#text/plain
*.h text svneol=native#text/plain
*.hpp text svneol=native#text/plain
*.ipp text svneol=native#text/plain
*.tpp text svneol=native#text/plain
*.jam text svneol=native#text/plain
*.java text svneol=native#text/plain

View File

@@ -0,0 +1,11 @@
#!/bin/bash
# Copyright 2020 Rene Rivera, Sam Darwin
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt)
if [ "$JOB_UUID" = "92cfceb39d" ] || [ "$JOB_UUID" = "0286dd552c" ] ; then
brew install ccache || true;
fi

View File

@@ -0,0 +1,882 @@
name: GitHub Actions CI
on:
pull_request:
push:
branches:
- master
- develop
- githubactions*
- feature/**
- fix/**
- pr/**
jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- name: "TOOLSET=gcc-4.4 CXXSTD=98,0x Job 0"
buildtype: "boost"
packages: "g++-4.4 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
container: "ubuntu:14.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-4.4"
cxxstd: "98,0x"
job_uuid: "b6589fc6ab"
- name: "TOOLSET=gcc-4.6 CXXSTD=03,0x Job 1"
buildtype: "boost"
packages: "g++-4.6 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-4.6"
cxxstd: "03,0x"
job_uuid: "356a192b79"
- name: "TOOLSET=gcc-4.7 CXXSTD=03,11 Job 2"
buildtype: "boost"
packages: "g++-4.7 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-4.7"
cxxstd: "03,11"
job_uuid: "da4b9237ba"
- name: "TOOLSET=gcc-4.8 CXXSTD=03,11 Job 3"
buildtype: "boost"
packages: "g++-4.8 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-4.8"
cxxstd: "03,11"
job_uuid: "77de68daec"
- name: "TOOLSET=gcc-4.8 CXXSTD=1y Job 4"
buildtype: "boost"
packages: "g++-4.8 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-4.8"
cxxstd: "1y"
job_uuid: "1b64538924"
- name: "TOOLSET=gcc-4.9 CXXSTD=03,11 Job 5"
buildtype: "boost"
packages: "g++-4.9 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-4.9"
cxxstd: "03,11"
job_uuid: "ac3478d69a"
- name: "TOOLSET=gcc-4.9 CXXSTD=14 Job 6"
buildtype: "boost"
packages: "g++-4.9 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-4.9"
cxxstd: "14"
job_uuid: "c1dfd96eea"
- name: "TOOLSET=gcc-5 CXXSTD=03,11 Job 7"
buildtype: "boost"
packages: "g++-5 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-5"
cxxstd: "03,11"
job_uuid: "902ba3cda1"
- name: "TOOLSET=gcc-5 CXXSTD=14,17 Job 8"
buildtype: "boost"
packages: "g++-5 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-5"
cxxstd: "14,17"
job_uuid: "fe5dbbcea5"
- name: "TOOLSET=gcc-6 CXXSTD=03,11 Job 9"
buildtype: "boost"
packages: "g++-6 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-6"
cxxstd: "03,11"
job_uuid: "0ade7c2cf9"
- name: "TOOLSET=gcc-6 CXXSTD=14,17 Job 10"
buildtype: "boost"
packages: "g++-6 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-6"
cxxstd: "14,17"
job_uuid: "b1d5781111"
- name: "TOOLSET=gcc-7 CXXSTD=03,11 Job 11"
buildtype: "boost"
packages: "g++-7 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-7"
cxxstd: "03,11"
job_uuid: "17ba079149"
- name: "TOOLSET=gcc-7 CXXSTD=14,17 Job 12"
buildtype: "boost"
packages: "g++-7 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-7"
cxxstd: "14,17"
job_uuid: "7b52009b64"
- name: "TOOLSET=gcc-8 CXXSTD=03,11 Job 13"
buildtype: "boost"
packages: "g++-8 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-8"
cxxstd: "03,11"
job_uuid: "bd307a3ec3"
- name: "TOOLSET=gcc-8 CXXSTD=14,17 Job 14"
buildtype: "boost"
packages: "g++-8 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-8"
cxxstd: "14,17"
job_uuid: "fa35e19212"
- name: "TOOLSET=gcc-8 CXXSTD=2a Job 15"
buildtype: "boost"
packages: "g++-8 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-8"
cxxstd: "2a"
job_uuid: "f1abd67035"
- name: "TOOLSET=gcc-9 CXXSTD=03,11,14 SANITIZED Job 16"
buildtype: "boost"
packages: "g++-9 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-9"
cxxstd: "03,11,14"
job_uuid: "1574bddb75"
- name: "TOOLSET=gcc-9 CXXSTD=17,2a SANITIZED Job 17"
buildtype: "boost"
packages: "g++-9 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc-9"
cxxstd: "17,2a"
job_uuid: "0716d9708d"
- name: "TOOLSET=clang-3.5 CXXSTD=03,11 Job 18"
buildtype: "boost"
packages: "clang-3.5 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-3.5"
cxxstd: "03,11"
job_uuid: "9e6a55b6b4"
- name: "TOOLSET=clang-3.6 CXXSTD=03,11 Job 19"
buildtype: "boost"
packages: "clang-3.6 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-3.6"
cxxstd: "03,11"
job_uuid: "b3f0c7f6bb"
- name: "TOOLSET=clang-3.6 CXXSTD=14,1z Job 20"
buildtype: "boost"
packages: "clang-3.6 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-3.6"
cxxstd: "14"
job_uuid: "91032ad7bb"
- name: "TOOLSET=clang-3.7 CXXSTD=03,11 Job 21"
buildtype: "boost"
packages: "clang-3.7 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-3.7"
cxxstd: "03,11"
job_uuid: "472b07b9fc"
- name: "TOOLSET=clang-3.7 CXXSTD=14,1z Job 22"
buildtype: "boost"
packages: "clang-3.7 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-3.7"
cxxstd: "14"
job_uuid: "12c6fc06c9"
- name: "TOOLSET=clang-3.8 CXXSTD=03,11 Job 23"
buildtype: "boost"
packages: "clang-3.8 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-3.8"
cxxstd: "03,11"
job_uuid: "d435a6cdd7"
- name: "TOOLSET=clang-3.8 CXXSTD=14,1z Job 24"
buildtype: "boost"
packages: "clang-3.8 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-3.8"
cxxstd: "14"
job_uuid: "4d134bc072"
- name: "TOOLSET=clang-3.9 CXXSTD=03,11 Job 25"
buildtype: "boost"
packages: "clang-3.9 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-3.9"
cxxstd: "03,11"
job_uuid: "f6e1126ced"
- name: "TOOLSET=clang-3.9 CXXSTD=14,1z Job 26"
buildtype: "boost"
packages: "clang-3.9 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-3.9"
cxxstd: "14"
job_uuid: "887309d048"
- name: "TOOLSET=clang-4.0 CXXSTD=03,11 Job 27"
buildtype: "boost"
packages: "clang-4.0 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-4.0"
cxxstd: "03,11"
job_uuid: "bc33ea4e26"
- name: "TOOLSET=clang-4.0 CXXSTD=14,1z Job 28"
buildtype: "boost"
packages: "clang-4.0 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-4.0"
cxxstd: "14"
job_uuid: "0a57cb53ba"
- name: "TOOLSET=clang-5.0 CXXSTD=03,11 Job 29"
buildtype: "boost"
packages: "clang-5.0 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: "xenial"
llvm_ver: "5.0"
toolset: "clang-5.0"
cxxstd: "03,11"
job_uuid: "7719a1c782"
- name: "TOOLSET=clang-5.0 CXXSTD=14,17 Job 30"
buildtype: "boost"
packages: "clang-5.0 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: "xenial"
llvm_ver: "5.0"
toolset: "clang-5.0"
cxxstd: "14,17"
job_uuid: "22d200f867"
- name: "TOOLSET=clang-5.0 CXXSTD=2a Job 31"
buildtype: "boost"
packages: "clang-5.0 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: "xenial"
llvm_ver: "5.0"
toolset: "clang-5.0"
cxxstd: "2a"
job_uuid: "632667547e"
- name: "TOOLSET=clang-6.0 CXXSTD=03,11 Job 32"
buildtype: "boost"
packages: "clang-6.0 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: "xenial"
llvm_ver: "6.0"
toolset: "clang-6.0"
cxxstd: "03,11"
job_uuid: "cb4e5208b4"
- name: "TOOLSET=clang-6.0 CXXSTD=14,17 Job 33"
buildtype: "boost"
packages: "clang-6.0 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: "xenial"
llvm_ver: "6.0"
toolset: "clang-6.0"
cxxstd: "14,17"
job_uuid: "b6692ea5df"
- name: "TOOLSET=clang-6.0 CXXSTD=2a Job 34"
buildtype: "boost"
packages: "clang-6.0 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: "xenial"
llvm_ver: "6.0"
toolset: "clang-6.0"
cxxstd: "2a"
job_uuid: "f1f836cb4e"
- name: "TOOLSET=clang-7 CXXSTD=03,11 Job 35"
buildtype: "boost"
packages: "clang-7 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: "xenial"
llvm_ver: "7"
toolset: "clang-7"
cxxstd: "03,11"
job_uuid: "972a67c481"
- name: "TOOLSET=clang-7 CXXSTD=14,17 Job 36"
buildtype: "boost"
packages: "clang-7 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: "xenial"
llvm_ver: "7"
toolset: "clang-7"
cxxstd: "14,17"
job_uuid: "fc074d5013"
- name: "TOOLSET=clang-7 CXXSTD=2a Job 37"
buildtype: "boost"
packages: "clang-7 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: "xenial"
llvm_ver: "7"
toolset: "clang-7"
cxxstd: "2a"
job_uuid: "cb7a1d775e"
- name: "TOOLSET=clang-8 CXXSTD=03,11,14 Job 38"
buildtype: "boost"
packages: "clang-8 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-8"
cxxstd: "03,11,14"
job_uuid: "5b384ce32d"
- name: "TOOLSET=clang-8 CXXSTD=17,2a Job 39"
buildtype: "boost"
packages: "clang-8 ccache"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-8"
cxxstd: "17,2a"
job_uuid: "ca3512f4df"
- name: "TOOLSET=clang-9 CXXSTD=03,11,14 SANITIZED Job 40"
buildtype: "boost"
packages: "clang-9 ccache"
packages_to_remove: ""
os: "ubuntu-18.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-9"
cxxstd: "03,11,14"
job_uuid: "af3e133428"
- name: "TOOLSET=clang-9 CXXSTD=17,2a SANITIZED Job 41"
buildtype: "boost"
packages: "clang-9 ccache"
packages_to_remove: ""
os: "ubuntu-18.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang-9"
cxxstd: "17,2a"
job_uuid: "761f22b2c1"
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Check if running in container
if: matrix.container != ''
run: echo "GHA_CONTAINER=${{ matrix.container }}" >> $GITHUB_ENV
- name: If running in container, upgrade packages
if: matrix.container != ''
run: |
sudo apt-get -o Acquire::Retries=3 update && DEBIAN_FRONTEND=noninteractive apt-get -y install tzdata && apt-get -o Acquire::Retries=3 install -y sudo software-properties-common wget curl apt-transport-https make apt-file sudo unzip libssl-dev build-essential autotools-dev autoconf automake g++ libc++-helpers python python-pip ruby cpio gcc-multilib g++-multilib pkgconf python3 python3-pip ccache libpython-dev
sudo apt-add-repository ppa:git-core/ppa
sudo apt-get -o Acquire::Retries=3 update && apt-get -o Acquire::Retries=3 -y install git
sudo python -m pip install --upgrade pip==20.3.4
sudo /usr/local/bin/pip install cmake
- uses: actions/checkout@v2
- name: linux
shell: bash
env:
CXX: ${{ matrix.cxx }}
SOURCES: ${{ matrix.sources }}
LLVM_OS: ${{ matrix.llvm_os }}
LLVM_VER: ${{ matrix.llvm_ver }}
PACKAGES: ${{ matrix.packages }}
PACKAGES_TO_REMOVE: ${{ matrix.packages_to_remove }}
JOB_BUILDTYPE: ${{ matrix.buildtype }}
TOOLSET: ${{ matrix.toolset }}
CXXSTD: ${{ matrix.cxxstd }}
COMPILER: ${{ matrix.compiler }}
TRAVIS_BRANCH: ${{ github.base_ref }}
TRAVIS_OS_NAME: "linux"
JOB_UUID: ${{ matrix.job_uuid }}
run: |
echo '==================================> SETUP'
echo '==================================> PACKAGES'
set -e
if [ -n "$PACKAGES_TO_REMOVE" ]; then sudo apt-get purge -y $PACKAGES_TO_REMOVE; fi
echo ">>>>> APT: REPO.."
for i in {1..3}; do sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test" && break || sleep 2; done
if test -n "${LLVM_OS}" ; then
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
if test -n "${LLVM_VER}" ; then
sudo -E apt-add-repository "deb http://apt.llvm.org/${LLVM_OS}/ llvm-toolchain-${LLVM_OS}-${LLVM_VER} main"
else
# Snapshot (i.e. trunk) build of clang
sudo -E apt-add-repository "deb http://apt.llvm.org/${LLVM_OS}/ llvm-toolchain-${LLVM_OS} main"
fi
fi
echo ">>>>> APT: UPDATE.."
sudo -E apt-get -o Acquire::Retries=3 update
if test -n "${SOURCES}" ; then
echo ">>>>> APT: INSTALL SOURCES.."
for SOURCE in $SOURCES; do
sudo -E apt-add-repository ppa:$SOURCE
done
fi
echo ">>>>> APT: INSTALL ${PACKAGES}.."
sudo -E DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=3 -y --no-install-suggests --no-install-recommends install ${PACKAGES}
echo '==================================> INSTALL AND COMPILE'
set -e
export TRAVIS_BUILD_DIR=$(pwd)
export TRAVIS_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
export VCS_COMMIT_ID=$GITHUB_SHA
export GIT_COMMIT=$GITHUB_SHA
export REPO_NAME=$(basename $GITHUB_REPOSITORY)
export USER=$(whoami)
export CC=${CC:-gcc}
export PATH=~/.local/bin:/usr/local/bin:$PATH
if [ "$JOB_BUILDTYPE" == "boost" ]; then
echo '==================================> BEFORE_INSTALL'
. .github/scripts/before-install.sh
echo '==================================> INSTALL'
BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
cd ..
git clone --depth 1 -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule init libs/algorithm
git submodule init libs/any
git submodule init libs/array
git submodule init libs/assert
git submodule init libs/assign
git submodule init libs/atomic
git submodule init libs/bind
git submodule init libs/chrono
git submodule init libs/circular_buffer
git submodule init libs/concept_check
git submodule init libs/config
git submodule init libs/container
git submodule init libs/container_hash
git submodule init libs/conversion
git submodule init libs/core
git submodule init libs/date_time
git submodule init libs/detail
git submodule init libs/endian
git submodule init libs/exception
git submodule init libs/filesystem
git submodule init libs/foreach
git submodule init libs/format
git submodule init libs/function
git submodule init libs/function_types
git submodule init libs/functional
git submodule init libs/fusion
git submodule init libs/integer
git submodule init libs/intrusive
git submodule init libs/io
git submodule init libs/iostreams
git submodule init libs/iterator
git submodule init libs/lambda
git submodule init libs/lexical_cast
git submodule init libs/locale
git submodule init libs/log
git submodule init libs/math
git submodule init libs/move
git submodule init libs/mp11
git submodule init libs/mpl
git submodule init libs/multi_index
git submodule init libs/numeric/conversion
git submodule init libs/optional
git submodule init libs/parameter
git submodule init libs/pool
git submodule init libs/predef
git submodule init libs/preprocessor
git submodule init libs/property_tree
git submodule init libs/proto
git submodule init libs/ptr_container
git submodule init libs/python
git submodule init libs/random
git submodule init libs/range
git submodule init libs/ratio
git submodule init libs/rational
git submodule init libs/regex
git submodule init libs/serialization
git submodule init libs/signals2
git submodule init libs/smart_ptr
git submodule init libs/spirit
git submodule init libs/static_assert
git submodule init libs/system
git submodule init libs/thread
git submodule init libs/throw_exception
git submodule init libs/tokenizer
git submodule init libs/tti
git submodule init libs/tuple
git submodule init libs/type_index
git submodule init libs/type_traits
git submodule init libs/typeof
git submodule init libs/unordered
git submodule init libs/utility
git submodule init libs/variant
git submodule init libs/winapi
git submodule init libs/xpressive
git submodule init libs/headers tools/boost_install tools/build
git submodule update --jobs 8
rm -rf libs/phoenix
cp -rp $TRAVIS_BUILD_DIR libs/phoenix
ln -s $(pwd)/libs/phoenix $TRAVIS_BUILD_DIR
./bootstrap.sh
./b2 headers
if [ $TRAVIS_OS_NAME = osx ]; then
export PATH="/usr/local/opt/ccache/libexec:$PATH"
true brew install ccache
fi
echo "using ${TOOLSET%%-*} : ${TOOLSET#*-} : ccache `echo $TOOLSET | sed 's/clang/clang++/;s/gcc/g++/'` ;" > ~/user-config.jam
echo '==================================> SCRIPT'
./b2 libs/phoenix/test toolset=$TOOLSET cxxstd=$CXXSTD ${SANITIZED+cxxflags=-fsanitize=address,undefined} ${SANITIZED+'linkflags=-fsanitize=address,undefined -fuse-ld=gold'}
fi
osx:
strategy:
fail-fast: false
matrix:
include:
- name: "TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 Job 42"
buildtype: "boost"
packages: ""
os: "macos-10.15"
cxx: "clang++"
sources: ""
llvm_os: ""
llvm_ver: ""
xcode_version: 11.7
toolset: "clang"
compiler: "clang++"
cxxstd: "03,11"
job_uuid: "92cfceb39d"
- name: "TOOLSET=clang COMPILER=clang++ CXXSTD=14,1z Job 43"
buildtype: "boost"
packages: ""
os: "macos-10.15"
cxx: "clang++"
sources: ""
llvm_os: ""
llvm_ver: ""
xcode_version: 11.7
toolset: "clang"
compiler: "clang++"
cxxstd: "14,1z"
job_uuid: "0286dd552c"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set DEVELOPER_DIR
if: matrix.xcode_version != ''
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer" >> $GITHUB_ENV
- name: Test DEVELOPER_DIR
run: echo $DEVELOPER_DIR
- name: "osx"
shell: bash
env:
CXX: ${{ matrix.cxx }}
SOURCES: ${{ matrix.sources }}
LLVM_OS: ${{ matrix.llvm_os }}
LLVM_VER: ${{ matrix.llvm_ver }}
PACKAGES: ${{ matrix.packages }}
JOB_BUILDTYPE: ${{ matrix.buildtype }}
TOOLSET: ${{ matrix.toolset }}
CXXSTD: ${{ matrix.cxxstd }}
COMPILER: ${{ matrix.compiler }}
TRAVIS_BRANCH: ${{ github.base_ref }}
TRAVIS_OS_NAME: "osx"
JOB_UUID: ${{ matrix.job_uuid }}
run: |
echo '==================================> SETUP'
set -e
sudo mv /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools.bck
echo '==================================> PACKAGES'
echo '==================================> INSTALL AND COMPILE'
set -e
export TRAVIS_BUILD_DIR=$(pwd)
export TRAVIS_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
export VCS_COMMIT_ID=$GITHUB_SHA
export GIT_COMMIT=$GITHUB_SHA
export REPO_NAME=$(basename $GITHUB_REPOSITORY)
export USER=$(whoami)
export CC=${CC:-gcc}
export PATH=~/.local/bin:/usr/local/bin:$PATH
if [ "$JOB_BUILDTYPE" == "boost" ]; then
echo '==================================> BEFORE_INSTALL'
. .github/scripts/before-install.sh
echo '==================================> INSTALL'
BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
cd ..
git clone --depth 1 -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule init libs/algorithm
git submodule init libs/any
git submodule init libs/array
git submodule init libs/assert
git submodule init libs/assign
git submodule init libs/atomic
git submodule init libs/bind
git submodule init libs/chrono
git submodule init libs/circular_buffer
git submodule init libs/concept_check
git submodule init libs/config
git submodule init libs/container
git submodule init libs/container_hash
git submodule init libs/conversion
git submodule init libs/core
git submodule init libs/date_time
git submodule init libs/detail
git submodule init libs/endian
git submodule init libs/exception
git submodule init libs/filesystem
git submodule init libs/foreach
git submodule init libs/format
git submodule init libs/function
git submodule init libs/function_types
git submodule init libs/functional
git submodule init libs/fusion
git submodule init libs/integer
git submodule init libs/intrusive
git submodule init libs/io
git submodule init libs/iostreams
git submodule init libs/iterator
git submodule init libs/lambda
git submodule init libs/lexical_cast
git submodule init libs/locale
git submodule init libs/log
git submodule init libs/math
git submodule init libs/move
git submodule init libs/mp11
git submodule init libs/mpl
git submodule init libs/multi_index
git submodule init libs/numeric/conversion
git submodule init libs/optional
git submodule init libs/parameter
git submodule init libs/pool
git submodule init libs/predef
git submodule init libs/preprocessor
git submodule init libs/property_tree
git submodule init libs/proto
git submodule init libs/ptr_container
git submodule init libs/python
git submodule init libs/random
git submodule init libs/range
git submodule init libs/ratio
git submodule init libs/rational
git submodule init libs/regex
git submodule init libs/serialization
git submodule init libs/signals2
git submodule init libs/smart_ptr
git submodule init libs/spirit
git submodule init libs/static_assert
git submodule init libs/system
git submodule init libs/thread
git submodule init libs/throw_exception
git submodule init libs/tokenizer
git submodule init libs/tti
git submodule init libs/tuple
git submodule init libs/type_index
git submodule init libs/type_traits
git submodule init libs/typeof
git submodule init libs/unordered
git submodule init libs/utility
git submodule init libs/variant
git submodule init libs/winapi
git submodule init libs/xpressive
git submodule init libs/headers tools/boost_install tools/build
git submodule update --jobs 8
rm -rf libs/phoenix
cp -rp $TRAVIS_BUILD_DIR libs/phoenix
ln -s $(pwd)/libs/phoenix $TRAVIS_BUILD_DIR
./bootstrap.sh
./b2 headers
if [ $TRAVIS_OS_NAME = osx ]; then
export PATH="/usr/local/opt/ccache/libexec:$PATH"
true brew install ccache
fi
echo "using ${TOOLSET%%-*} : ${TOOLSET#*-} : ccache `echo $TOOLSET | sed 's/clang/clang++/;s/gcc/g++/'` ;" > ~/user-config.jam
echo '==================================> SCRIPT'
./b2 libs/phoenix/test toolset=$TOOLSET cxxstd=$CXXSTD ${SANITIZED+cxxflags=-fsanitize=address,undefined} ${SANITIZED+'linkflags=-fsanitize=address,undefined -fuse-ld=gold'}
fi

View File

@@ -0,0 +1,543 @@
# Copyright 2016, 2017 Peter Dimov
# Copyright 2017-2019 Kohei Takahashi
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
language: cpp
sudo: false
cache: ccache
os:
- linux
- osx
env:
matrix:
- BOGUS_JOB=true
matrix:
exclude:
- env: BOGUS_JOB=true
include:
- os: linux
dist: trusty
env: TOOLSET=gcc-4.4 CXXSTD=98,0x
addons:
apt:
packages:
- g++-4.4
sources:
- ubuntu-toolchain-r-test
#- os: linux
# dist: trusty
# env: TOOLSET=gcc-4.5 CXXSTD=03,0x
# addons:
# apt:
# packages:
# - g++-4.5
# sources:
# - ubuntu-toolchain-r-test
- os: linux
dist: trusty
env: TOOLSET=gcc-4.6 CXXSTD=03,0x
addons:
apt:
packages:
- g++-4.6
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-4.7 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.7
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-4.8 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-4.8 CXXSTD=1y
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-4.9 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-4.9 CXXSTD=14
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-5 CXXSTD=03,11
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-5 CXXSTD=14,17
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-6 CXXSTD=03,11
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-6 CXXSTD=14,17
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-7 CXXSTD=03,11
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-7 CXXSTD=14,17
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-8 CXXSTD=03,11
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-8 CXXSTD=14,17
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-8 CXXSTD=2a
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-9 CXXSTD=03,11,14 SANITIZED
addons:
apt:
packages:
- g++-9
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=gcc-9 CXXSTD=17,2a SANITIZED
addons:
apt:
packages:
- g++-9
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: xenial
env: TOOLSET=clang-3.5 CXXSTD=03,11
addons:
apt:
packages:
- clang-3.5
# Disable due to: error: debug information for auto is not yet supported
#- os: linux
# dist: xenial
# env: TOOLSET=clang-3.5 CXXSTD=14,1z
# addons:
# apt:
# packages:
# - clang-3.5
- os: linux
dist: xenial
env: TOOLSET=clang-3.6 CXXSTD=03,11
addons:
apt:
packages:
- clang-3.6
- os: linux
dist: xenial
env: TOOLSET=clang-3.6 CXXSTD=14,1z
addons:
apt:
packages:
- clang-3.6
- os: linux
dist: xenial
env: TOOLSET=clang-3.7 CXXSTD=03,11
addons:
apt:
packages:
- clang-3.7
- os: linux
dist: xenial
env: TOOLSET=clang-3.7 CXXSTD=14,1z
addons:
apt:
packages:
- clang-3.7
- os: linux
dist: xenial
env: TOOLSET=clang-3.8 CXXSTD=03,11
addons:
apt:
packages:
- clang-3.8
- os: linux
dist: xenial
env: TOOLSET=clang-3.8 CXXSTD=14,1z
addons:
apt:
packages:
- clang-3.8
- os: linux
dist: xenial
env: TOOLSET=clang-3.9 CXXSTD=03,11
addons:
apt:
packages:
- clang-3.9
- os: linux
dist: xenial
env: TOOLSET=clang-3.9 CXXSTD=14,1z
addons:
apt:
packages:
- clang-3.9
- os: linux
dist: xenial
env: TOOLSET=clang-4.0 CXXSTD=03,11
addons:
apt:
packages:
- clang-4.0
- os: linux
dist: xenial
env: TOOLSET=clang-4.0 CXXSTD=14,1z
addons:
apt:
packages:
- clang-4.0
- os: linux
dist: xenial
env: TOOLSET=clang-5.0 CXXSTD=03,11
addons:
apt:
packages:
- clang-5.0
sources:
- llvm-toolchain-xenial-5.0
- os: linux
dist: xenial
env: TOOLSET=clang-5.0 CXXSTD=14,17
addons:
apt:
packages:
- clang-5.0
sources:
- llvm-toolchain-xenial-5.0
- os: linux
dist: xenial
env: TOOLSET=clang-5.0 CXXSTD=2a
addons:
apt:
packages:
- clang-5.0
sources:
- llvm-toolchain-xenial-5.0
- os: linux
dist: xenial
env: TOOLSET=clang-6.0 CXXSTD=03,11
addons:
apt:
packages:
- clang-6.0
sources:
- llvm-toolchain-xenial-6.0
- os: linux
dist: xenial
env: TOOLSET=clang-6.0 CXXSTD=14,17
addons:
apt:
packages:
- clang-6.0
sources:
- llvm-toolchain-xenial-6.0
- os: linux
dist: xenial
env: TOOLSET=clang-6.0 CXXSTD=2a
addons:
apt:
packages:
- clang-6.0
sources:
- llvm-toolchain-xenial-6.0
- os: linux
dist: xenial
env: TOOLSET=clang-7 CXXSTD=03,11
addons:
apt:
packages:
- clang-7
sources:
- llvm-toolchain-xenial-7
- os: linux
dist: xenial
env: TOOLSET=clang-7 CXXSTD=14,17
addons:
apt:
packages:
- clang-7
sources:
- llvm-toolchain-xenial-7
- os: linux
dist: xenial
env: TOOLSET=clang-7 CXXSTD=2a
addons:
apt:
packages:
- clang-7
sources:
- llvm-toolchain-xenial-7
- os: linux
dist: xenial
env: TOOLSET=clang-8 CXXSTD=03,11,14
addons:
apt:
packages:
- clang-8
- os: linux
dist: xenial
env: TOOLSET=clang-8 CXXSTD=17,2a
addons:
apt:
packages:
- clang-8
- os: linux
dist: bionic
env: TOOLSET=clang-9 CXXSTD=03,11,14 SANITIZED
addons:
apt:
packages:
- clang-9
- os: linux
dist: bionic
env: TOOLSET=clang-9 CXXSTD=17,2a SANITIZED
addons:
apt:
packages:
- clang-9
- os: osx
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
- os: osx
env: TOOLSET=clang COMPILER=clang++ CXXSTD=14,1z
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone --depth 1 -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule init libs/algorithm
- git submodule init libs/any
- git submodule init libs/array
- git submodule init libs/assert
- git submodule init libs/assign
- git submodule init libs/atomic
- git submodule init libs/bind
- git submodule init libs/chrono
- git submodule init libs/circular_buffer
- git submodule init libs/concept_check
- git submodule init libs/config
- git submodule init libs/container
- git submodule init libs/container_hash
- git submodule init libs/conversion
- git submodule init libs/core
- git submodule init libs/date_time
- git submodule init libs/detail
- git submodule init libs/endian
- git submodule init libs/exception
- git submodule init libs/filesystem
- git submodule init libs/foreach
- git submodule init libs/format
- git submodule init libs/function
- git submodule init libs/function_types
- git submodule init libs/functional
- git submodule init libs/fusion
- git submodule init libs/integer
- git submodule init libs/intrusive
- git submodule init libs/io
- git submodule init libs/iostreams
- git submodule init libs/iterator
- git submodule init libs/lambda
- git submodule init libs/lexical_cast
- git submodule init libs/locale
- git submodule init libs/log
- git submodule init libs/math
- git submodule init libs/move
- git submodule init libs/mp11
- git submodule init libs/mpl
- git submodule init libs/multi_index
- git submodule init libs/numeric/conversion
- git submodule init libs/optional
- git submodule init libs/parameter
- git submodule init libs/pool
- git submodule init libs/predef
- git submodule init libs/preprocessor
- git submodule init libs/property_tree
- git submodule init libs/proto
- git submodule init libs/ptr_container
- git submodule init libs/python
- git submodule init libs/random
- git submodule init libs/range
- git submodule init libs/ratio
- git submodule init libs/rational
- git submodule init libs/regex
- git submodule init libs/serialization
- git submodule init libs/signals2
- git submodule init libs/smart_ptr
- git submodule init libs/spirit
- git submodule init libs/static_assert
- git submodule init libs/system
- git submodule init libs/thread
- git submodule init libs/throw_exception
- git submodule init libs/tokenizer
- git submodule init libs/tti
- git submodule init libs/tuple
- git submodule init libs/type_index
- git submodule init libs/type_traits
- git submodule init libs/typeof
- git submodule init libs/unordered
- git submodule init libs/utility
- git submodule init libs/variant
- git submodule init libs/winapi
- git submodule init libs/xpressive
- git submodule init libs/headers tools/boost_install tools/build
- git submodule update --jobs 8
- rm -rf libs/phoenix
- mv $TRAVIS_BUILD_DIR libs/phoenix
- ln -s $(pwd)/libs/phoenix $TRAVIS_BUILD_DIR
- ./bootstrap.sh
- ./b2 headers
- |
if [ $TRAVIS_OS_NAME = osx ]; then
export PATH="/usr/local/opt/ccache/libexec:$PATH"
brew install ccache
fi
- |-
echo "using ${TOOLSET%%-*} : ${TOOLSET#*-} : ccache `echo $TOOLSET | sed 's/clang/clang++/;s/gcc/g++/'` ;" > ~/user-config.jam
script:
- ./b2 libs/phoenix/test toolset=$TOOLSET cxxstd=$CXXSTD
${SANITIZED+cxxflags=-fsanitize=address,undefined}
${SANITIZED+'linkflags=-fsanitize=address,undefined -fuse-ld=gold'}

View File

@@ -0,0 +1,38 @@
# Generated by `boostdep --cmake phoenix`
# Copyright 2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_phoenix VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_phoenix INTERFACE)
add_library(Boost::phoenix ALIAS boost_phoenix)
target_include_directories(boost_phoenix INTERFACE include)
target_link_libraries(boost_phoenix
INTERFACE
Boost::assert
Boost::bind
Boost::config
Boost::core
Boost::function
Boost::fusion
Boost::mpl
Boost::predef
Boost::preprocessor
Boost::proto
Boost::range
Boost::smart_ptr
Boost::type_traits
Boost::utility
)
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()

View File

@@ -0,0 +1,257 @@
Boost Phoenix: A Library for Functional Programming in C++
http://www.boost.org/
Copyright (c) 2005-2010 Joel de Guzman
Copyright (c) 2010-2013 Thomas Heller
Copyright (c) 2014-2015 John Fletcher
Copyright (c) 2016 Kohei Takahashi
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-------------------------------------------------------------------------------
TODO (known issues):
- Create a full list of known issues.
- Check all the examples and ammend as needed.
- Update documentation to be consistent with examples.
- Identify other boost libraries using Phoenix in order to
decide on priorities for fixing the bugs below.
One such library is Boost log.
- Identify dependencies on other libraries and cooperate on bugs.
It is now known that the other libraries which use Boost Phoenix
are Boost Spirit and Boost Meta State Machine (MSM)
- Add more examples
- Develop documentation.
A start has been made on this in release 3.1.0
- Inspection report outstanding issues
Fix libs/phoenix/doc/html/boostbook.css: Unlinked File
- Investigate fixes needed for the following bugs
(all refer to phoenix though not all may be in fact phoenix bugs
#9742 (NEW)
#9291, #9260, #8820, #8800
#8558, #8504, #8187, #8156, #7996
#7953, #7946, #7481, #7480, #7423
#7391, #7356, #6911, #6848,
#6202, #6133, #6026, #5687
- Feature requests
#7730 Potential fixes for this have been removed for further work.
#7633, #5541
- Complete work on the following under investigation
#9363, #9362, #8564, #7199
- #5875 local variable in phoenix let discards value
This seemed already fixed but is not doing well in tests.
Added test bug5875 - test withdrawn for further checking.
-------------------------------------------------------------------------------
CHANGELOG
- DEVELOP
- Many of components now supports C++11 variadic templates.
This is not a breaking change.
- Boost 1.59.0
- Support for <unordered_set> and <unordered_map>
This involves the following changes.
phoenix/config.hpp - New section with the following description:
This section is to sort out whether hash types or unordered types
are available. This depends on whether stdlib or libc++ is being used
and also whether C++11 or C++03 is being used.
Client code should contain this:
#ifdef BOOST_PHOENIX_HAS_HASH
#include BOOST_PHOENIX_HASH_SET_HEADER
#include BOOST_PHOENIX_HASH_MAP_HEADER
#endif
#ifdef BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP
#define BOOST_PHOENIX_UNORDERED_SET_HEADER <unordered_set>
#define BOOST_PHOENIX_UNORDERED_MAP_HEADER <unordered_map>
#endif
The client code can then chose the implementation provided.
See the example in test/stl/querying_find2.cpp
This example file has been adjusted for a problem with MSVC 10
Modified files:
phoenix/stl/algorithm/detail/has_find.hpp
New files:
phoenix/stl/algorithm/detail/is_unordered_set_or_map.hpp
phoenix/stl/algorithm/detail/std_unordered_set_or_map_fwd.hpp
New test file:
phoenix/test/algorithm/querying_find2.cpp
Support for retrieving the return type of boost::phoenix::function objects.
This is needed in the lazy functionality.
Modified file: boost/phoenix/function/function.hpp
Revised version of lazy functionality with added functions.
Modified files in boost/phoenix/function:
lazy_operator.hpp lazy_prelude.hpp lazy_reuse.hpp
New files:
lazy_signature.hpp lazy_smart.hpp
New test files:
lazy_compose_tests.cpp lazy_fold_tests.cpp lazy_scan_tests.cpp
- Feature enhancements #5604 Sequenced statements of a catch_ statement is
now able to handle thrown exception via local variables.
Modified files:
boost/phoenix/statement/try_catch.hpp
Modified test files:
exceptions.cpp
- V3.2.0 in Boost 1.58.0
- patch for #10927 in test/stdlib/cmath.cpp
- patch for #11085 in test/function/function_tests.cpp
- Bump version number to 3.2.0 in version.hpp.
- New header files in boost/phoenix/function
These are the first versions of the lazy functionality being introduced.
This is reimplementation of the ideas in FC++ on top of Phoenix.
The Phoenix code used is Phoenix.Function, along with Boost.Function.
lazy_prelude.hpp This is the top level header and also has prelude functions.
lazy_operator.hpp This defines lazy operators such as plus and minus.
lazy_list.hpp This defines list<T> a lazy list class and associated code.
lazy_reuser.hpp This defines the reuser functions used in the code.
- New tests for lazy functionality.
test/include/function/lazy_headers Test of the header structure.
test/function/lazy_list_tests Simple tests of list<T>.
test/function/lazy_list2_tests More tests of list<T>.
- Develop documentation for version 3.2.0
This includes a new section on the lazy list implementation.
- Fixed name clash by renaming 'at' to be 'at_' because the name 'at' is
used in phoenix/stl/container/container.hpp.
- Fixed an unused typedef in phoenix/scope/let.hpp
- contributed by Kohei Takahashi
- V3.1.1
- Bump version number to 3.1.1 in version.hpp and branch for release.
- New tests for lazy functions using existing phoenix/function capability.
lazy_argument_tests, lazy_make_pair_tests, lazy_templated_struct_tests
- New example bind_goose.cpp comparing boost.bind and boost.phoenix.bind.
- Changes to let_tests and more_let_tests to avoid failing cases.
- Updates to documentation.
- V3.1.0
- Bump version number to 3.1.0 in version.hpp and branch for release.
- New file boost/phoenix/config.hpp to centralise configuration issues.
At the moment it simply includes boost/config.hpp
- Changes to some tests to identify problems with several compilers.
- Add more cases to cmath test to test failures on some compilers.
- #7165 and #7166 Change tests to phoenix/core.hpp to reduce compiler load
- Testing fix for failures of tests as follows
bind_member_function_tests, bind_mf2_test, bind_test
with compilers including gcc 4.9.0 and clang 3.5
This involves use of boost::lazy_disable_if to resolve
the choice of overloaded bind functions in
bind/bind_member_variable.hpp
bind/bind_member_function.hpp Add reverse test boost::lazy_enable_if
This resolves a smaller number of failures.
- #9742 New tests for_each and for_test to attempt to resolve this.
- bind_rv_sp_test changed to give workaround for MSVC 8,9,10,
This removes a COMDAT error which does not occur with boost/bind.
- V3.0.6
- Fixed bug in example/container_actor.cpp in end() function.
- Fixed bug4853 and 5626 - added header <utility> for std::forward.
- Fixed bug4853 - added header <iostream> for gcc 4.9 test
- New Feature - boost::phoenix::display_expr(expr)
In file boost/phoenix/core/debug.hpp
and also included from boost/phoenix/core.hpp
For now this drops through to the boost Proto version.
I intend to add some more tags for better information.
New test debug for the new header.
KNOWN BUG - WARNING
- New test more_let_tests to check for problems with losing temporary values.
I think this is a serious problem which is affecting some compilers
and not others. I have seen the problem with Clang 3.4 although not
when run with C++11. These tests should find out where else there is a
problem. At the moment these tests are passing.
I now have cases which fail for Clang 3.4 with optimization -O2 but not
without optimization. Under investigation.
- V3.0.5
- Documentation
Start on fixing main documentation - whats new.
Fixed reference for FC++ in two locations.
Fixed example for nested let (#8564)
- Fixed #9113 warnings on -Wshadow
Fixed all warnings
- Fixed #8298 Clang error with Boost Phoenix Local Name Assignment using C++11
This is not expected to compile in the form supplied.
Added test bug8298 to show correct operation.
Added test bug8298f to show expected failure.
- Fixed #7730 Generic specializations of is_nullary for custom terminals
are not possible
Fix to specialize custom terminals is now set as a default.
Define BOOST_PHOENIX_NO_SPECIALIZE_CUSTOM_TERMINAL not to use this.
Test bug7730 tests the not use case.
- V3.0.4
- Inspection report outstanding issues
Fixed copyright and licence in preprocessed files for function_equal
- boost/phoenix/version.hpp Added BOOST_PHOENIX_VERSION_NUMBER
when boost/predef is available.
- Fixed tabs in ChangeLog!!
- Fixed #9295 PHOENIX_LIMIT macro clash: property_tree -- log/sink
This will not show up in phoenix - used in spirit/classic
- Fixed #8704 Using Phoenix lambdas on top of custom Proto expressions
This works for C++11 only.
Test cmath applies to this.
- Fixed #7624 Deduction failure
This works for C++11 and has a workaround for C++03
Test bug7624 tests both versions.
- Fixed #7166 Phoenix unconditionally sets BOOST_PROTO_MAX_ARITY
using patch supplied
Added test bug7166
- Fixed #7165 cannot change BOOST_PHOENIX_LIMIT
using patch supplied
Added test bug7165
- Fixed #6665 not-unary phoenix stl cmath adapted functions not working
Added test cmath
- V3.0.3
- Fixed #5824 Block statement headers and docs
Added test bug5824
- V3.0.2
- Fixed #5715 sequencing with comma does not work for boost::phoenix::bind
Added test bug5715
- V3.0.1
- Started CHANGELOG
- Fixed bug_000008 to use phoenix headers correctly.
This fixes it for most systems but not for
Clang Linux C++11 with libstdc++ where the problem seems
to be in boost/thread.
Clang Linux C++11 with libc++ works.
- Fixed #9113 warnings on -Wshadow (some fixed)
- Fixed #9111 unused parameter warning in phoenix bind
- Fixed #8417 Minor documentation
- Fixed #7181 MSVC warnings
- Fixed #6268 phoenix and fusion operator < and added test bug6268
- Fixed many issues from Inspection report
phoenix/core/detail/phx_result.hpp Fixed clash with Apple macro 'check'
Fixed copyright and licence issues
Fixed tabs in some files
Deleted some empty unused files
Added tests for includes not being tested.
Boost V1.55:
- V3.0.0
- Boost Phoenix as passed on to new maintainer John Fletcher

View File

@@ -0,0 +1,140 @@
# Copyright 2016, 2017 Peter Dimov
# Copyright 2017-2019 Kohei Takahashi
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
version: 1.0.{build}-{branch}
shallow_clone: true
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-9.0
ADDRMDL: 32
CXXSTD: latest # fake
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-10.0
ADDRMDL: 32
CXXSTD: latest # fake
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-11.0
ADDRMDL: 32
CXXSTD: latest # fake
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-12.0
CXXSTD: latest # fake
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
CXXSTD: 14
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
CXXSTD: latest
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 14
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: latest
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: clang-win
CXXSTD: 14
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: clang-win
CXXSTD: 17
install:
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- cd ..
- git clone --depth 1 -b %BOOST_BRANCH% https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule init libs/algorithm
- git submodule init libs/any
- git submodule init libs/array
- git submodule init libs/assert
- git submodule init libs/assign
- git submodule init libs/atomic
- git submodule init libs/bind
- git submodule init libs/chrono
- git submodule init libs/circular_buffer
- git submodule init libs/concept_check
- git submodule init libs/config
- git submodule init libs/container
- git submodule init libs/container_hash
- git submodule init libs/conversion
- git submodule init libs/core
- git submodule init libs/date_time
- git submodule init libs/detail
- git submodule init libs/endian
- git submodule init libs/exception
- git submodule init libs/filesystem
- git submodule init libs/foreach
- git submodule init libs/format
- git submodule init libs/function
- git submodule init libs/function_types
- git submodule init libs/functional
- git submodule init libs/fusion
- git submodule init libs/integer
- git submodule init libs/intrusive
- git submodule init libs/io
- git submodule init libs/iostreams
- git submodule init libs/iterator
- git submodule init libs/lambda
- git submodule init libs/lexical_cast
- git submodule init libs/locale
- git submodule init libs/log
- git submodule init libs/math
- git submodule init libs/move
- git submodule init libs/mp11
- git submodule init libs/mpl
- git submodule init libs/multi_index
- git submodule init libs/numeric/conversion
- git submodule init libs/optional
- git submodule init libs/parameter
- git submodule init libs/pool
- git submodule init libs/predef
- git submodule init libs/preprocessor
- git submodule init libs/property_tree
- git submodule init libs/proto
- git submodule init libs/ptr_container
- git submodule init libs/python
- git submodule init libs/random
- git submodule init libs/range
- git submodule init libs/ratio
- git submodule init libs/rational
- git submodule init libs/regex
- git submodule init libs/serialization
- git submodule init libs/signals2
- git submodule init libs/smart_ptr
- git submodule init libs/spirit
- git submodule init libs/static_assert
- git submodule init libs/system
- git submodule init libs/thread
- git submodule init libs/throw_exception
- git submodule init libs/tokenizer
- git submodule init libs/tti
- git submodule init libs/tuple
- git submodule init libs/type_index
- git submodule init libs/type_traits
- git submodule init libs/typeof
- git submodule init libs/unordered
- git submodule init libs/utility
- git submodule init libs/variant
- git submodule init libs/winapi
- git submodule init libs/xpressive
- git submodule init libs/headers tools/boost_install tools/build
- git submodule update --jobs 8
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\phoenix
- cmd /c bootstrap
- b2 headers
build: off
test_script:
- b2 --hash libs/phoenix/test toolset=%TOOLSET% cxxstd=%CXXSTD% address-model=%ADDRMDL%

View File

@@ -0,0 +1,32 @@
#==============================================================================
# Copyright (c) 2003, 2005 Joel de Guzman
#
# Use, modification and distribution is subject to the Boost Software
# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#==============================================================================
project boost/libs/phoenix/doc ;
import boostbook : boostbook ;
using quickbook ;
path-constant images : html ;
boostbook phoenix-doc
:
phoenix3.qbk
:
<xsl:param>boost.root=../../../..
<xsl:param>chunk.section.depth=3
<xsl:param>chunk.first.sections=1
<xsl:param>toc.section.depth=3
<xsl:param>toc.max.depth=3
<xsl:param>generate.section.toc.level=3
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/phoenix/doc/html
<format>pdf:<xsl:param>img.src.path=$(images)/
;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : phoenix-doc ;
explicit boostrelease ;

View File

@@ -0,0 +1,34 @@
[/==============================================================================
Copyright (C) 2001-2010 Joel de Guzman
Copyright (C) 2001-2005 Dan Marsden
Copyright (C) 2001-2010 Thomas Heller
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
===============================================================================/]
[section Acknowledgments]
# Hartmut Kaiser implemented the original lazy casts and constructors based on
his original work on Spirit SE "semantic expressions" (the precursor to
Phoenix), and guided Phoenix from the initial review of V2 to the release of V3.
# Eric Niebler did a 2.0 pre-release review and wrote some range related code
that Phoenix stole and used in the algorithms. Additionally he played the leading role
in inventing the extension mechanism as well as providing early prototypes and helping with
Boost.Proto code. DA Proto MAN!
# Angus Leeming implemented the container functions on Phoenix-1 which I then
ported to Phoenix-2.
# Daniel Wallin helped with the scope module, local variables, let and lambda
and the algorithms. I frequently discuss design issues with Daniel on Yahoo Messenger.
# Jaakko Jarvi. DA Lambda MAN!
# Dave Abrahams, for his constant presence, wherever, whenever.
# Aleksey Gurtovoy, DA MPL MAN!
# Doug Gregor, always a source of inspiration.
# Dan Marsden, did almost all the work in bringing Phoenix-2 out the door.
# Thorsten Ottosen; Eric's range_ex code began life as "container_algo" in the
old boost sandbox, by Thorsten in 2002-2003.
# Jeremy Siek, even prior to Thorsten, in 2001, started the "container_algo".
# Vladimir Prus wrote the mutating algorithms code from the Boost Wiki.
# Daryle Walker did a 2.0 pre-release review.
[endsect]

View File

@@ -0,0 +1,57 @@
[/==============================================================================
Copyright (C) 2001-2010 Joel de Guzman
Copyright (C) 2001-2005 Dan Marsden
Copyright (C) 2001-2010 Thomas Heller
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
===============================================================================/]
[section Actor]
The `Actor` is the main concept behind the library. Actors are function objects.
An actor can accept 0 to `BOOST_PHOENIX_LIMIT` arguments.
[note You can set `BOOST_PHOENIX_LIMIT`, the predefined maximum arity an
actor can take. By default, `BOOST_PHOENIX_LIMIT` is set to 10.]
Phoenix supplies an `actor` class template whose specializations
model the `Actor` concept. `actor` has one template parameter, `Expr`,
that supplies the underlying expression to evaluate.
template <typename Expr>
struct actor
{
return_type
operator()() const;
return_type
operator()();
template <typename T0>
return_type
operator()(T0& _0) const;
template <typename T0>
return_type
operator()(T0 const& _0) const;
template <typename T0>
return_type
operator()(T0& _0);
template <typename T0>
return_type
operator()(T0 const& _0);
//...
};
The actor class accepts the arguments through a set of function call operators
for 0 to `BOOST_PHOENIX_LIMIT` arities (Don't worry about the details, for now. Note, for example,
that we skimed over the details regarding `return_type`). The arguments
are then forwarded to the actor's `Expr` for evaluation.
[endsect]

View File

@@ -0,0 +1,45 @@
[/==============================================================================
Copyright (C) 2001-2010 Joel de Guzman
Copyright (C) 2001-2005 Dan Marsden
Copyright (C) 2001-2010 Thomas Heller
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
===============================================================================/]
[section Actor]
The `Actor` is the main concept behind the library. Actors are function objects.
An actor can accept 0 to `BOOST_PHOENIX_LIMIT` arguments.
[note You can set `BOOST_PHOENIX_LIMIT`, the predefined maximum arity an
actor can take. By default, `BOOST_PHOENIX_LIMIT` is set to 10.]
Phoenix supplies an `actor` class template whose specializations
model the `Actor` concept. `actor` has one template parameter, `Expr`,
that supplies the underlying expression to evaluate.
template <typename Expr>
struct actor
{
return_type
operator()() const;
template <typename T0>
return_type
operator()(T0& _0) const;
template <typename T0, typename T1>
return_type
operator()(T0& _0, T1& _1) const;
//...
};
The actor class accepts the arguments through a set of function call operators
for 0 to `BOOST_PHOENIX_LIMIT` arities (Don't worry about the details, for now. Note, for example,
that we skimp over the details regarding `return_type`). The arguments are passed through to
the evaluation mechanism. For more information see [link phoenix.inside.actor Inside Actors].
[endsect]

View File

@@ -0,0 +1,15 @@
[/==============================================================================
Copyright (C) 2001-2010 Joel de Guzman
Copyright (C) 2001-2010 Thomas Heller
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
===============================================================================/]
[section Advanced Topics]
[include advanced/porting.qbk]
[include advanced/extending_actors.qbk]
[/include advanced/custom_evaluation.qbk]
[endsect]

View File

@@ -0,0 +1,11 @@
[/==============================================================================
Copyright (C) 2001-2010 Joel de Guzman
Copyright (C) 2001-2010 Thomas Heller
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
===============================================================================/]
[section Custom Evaluation]
[endsect]

View File

@@ -0,0 +1,115 @@
[/==============================================================================
Copyright (C) 2001-2010 Joel de Guzman
Copyright (C) 2001-2005 Dan Marsden
Copyright (C) 2001-2010 Thomas Heller
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
===============================================================================/]
[section Porting from Phoenix 2.0]
While reading the current documentation you might have noticed that the
[link phoenix.starter_kit Starter Kit] didn't change very much. This is because
a lot of effort was put into being compatible with Phoenix 2.0, at least on the
outside.
That being said, the only major difference is the result type deduction protocol.
The everyday Phoenix-User will encounter this change only when writing
[link phoenix.reference.modules.function Functions].
To make your function implementations Phoenix compliant again change from
the old Phoenix result type deduction protocol to the new (standard compliant)
result type deduction protocol:
[table
[[Phoenix 2.0] [Phoenix 3.0] [Notes]]
[
[``
struct is_odd_impl
{
template <typename Arg>
struct result
{
typedef bool type;
};
template <typename Arg>
bool operator()(Arg arg) const
{
return arg % 2 == 1;
}
};
boost::phoenix::function<is_odd_impl> is_odd = is_odd_impl();
``]
[``
struct is_odd_impl
{
typedef bool result_type;
template <typename Arg>
bool operator()(Arg arg) const
{
return arg % 2 == 1;
}
};
boost::phoenix::function<is_odd_impl> is_odd = is_odd_impl();
``]
[ __note__
The result_of protocol is particularly easy when you implement a monomorphic
function (return type not dependent on the arguments). You then just need a
single nested return_type typedef.
]
]
[
[``
struct add_impl
{
template <typename Arg1, typename Arg2>
struct result
{
typedef Arg1 type;
};
template <typename Arg1, typename Arg2>
Arg1 operator()(Arg1 arg1, Arg2 arg2) const
{
return arg1 + arg2;
}
};
boost::phoenix::function<add_impl> add = add_impl();
``]
[``
struct add_impl
{
template <typename Sig>
struct result;
template <typename This, typename Arg1, typename Arg2>
struct result<This(Arg1, Arg2)>
: boost::remove_reference<Arg1> {};
template <typename Arg1, typename Arg2>
typename boost::remove_reference<Arg1>::type
operator()(Arg1 arg1, Arg2 arg2) const
{
return arg1 + arg2;
}
};
boost::phoenix::function<add_impl> add = add_impl();
``]
[__alert__ When dealing with polymorphic functions the template arguments can
be any type including cv-qualifiers and references. For that reason, the calculated
result type need to remove the reference whenever appropriate!]
]
]
[blurb __tip__ There is no general guideline for porting code which relies on the
internals of Phoenix 2.0. If you plan on porting your Phoenix 2.0 extensions
please refer to the next sections.]
[endsect]

View File

@@ -0,0 +1,180 @@
[/==============================================================================
Copyright (C) 2001-2010 Joel de Guzman
Copyright (C) 2001-2005 Dan Marsden
Copyright (C) 2001-2010 Thomas Heller
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
===============================================================================/]
[section Basics]
[def __constant_n__ /n/]
[def __argument_n__ a/n/]
Almost everything is a function in the Phoenix library that can be evaluated as
`f(a1, a2, ..., __argument_n__)`, where __constant_n__ is the function's arity, or number of arguments that the
function expects. Operators are also functions. For example, `a + b` is just a
function with arity == 2 (or binary). `a + b` is the same as `add(a, b)`, `a + b
+ c` is the same as `add(add(a, b), c)`.
[note Amusingly, functions may even return functions. We shall see
what this means in a short while.]
[heading Partial Function Application]
Think of a function as a black box. You pass arguments and it returns something
back. The figure below depicts the typical scenario.
[$images/fbox.png]
A fully evaluated function is one in which all the arguments are given. All
functions in plain C++ are fully evaluated. When you call the `sin(x)` function,
you have to pass a number x. The function will return a result in return: the
sin of x. When you call the `add(x, y)` function, you have to pass two numbers x
and y. The function will return the sum of the two numbers. The figure below is
a fully evaluated `add` function.
[$images/adder.png]
A partially applied function, on the other hand, is one in which not all the
arguments are supplied. If we are able to partially apply the function `add`
above, we may pass only the first argument. In doing so, the function does not
have all the required information it needs to perform its task to compute and
return a result. What it returns instead is another function, a lambda function.
Unlike the original `add` function which has an arity of 2, the resulting lambda
function has an arity of 1. Why? because we already supplied part of the input:
`2`
[$images/add2.png]
Now, when we shove in a number into our lambda function, it will return 2 plus
whatever we pass in. The lambda function essentially remembers 1) the original
function, `add`, and 2) the partial input, 2. The figure below illustrates a
case where we pass 3 to our lambda function, which then returns 5:
[$images/add2_call.png]
Obviously, partially applying the `add` function, as we see above, cannot be
done directly in C++ where we are expected to supply all the arguments that a
function expects. That's where the Phoenix library comes in. The library
provides the facilities to do partial function application.
And even more, with Phoenix, these resulting functions won't be black boxes
anymore.
[heading STL and higher order functions]
So, what's all the fuss? What makes partial function application so useful?
Recall our original example in the [link phoenix.starter_kit.lazy_operators
previous section]:
std::find_if(c.begin(), c.end(), arg1 % 2 == 1)
The expression `arg1 % 2 == 1` evaluates to a lambda function. `arg1` is a
placeholder for an argument to be supplied later. Hence, since there's only one
unsupplied argument, the lambda function has an arity 1. It just so happens that
`find_if` supplies the unsupplied argument as it loops from `c.begin()` to
`c.end()`.
[note Higher order functions are functions which can take other
functions as arguments, and may also return functions as results. Higher order
functions are functions that are treated like any other objects and can be used
as arguments and return values from functions.]
[heading Lazy Evaluation]
In Phoenix, to put it more accurately, function evaluation has two stages:
# Partial application
# Final evaluation
The first stage is handled by a set of generator functions. These are your front
ends (in the client's perspective). These generators create (through partial
function application), higher order functions that can be passed on just like
any other function pointer or function object. The second stage, the actual
function call, can be invoked or executed anytime in the future, or not at all;
hence /"lazy"/.
If we look more closely, the first step involves partial function application:
arg1 % 2 == 1
The second step is the actual function invocation (done inside the `find_if`
function. These are the back-ends (often, the final invocation is never actually
seen by the client). In our example, the `find_if`, if we take a look inside,
we'll see something like:
template <class InputIterator, class Predicate>
InputIterator
find_if(InputIterator first, InputIterator last, Predicate pred)
{
while (first != last && !pred(*first)) // <--- The lambda function is called here
++first; // passing in *first
return first;
}
Again, typically, we, as clients, see only the first step. However, in this
document and in the examples and tests provided, don't be surprised to see the
first and second steps juxtaposed in order to illustrate the complete semantics
of Phoenix expressions. Examples:
int x = 1;
int y = 2;
std::cout << (arg1 % 2 == 1)(x) << std::endl; // prints 1 or true
std::cout << (arg1 % 2 == 1)(y) << std::endl; // prints 0 or false
[heading Forwarding Function Problem]
Usually, we, as clients, write the call-back functions while libraries (such as
STL) provide the callee (e.g. `find_if`). In case the role is reversed, e.g.
if you have to write an STL algorithm that takes in a predicate, or develop a
GUI library that accepts event handlers, you have to be aware of a little known
problem in C++ called the "__forwarding__".
Look again at the code above:
(arg1 % 2 == 1)(x)
Notice that, in the second-stage (the final evaluation), we used a variable `x`.
In Phoenix we emulated perfect forwarding through preprocessor macros generating
code to allow const and non-const references.
We generate these second-stage overloads for Phoenix expression up to
`BOOST_PHOENIX_PERFECT_FORWARD_LIMIT`
[note You can set `BOOST_PHOENIX_PERFECT_FORWARD_LIMIT`, the predefined maximum perfect
forward arguments an actor can take. By default, `BOOST_PHOENIX_PERFECT_FORWARDLIMIT`
is set to 3.]
[/
Be aware that the second stage cannot accept non-const temporaries and literal
constants. Hence, this will fail:
(arg1 % 2 == 1)(123) // Error!
Disallowing non-const rvalues partially solves the "__forwarding__" but
prohibits code like above.
]
[heading Polymorphic Functions]
Unless otherwise noted, Phoenix generated functions are fully polymorphic. For
instance, the `add` example above can apply to integers, floating points, user
defined complex numbers or even strings. Example:
std::string h("Hello");
char const* w = " World";
std::string r = add(arg1, arg2)(h, w);
evaluates to `std::string("Hello World")`. The observant reader might notice
that this function call in fact takes in heterogeneous arguments where `arg1`
is of type `std::string` and `arg2` is of type `char const*`. `add` still works
because the C++ standard library allows the expression `a + b` where `a` is a
`std::string` and `b` is a `char const*`.
[endsect]

View File

@@ -0,0 +1,16 @@
[/==============================================================================
Copyright (C) 2001-2010 Joel de Guzman
Copyright (C) 2001-2005 Dan Marsden
Copyright (C) 2001-2010 Thomas Heller
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
===============================================================================/]
[section:examples Advanced Examples]
[include examples/extending_actors.qbk]
[include examples/adding.qbk]
[include examples/transforming.qbk]
[endsect]

View File

@@ -0,0 +1,111 @@
[/==============================================================================
Copyright (C) 2001-2010 Joel de Guzman
Copyright (C) 2001-2005 Dan Marsden
Copyright (C) 2001-2010 Thomas Heller
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
===============================================================================/]
[section Adding an expression]
This is not a toy example. This is actually part of the library. Remember the
[link phoenix.modules.statement.while__statement `while`] lazy statement? Putting together
everything we've learned so far, we eill present it here in its entirety
(verbatim):
BOOST_PHOENIX_DEFINE_EXPRESSION(
(boost)(phoenix)(while_)
, (meta_grammar) // Cond
(meta_grammar) // Do
)
namespace boost { namespace phoenix
{
struct while_eval
{
typedef void result_type;
template <typename Cond, typename Do, typename Context>
result_type
operator()(Cond const& cond, Do const& do_, Context & ctx) const
{
while(eval(cond, ctx))
{
eval(do_, ctx);
}
}
};
template <typename Dummy>
struct default_actions::when<rule::while_, Dummy>
: call<while_eval, Dummy>
{};
template <typename Cond>
struct while_gen
{
while_gen(Cond const& cond) : cond(cond) {}
template <typename Do>
typename expression::while_<Cond, Do>::type const
operator[](Do const& do_) const
{
return expression::while_<Cond, Do>::make(cond, do_);
}
Cond const& cond;
};
template <typename Cond>
while_gen<Cond> const
while_(Cond const& cond)
{
return while_gen<Cond>(cond);
}
}}
`while_eval` is an example of how to evaluate an expression. It gets called in
the `rule::while` action. `while_gen` and `while_` are the expression template
front ends. Let's break this apart to undestand what's happening. Let's start at
the bottom. It's easier that way.
When you write:
while_(cond)
we generate an instance of `while_gen<Cond>`, where `Cond` is the type of `cond`.
`cond` can be an arbitrarily complex actor expression. The `while_gen` template
class has an `operator[]` accepting another expression. If we write:
while_(cond)
[
do_
]
it will generate a proper composite with the type:
expression::while_<Cond, Do>::type
where `Cond` is the type of `cond` and `Do` is the type of `do_`. Notice how we are using Phoenix's
[link phoenix.inside.expression Expression] mechanism here
template <typename Do>
typename expression::while_<Cond, Do>::type const
operator[](Do const& do_) const
{
return expression::while_<Cond, Do>::make(cond, do_);
}
Finally, the `while_eval` does its thing:
while(eval(cond, ctx))
{
eval(do_, ctx);
}
`cond` and `do_`, at this point, are instances of [link phoenix.inside.actor Actor]. `cond` and `do_` are the [link phoenix.inside.actor Actors]
passed as parameters by `call`, ctx is the [link phoenix.inside.actor Context]
[endsect]

View File

@@ -0,0 +1,177 @@
[/==============================================================================
Copyright (C) 2001-2010 Joel de Guzman
Copyright (C) 2001-2005 Dan Marsden
Copyright (C) 2001-2010 Thomas Heller
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
===============================================================================/]
[section Extending Actors]
[link phoenix.inside.actor Actors] are one of the main parts of the
library, and one of the many customization points. The default actor implementation
provides several operator() overloads which deal with the evaluation of expressions.
For some use cases this might not be enough. For convenience it is thinkable to
provide custom member functions which generate new expressions. An example is the
[link phoenix.modules.statement.___if_else_____statement '''if_else_'''
Statement] which provides an additional else member for generating a lazy if-else
expression. With this the actual Phoenix expression becomes more expressive.
Another scenario is to give actors the semantics of a certain well known interface
or concept. This tutorial like section will provide information on how to implement
a custom actor which is usable as if it were a
[@http://www.sgi.com/tech/stl/Container.html STL Container].
[heading Requirements]
Let's repeat what we want to have:
[table
[[Expression] [Semantics]]
[[`a.begin()`] [Returns an iterator pointing to the first element in the container.]]
[[`a.end()`] [Returns an iterator pointing one past the last element in the container.]]
[[`a.size()`] [Returns the size of the container, that is, its number of elements.]]
[[`a.max_size()`] [Returns the largest size that this container can ever have.]]
[[`a.empty()`] [Equivalent to a.size() == 0. (But possibly faster.)]]
[[`a.swap(b)`] [Equivalent to swap(a,b)]]
]
Additionally, we want all the operator() overloads of the regular actor.
[heading Defining the actor]
The first version of our `container_actor` interface will show the general
principle. This will be continually extended. For the sake of simplicity,
every member function generator will return [link phoenix.modules.core.nothing `nothing`]
at first.
template <typename Expr>
struct container_actor
: actor<Expr>
{
typedef actor<Expr> base_type;
typedef container_actor<Expr> that_type;
container_actor( base_type const& base )
: base_type( base ) {}
expression::null<mpl::void_>::type const begin() const { return nothing; }
expression::null<mpl::void_>::type const end() const { return nothing; }
expression::null<mpl::void_>::type const size() const { return nothing; }
expression::null<mpl::void_>::type const max_size() const { return nothing; }
expression::null<mpl::void_>::type const empty() const { return nothing; }
// Note that swap is the only function needing another container.
template <typename Container>
expression::null<mpl::void_>::type const swap( actor<Container> const& ) const { return nothing; }
};
[heading Using the actor]
Although the member functions do nothing right now, we want to test if we can use
our new actor.
First, lets create a generator which wraps the `container_actor` around any other
expression:
template <typename Expr>
container_actor<Expr> const
container( actor<Expr> const& expr )
{
return expr;
}
Now let's test this:
std::vector<int> v;
v.push_back(0);
v.push_back(1);
v.push_back(2);
v.push_back(3);
(container(arg1).size())(v);
Granted, this is not really elegant and not very practical (we could have just
used phoenix::begin(v) from the [link phoenix.modules.stl.algorithm Phoenix algorithm module],
but we can do better.
Let's have an [link phoenix.modules.core.arguments argument placeholder]
which is usable as if it was a STL container:
container_actor<expression::argument<1>::type> const con1;
// and so on ...
The above example can be rewritten as:
std::vector<int> v;
v.push_back(0);
v.push_back(1);
v.push_back(2);
v.push_back(3);
(con1.size())(v);
Wow, that was easy!
[heading Adding life to the actor]
This one will be even easier!
First, we define a [link phoenix.modules.function lazy function] which
evaluates the expression we want to implement.
Following is the implementation of the size function:
struct size_impl
{
// result_of protocol:
template <typename Sig>
struct result;
template <typename This, typename Container>
struct result<This(Container)>
{
// Note, remove reference here, because Container can be anything
typedef typename boost::remove_reference<Container>::type container_type;
// The result will be size_type
typedef typename container_type::size_type type;
};
template <typename Container>
typename result<size_impl(Container const&)>::type
operator()(Container const& container) const
{
return container.size();
}
};
Good, this was the first part. The second part will be to implement the size member
function of `container_actor`:
template <typename Expr>
struct container_actor
: actor<Expr>
{
typedef actor<Expr> base_type;
typedef container_actor<Expr> that_type;
container_actor( base_type const& base )
: base_type( base ) {}
typename expression::function<size_impl, that_type>::type const
size() const
{
function<size_impl> const f = size_impl();
return f(*this);
}
// the rest ...
};
It is left as an exercise to the user to implement the missing parts by reusing
functions from the [link phoenix.modules.stl.algorithm Phoenix Algorithm Module]
(the impatient take a look here: [@../../example/container_actor.cpp container_actor.cpp]).
[endsect]

View File

@@ -0,0 +1,153 @@
[/==============================================================================
Copyright (C) 2001-2010 Joel de Guzman
Copyright (C) 2001-2005 Dan Marsden
Copyright (C) 2001-2010 Thomas Heller
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
===============================================================================/]
[section Transforming the Expression Tree]
This example will show how to write __phoenix_actions__ that transform the
Phoenix AST.
[:
"/Lisp macros transform the program structure itself, with the full language
available to express such transformations./"
[@http://en.wikipedia.org/wiki/Lisp_macro#Lisp_macros Wikipedia]
]
What we want to do is to invert some arithmetic operators, i.e. plus will be
transformed to minus, minus to plus, multiplication to division and division to
multiplication.
Let's start with defining our default action:
[def __proto_nary_expr__ [@http://www.boost.org/doc/libs/release/doc/html/boost/proto/nary_expr.html `proto::nary_expr`]]
[def __proto_vararg__ [@http://www.boost.org/doc/libs/release/doc/html/boost/proto/vararg.html `proto::vararg`]]
[def __proto_when__ [@http://www.boost.org/doc/libs/release/doc/html/boost/proto/when.html `proto::when`]]
[def __proto_underscore__ [@http://www.boost.org/doc/libs/release/doc/html/boost/proto/_.html `proto::_`]]
[def __proto_make_expr__ [@http://www.boost.org/doc/libs/release/doc/html/boost/proto/functional/make_expr.html `proto::functional::make_expr`]]
struct invert_actions
{
template <typename Rule>
struct when
: __proto_nary_expr__
__proto_underscore__
, __proto_vararg__
__proto_when__<__proto_underscore__, phoenix::evaluator(__proto_underscore__, phoenix::_context)
>
>
{};
};
Wow, this looks complicated! Granted you need to know a little bit about __proto__
(For a good introduction read through the
[@http://cpp-next.com/archive/2010/08/expressive-c-introduction/ Expressive C++] series).
By default, we don't want to do anything, well, not exactly nothing, but just
continue transformation into its arguments.
So, it is done by the following:
* For each arguments are passed to evaluator (with the current context, that contains our invert_actions)
* Create new expression using current expression tag, what is done by __proto_underscore__, with the result of evaluated arguments
So, after the basics are set up, we can start by writing the transformations we
want to have on our tree:
// Transform plus to minus
template <>
struct invert_actions::when<phoenix::rule::plus>
: __proto_call__<
__proto_make_expr__<proto::tag::minus>(
phoenix::evaluator(proto::_left, phoenix::_context)
, phoenix::evaluator(proto::_right, phoenix::_context)
)
>
{};
What is done is the following:
* The left expression is passed to evaluator (with the current context, that contains our invert_actions)
* The right expression is passed to evaluator (with the current context, that contains our invert_actions)
* The result of these two __proto_transforms__ are passed to __proto_make_expr__ which returns the freshly created expression
After you know what is going on, maybe the rest doesn't look so scary anymore:
// Transform minus to plus
template <>
struct invert_actions::when<phoenix::rule::minus>
: __proto_call__<
__proto_make_expr__<proto::tag::plus>(
phoenix::evaluator(proto::_left, phoenix::_context)
, phoenix::evaluator(proto::_right, phoenix::_context)
)
>
{};
// Transform multiplies to divides
template <>
struct invert_actions::when<phoenix::rule::multiplies>
: __proto_call__<
__proto_make_expr__<proto::tag::divides>(
phoenix::evaluator(proto::_left, phoenix::_context)
, phoenix::evaluator(proto::_right, phoenix::_context)
)
>
{};
// Transform divides to multiplies
template <>
struct invert_actions::when<phoenix::rule::divides>
: __proto_call__<
__proto_make_expr__<proto::tag::multiplies>(
phoenix::evaluator(proto::_left, phoenix::_context)
, phoenix::evaluator(proto::_right, phoenix::_context)
)
>
{};
That's it! Now that we have our actions defined, we want to evaluate some of our expressions with them:
template <typename Expr>
// Calculate the result type: our transformed AST
typename boost::result_of<
phoenix::evaluator(
Expr const&
, phoenix::result_of::context<int, invert_actions>::type
)
>::type
invert(Expr const & expr)
{
return
// Evaluate it with our actions
phoenix::eval(
expr
, phoenix::context(
int()
, invert_actions()
)
);
}
Run some tests to see if it is working:
invert(_1); // --> _1
invert(_1 + _2); // --> _1 - _2
invert(_1 + _2 - _3); // --> _1 - _2 + _3
invert(_1 * _2); // --> _1 / _2
invert(_1 * _2 / _3); // --> _1 / _2 * _3
invert(_1 * _2 + _3); // --> _1 / _2 - _3
invert(_1 * _2 - _3); // --> _1 / _2 + _2
invert(if_(_1 * _4)[_2 - _3]); // --> if_(_1 / _4)[_2 + _3]
_1 * invert(_2 - _3)); // --> _1 * _2 + _3
__note__ The complete example can be found here: [@../../example/invert.cpp example/invert.cpp]
/Pretty simple .../
[endsect]

View File

@@ -0,0 +1,601 @@
/*=============================================================================
Copyright (c) 2004 Joel de Guzman
http://spirit.sourceforge.net/
Distributed under the Boost Software License, Version 1.0. (See accompany-
ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
/*=============================================================================
Body defaults
=============================================================================*/
body
{
margin: 1em;
font-family: sans-serif;
}
/*=============================================================================
Paragraphs
=============================================================================*/
p
{
text-align: left;
font-size: 10pt;
line-height: 1.15;
}
/*=============================================================================
Program listings
=============================================================================*/
/* Code on paragraphs */
p tt.computeroutput
{
font-size: 9pt;
}
pre.synopsis
{
font-size: 9pt;
margin: 1pc 4% 0pc 4%;
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
}
.programlisting,
.screen
{
font-size: 9pt;
display: block;
margin: 1pc 4% 0pc 4%;
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
}
/* Program listings in tables don't get borders */
td .programlisting,
td .screen
{
margin: 0pc 0pc 0pc 0pc;
padding: 0pc 0pc 0pc 0pc;
}
/*=============================================================================
Headings
=============================================================================*/
h1, h2, h3, h4, h5, h6
{
text-align: left;
margin: 1em 0em 0.5em 0em;
font-weight: bold;
}
h1 { font: 140% }
h2 { font: bold 140% }
h3 { font: bold 130% }
h4 { font: bold 120% }
h5 { font: italic 110% }
h6 { font: italic 100% }
/* Top page titles */
title,
h1.title,
h2.title
h3.title,
h4.title,
h5.title,
h6.title,
.refentrytitle
{
font-weight: bold;
margin-bottom: 1pc;
}
h1.title { font-size: 140% }
h2.title { font-size: 140% }
h3.title { font-size: 130% }
h4.title { font-size: 120% }
h5.title { font-size: 110% }
h6.title { font-size: 100% }
.section h1
{
margin: 0em 0em 0.5em 0em;
font-size: 140%;
}
.section h2 { font-size: 140% }
.section h3 { font-size: 130% }
.section h4 { font-size: 120% }
.section h5 { font-size: 110% }
.section h6 { font-size: 100% }
/* Code on titles */
h1 tt.computeroutput { font-size: 140% }
h2 tt.computeroutput { font-size: 140% }
h3 tt.computeroutput { font-size: 130% }
h4 tt.computeroutput { font-size: 130% }
h5 tt.computeroutput { font-size: 130% }
h6 tt.computeroutput { font-size: 130% }
/*=============================================================================
Author
=============================================================================*/
h3.author
{
font-size: 100%
}
/*=============================================================================
Lists
=============================================================================*/
li
{
font-size: 10pt;
line-height: 1.3;
}
/* Unordered lists */
ul
{
text-align: left;
}
/* Ordered lists */
ol
{
text-align: left;
}
/*=============================================================================
Links
=============================================================================*/
a
{
text-decoration: none; /* no underline */
}
a:hover
{
text-decoration: underline;
}
/*=============================================================================
Spirit style navigation
=============================================================================*/
.spirit-nav
{
text-align: right;
}
.spirit-nav a
{
color: white;
padding-left: 0.5em;
}
.spirit-nav img
{
border-width: 0px;
}
/*=============================================================================
Copyright footer
=============================================================================*/
.copyright-footer
{
text-align: right;
font-size: 70%;
}
.copyright-footer p
{
text-align: right;
font-size: 80%;
}
/*=============================================================================
Table of contents
=============================================================================*/
.toc
{
margin: 1pc 4% 0pc 4%;
padding: 0.1pc 1pc 0.1pc 1pc;
font-size: 80%;
line-height: 1.15;
}
.boost-toc
{
float: right;
padding: 0.5pc;
}
/* Code on toc */
.toc .computeroutput { font-size: 120% }
/*=============================================================================
Tables
=============================================================================*/
.table-title,
div.table p.title
{
margin-left: 4%;
padding-right: 0.5em;
padding-left: 0.5em;
}
.informaltable table,
.table table
{
width: 92%;
margin-left: 4%;
margin-right: 4%;
}
div.informaltable table,
div.table table
{
padding: 4px;
}
/* Table Cells */
div.informaltable table tr td,
div.table table tr td
{
padding: 0.5em;
text-align: left;
font-size: 9pt;
}
div.informaltable table tr th,
div.table table tr th
{
padding: 0.5em 0.5em 0.5em 0.5em;
border: 1pt solid white;
font-size: 80%;
}
table.simplelist
{
width: auto !important;
margin: 0em !important;
padding: 0em !important;
border: none !important;
}
table.simplelist td
{
margin: 0em !important;
padding: 0em !important;
text-align: left !important;
font-size: 9pt !important;
border: none !important;
}
/*=============================================================================
Blurbs
=============================================================================*/
div.note,
div.tip,
div.important,
div.caution,
div.warning,
p.blurb
{
font-size: 9pt; /* A little bit smaller than the main text */
line-height: 1.2;
display: block;
margin: 1pc 4% 0pc 4%;
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
}
p.blurb img
{
padding: 1pt;
}
/*=============================================================================
Variable Lists
=============================================================================*/
div.variablelist
{
margin: 1em 0;
}
/* Make the terms in definition lists bold */
div.variablelist dl dt,
span.term
{
font-weight: bold;
font-size: 10pt;
}
div.variablelist table tbody tr td
{
text-align: left;
vertical-align: top;
padding: 0em 2em 0em 0em;
font-size: 10pt;
margin: 0em 0em 0.5em 0em;
line-height: 1;
}
div.variablelist dl dt
{
margin-bottom: 0.2em;
}
div.variablelist dl dd
{
margin: 0em 0em 0.5em 2em;
font-size: 10pt;
}
div.variablelist table tbody tr td p,
div.variablelist dl dd p
{
margin: 0em 0em 0.5em 0em;
line-height: 1;
}
/*=============================================================================
Misc
=============================================================================*/
/* Title of books and articles in bibliographies */
span.title
{
font-style: italic;
}
span.underline
{
text-decoration: underline;
}
span.strikethrough
{
text-decoration: line-through;
}
/* Copyright, Legal Notice */
div div.legalnotice p
{
text-align: left
}
/*=============================================================================
Colors
=============================================================================*/
@media screen
{
body {
background-color: #FFFFFF;
color: #000000;
}
/* Syntax Highlighting */
.keyword { color: #0000AA; }
.identifier { color: #000000; }
.special { color: #707070; }
.preprocessor { color: #402080; }
.char { color: teal; }
.comment { color: #800000; }
.string { color: teal; }
.number { color: teal; }
.white_bkd { background-color: #FFFFFF; }
.dk_grey_bkd { background-color: #999999; }
/* Links */
a, a .keyword, a .identifier, a .special, a .preprocessor
a .char, a .comment, a .string, a .number
{
color: #005a9c;
}
a:visited, a:visited .keyword, a:visited .identifier,
a:visited .special, a:visited .preprocessor a:visited .char,
a:visited .comment, a:visited .string, a:visited .number
{
color: #9c5a9c;
}
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a,
h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover,
h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited
{
text-decoration: none; /* no underline */
color: #000000;
}
/* Copyright, Legal Notice */
.copyright
{
color: #666666;
font-size: small;
}
div div.legalnotice p
{
color: #666666;
}
/* Program listing */
pre.synopsis
{
border: 1px solid #DCDCDC;
}
.programlisting,
.screen
{
border: 1px solid #DCDCDC;
}
td .programlisting,
td .screen
{
border: 0px solid #DCDCDC;
}
/* Blurbs */
div.note,
div.tip,
div.important,
div.caution,
div.warning,
p.blurb
{
border: 1px solid #DCDCDC;
}
/* Table of contents */
.toc
{
border: 1px solid #DCDCDC;
}
/* Tables */
div.informaltable table tr td,
div.table table tr td
{
border: 1px solid #DCDCDC;
}
div.informaltable table tr th,
div.table table tr th
{
background-color: #F0F0F0;
border: 1px solid #DCDCDC;
}
.copyright-footer
{
color: #8F8F8F;
}
/* Misc */
span.highlight
{
color: #00A000;
}
}
@media print
{
/* Links */
a
{
color: black;
}
a:visited
{
color: black;
}
.spirit-nav
{
display: none;
}
/* Program listing */
pre.synopsis
{
border: 1px solid gray;
}
.programlisting,
.screen
{
border: 1px solid gray;
}
td .programlisting,
td .screen
{
border: 0px solid #DCDCDC;
}
/* Table of contents */
.toc
{
border: 1px solid gray;
}
.informaltable table,
.table table
{
border: 1px solid gray;
border-collapse: collapse;
}
/* Tables */
div.informaltable table tr td,
div.table table tr td
{
border: 1px solid gray;
}
div.informaltable table tr th,
div.table table tr th
{
border: 1px solid gray;
}
table.simplelist tr td
{
border: none !important;
}
/* Misc */
span.highlight
{
font-weight: bold;
}
}
/*=============================================================================
Images
=============================================================================*/
span.inlinemediaobject img
{
vertical-align: middle;
}
/*==============================================================================
Super and Subscript: style so that line spacing isn't effected, see
http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=1&postId=5341
==============================================================================*/
sup,
sub {
height: 0;
line-height: 1;
vertical-align: baseline;
_vertical-align: bottom;
position: relative;
}
sup {
bottom: 1ex;
}
sub {
top: .5ex;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

View File

@@ -0,0 +1,356 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Chapter&#160;1.&#160;Phoenix 3.2.0</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="next" href="phoenix/release_notes.html" title="Release Notes">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav"><a accesskey="n" href="phoenix/release_notes.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
<div class="chapter">
<div class="titlepage"><div>
<div><h2 class="title">
<a name="phoenix"></a>Chapter&#160;1.&#160;Phoenix 3.2.0</h2></div>
<div><div class="author"><h3 class="author">
<span class="firstname">Joel</span> <span class="surname">de Guzman</span>
</h3></div></div>
<div><div class="author"><h3 class="author">
<span class="firstname">Dan</span> <span class="surname">Marsden</span>
</h3></div></div>
<div><div class="author"><h3 class="author">
<span class="firstname">Thomas</span> <span class="surname">Heller</span>
</h3></div></div>
<div><div class="author"><h3 class="author">
<span class="firstname">John</span> <span class="surname">Fletcher</span>
</h3></div></div>
<div><p class="copyright">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher</p></div>
<div><div class="legalnotice">
<a name="phoenix.legal"></a><p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></div>
</div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="section"><a href="phoenix/release_notes.html">Release Notes</a></span></dt>
<dt><span class="section"><a href="phoenix/what_s_new.html">What's New</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/what_s_new/phoenix___warning_on__lambda_and_let_.html">Phoenix
- warning on <span class="bold"><strong>lambda and let</strong></span></a></span></dt>
<dt><span class="section"><a href="phoenix/what_s_new/phoenix_3_2_0__boost_1_58_0_.html">Phoenix
3.2.0 (Boost 1.58.0)</a></span></dt>
<dt><span class="section"><a href="phoenix/what_s_new/phoenix_3_1_1.html">Phoenix 3.1.1</a></span></dt>
<dt><span class="section"><a href="phoenix/what_s_new/phoenix_3_1_0.html">Phoenix 3.1.0</a></span></dt>
<dt><span class="section"><a href="phoenix/what_s_new/phoenix_3_0_6__boost_1_57_0_.html">Phoenix
3.0.6 (Boost 1.57.0)</a></span></dt>
<dt><span class="section"><a href="phoenix/what_s_new/phoenix_3_0_5.html">Phoenix 3.0.5</a></span></dt>
<dt><span class="section"><a href="phoenix/what_s_new/phoenix_3_0.html">Phoenix 3.0</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="phoenix/introduction.html">Introduction</a></span></dt>
<dt><span class="section"><a href="phoenix/starter_kit.html">Starter Kit</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/starter_kit/values.html">Values</a></span></dt>
<dt><span class="section"><a href="phoenix/starter_kit/references.html">References</a></span></dt>
<dt><span class="section"><a href="phoenix/starter_kit/arguments.html">Arguments</a></span></dt>
<dt><span class="section"><a href="phoenix/starter_kit/lazy_operators.html">Lazy Operators</a></span></dt>
<dt><span class="section"><a href="phoenix/starter_kit/lazy_statements.html">Lazy Statements</a></span></dt>
<dt><span class="section"><a href="phoenix/starter_kit/construct__new__delete__casts.html">Construct,
New, Delete, Casts</a></span></dt>
<dt><span class="section"><a href="phoenix/starter_kit/lazy_functions.html">Lazy Functions</a></span></dt>
<dt><span class="section"><a href="phoenix/starter_kit/more.html">More</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="phoenix/basics.html">Basics</a></span></dt>
<dt><span class="section"><a href="phoenix/organization.html">Organization</a></span></dt>
<dt><span class="section"><a href="phoenix/actor.html">Actor</a></span></dt>
<dt><span class="section"><a href="phoenix/modules.html">Modules</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/modules/core.html">Core</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/modules/core/values.html">Values</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/core/references.html">References</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/core/arguments.html">Arguments</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/core/nothing.html">Nothing</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="phoenix/modules/function.html">Function</a></span></dt>
<dd><dl><dt><span class="section"><a href="phoenix/modules/function/adapting_functions.html">Adapting
Functions</a></span></dt></dl></dd>
<dt><span class="section"><a href="phoenix/modules/operator.html">Operator</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/statement.html">Statement</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/modules/statement/block_statement.html">Block Statement</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/statement/if__statement.html">if_ Statement</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/statement/___if_else_____statement.html">if_else_ Statement</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/statement/switch__statement.html">switch_
Statement</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/statement/while__statement.html">while_
Statement</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/statement/___do_while_____statement.html">do_while_ Statement</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/statement/for_statement.html">for_ Statement</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/statement/try__catch__statement.html">try_
catch_ Statement</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/statement/throw_.html">throw_</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="phoenix/modules/object.html">Object</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/modules/object/construction.html">Construction</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/object/new.html">New</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/object/delete.html">Delete</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/object/casts.html">Casts</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="phoenix/modules/scope.html">Scope</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/modules/scope/local_variables.html">Local Variables</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/scope/let.html">let</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/scope/lambda.html">lambda</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="phoenix/modules/bind.html">Bind</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/modules/bind/binding_function_objects.html">Binding
Function Objects</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/bind/binding_functions.html">Binding Functions</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/bind/binding_member_functions.html">Binding
Member Functions</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/bind/binding_member_variables.html">Binding
Member Variables</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/bind/compatibility_with_boost_bind.html">Compatibility
with Boost.Bind</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="phoenix/modules/stl.html">STL</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/modules/stl/container.html">Container</a></span></dt>
<dt><span class="section"><a href="phoenix/modules/stl/algorithm.html">Algorithm</a></span></dt>
</dl></dd>
</dl></dd>
<dt><span class="section"><a href="phoenix/inside.html">Inside Phoenix</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/inside/actor.html">Actors in Detail</a></span></dt>
<dt><span class="section"><a href="phoenix/inside/expression.html">Phoenix Expressions</a></span></dt>
<dd><dl><dt><span class="section"><a href="phoenix/inside/expression/boilerplate_macros.html">Boilerplate
Macros</a></span></dt></dl></dd>
<dt><span class="section"><a href="phoenix/inside/actions.html">More on Actions</a></span></dt>
<dt><span class="section"><a href="phoenix/inside/rules.html">Predefined Expressions and Rules</a></span></dt>
<dt><span class="section"><a href="phoenix/inside/custom_terminals.html">Custom Terminals</a></span></dt>
<dt><span class="section"><a href="phoenix/inside/placeholder_unification.html">Placeholder Unification</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="phoenix/examples.html">Advanced Examples</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/examples/extending_actors.html">Extending Actors</a></span></dt>
<dt><span class="section"><a href="phoenix/examples/adding_an_expression.html">Adding an expression</a></span></dt>
<dt><span class="section"><a href="phoenix/examples/transforming_the_expression_tree.html">Transforming
the Expression Tree</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="phoenix/lazy_list.html">Lazy List</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/lazy_list/background.html">Background</a></span></dt>
<dt><span class="section"><a href="phoenix/lazy_list/what_is_provided.html">What is provided</a></span></dt>
<dt><span class="section"><a href="phoenix/lazy_list/tutorial_with_examples.html">Tutorial with
examples</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/lazy_list/tutorial_with_examples/arithmetic_functions.html">Arithmetic
functions</a></span></dt>
<dt><span class="section"><a href="phoenix/lazy_list/tutorial_with_examples/list_generation.html">List
Generation</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="phoenix/lazy_list/exceptions.html">Exceptions</a></span></dt>
<dt><span class="section"><a href="phoenix/lazy_list/implementation_details.html">Implementation
Details</a></span></dt>
<dt><span class="section"><a href="phoenix/lazy_list/testing.html">Testing</a></span></dt>
<dt><span class="section"><a href="phoenix/lazy_list/where_next_.html">Where Next?</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="phoenix/maintenance.html">Maintenance</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/maintenance/background.html">Background</a></span></dt>
<dt><span class="section"><a href="phoenix/maintenance/my_understanding_of_how_maintenance_works.html">My
Understanding of how maintenance works</a></span></dt>
<dt><span class="section"><a href="phoenix/maintenance/method_in_use.html">Method in use</a></span></dt>
<dt><span class="section"><a href="phoenix/maintenance/experience.html">Experience</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="phoenix/maintenance/experience/maintenance_tools.html">Maintenance
Tools</a></span></dt>
<dt><span class="section"><a href="phoenix/maintenance/experience/bugs_to_be_fixed.html">Bugs
to be fixed</a></span></dt>
<dt><span class="section"><a href="phoenix/maintenance/experience/compilers.html">Compilers</a></span></dt>
</dl></dd>
</dl></dd>
<dt><span class="section"><a href="phoenix/wrap_up.html">Wrap Up</a></span></dt>
<dt><span class="section"><a href="phoenix/acknowledgments.html">Acknowledgments</a></span></dt>
<dt><span class="section"><a href="phoenix/references.html">References</a></span></dt>
</dl>
</div>
<h2>
<a name="phoenix.h0"></a>
<span><a name="phoenix.preface"></a></span><a class="link" href="index.html#phoenix.preface">Preface</a>
</h2>
<div class="blockquote"><blockquote class="blockquote"><p>
<span class="emphasis"><em>Functional programming is so called because a program consists entirely
of functions. The main program itself is written as a function which receives
the program's input as its argument and delivers the program's output as its
result. Typically the main function is defined in terms of other functions,
which in turn are defined in terms of still more functions until at the bottom
level the functions are language primitives.</em></span>
</p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
<span class="bold"><strong>John Hughes</strong></span>-- <span class="emphasis"><em>Why Functional Programming
Matters</em></span>
</p></blockquote></div>
<p>
<span class="inlinemediaobject"><img src="images/lambda_cpp.png"></span>
</p>
<h3>
<a name="phoenix.h1"></a>
<span><a name="phoenix.description"></a></span><a class="link" href="index.html#phoenix.description">Description</a>
</h3>
<p>
Phoenix enables Functional Programming (FP) in C++. The design and implementation
of Phoenix is highly influenced by <a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>
by Yannis Smaragdakis and Brian McNamara and the <a href="http://www.boost.org/libs/lambda/doc/index.html" target="_top">BLL</a>
(Boost Lambda Library) by Jaakko Jaarvi and Gary Powell. Phoenix is a blend of
FC++ and BLL using the implementation techniques used in the <a href="http://spirit.sourceforge.net" target="_top">Spirit</a>
inline parser.
</p>
<p>
Phoenix is a header only library. It is extremely modular by design. One can
extract and use only a small subset of the full library, literally tearing the
library into small pieces, without fear that the pieces won't work anymore. The
library is organized in highly independent modules and layers.
</p>
<h3>
<a name="phoenix.h2"></a>
<span><a name="phoenix.how_to_use_this_manual"></a></span><a class="link" href="index.html#phoenix.how_to_use_this_manual">How
to use this manual</a>
</h3>
<p>
The Phoenix library is organized in logical modules. This documentation provides
a user's guide and reference for each module in the library. A simple and clear
code example is worth a hundred lines of documentation; therefore, the user's
guide is presented with abundant examples annotated and explained in step-wise
manner. The user's guide is based on examples: lots of them.
</p>
<p>
As much as possible, forward information (i.e. citing a specific piece of information
that has not yet been discussed) is avoided in the user's manual portion of each
module. In many cases, though, it is unavoidable that advanced but related topics
be interspersed with the normal flow of discussion. To alleviate this problem,
topics categorized as "advanced" may be skipped at first reading.
</p>
<p>
Some icons are used to mark certain topics indicative of their relevance. These
icons precede some text to indicate:
</p>
<div class="table">
<a name="phoenix.t0"></a><p class="title"><b>Table&#160;1.1.&#160;Icons</b></p>
<div class="table-contents"><table class="table" summary="Icons">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Icon
</p>
</th>
<th>
<p>
Name
</p>
</th>
<th>
<p>
Meaning
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
<span class="inlinemediaobject"><img src="images/note.png"></span>
</p>
</td>
<td>
<p>
Note
</p>
</td>
<td>
<p>
Information provided is auxiliary but will give the reader a deeper
insight into a specific topic. May be skipped.
</p>
</td>
</tr>
<tr>
<td>
<p>
<span class="inlinemediaobject"><img src="images/alert.png"></span>
</p>
</td>
<td>
<p>
Alert
</p>
</td>
<td>
<p>
Information provided is of utmost importance.
</p>
</td>
</tr>
<tr>
<td>
<p>
<span class="inlinemediaobject"><img src="images/tip.png"></span>
</p>
</td>
<td>
<p>
Tip
</p>
</td>
<td>
<p>
A potentially useful and helpful piece of information.
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="sidebar">
<p class="title"><b></b></p>
<p>
<span class="inlinemediaobject"><img src="images/note.png"></span>
Unless otherwise noted <code class="computeroutput"><span class="keyword">using</span> <span class="keyword">namespace</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">;</span></code> is
assumed
</p>
</div>
<h3>
<a name="phoenix.h3"></a>
<span><a name="phoenix._emphasis_role__bold___emphasis____to_joel_s_dear_daughter__phoenix__emphasis___emphasis_"></a></span><a class="link" href="index.html#phoenix._emphasis_role__bold___emphasis____to_joel_s_dear_daughter__phoenix__emphasis___emphasis_"><span class="bold"><strong><span class="emphasis"><em>...To Joel's dear daughter, Phoenix</em></span></strong></span></a>
</h3>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: June 28, 2017 at 13:57:41 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
<div class="spirit-nav"><a accesskey="n" href="phoenix/release_notes.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
</body>
</html>

View File

@@ -0,0 +1,93 @@
index.html
phoenix/release_notes.html
phoenix/what_s_new.html
phoenix/what_s_new/phoenix___warning_on__lambda_and_let_.html
phoenix/what_s_new/phoenix_3_2_0__boost_1_58_0_.html
phoenix/what_s_new/phoenix_3_1_1.html
phoenix/what_s_new/phoenix_3_1_0.html
phoenix/what_s_new/phoenix_3_0_6__boost_1_57_0_.html
phoenix/what_s_new/phoenix_3_0_5.html
phoenix/what_s_new/phoenix_3_0.html
phoenix/introduction.html
phoenix/starter_kit.html
phoenix/starter_kit/values.html
phoenix/starter_kit/references.html
phoenix/starter_kit/arguments.html
phoenix/starter_kit/lazy_operators.html
phoenix/starter_kit/lazy_statements.html
phoenix/starter_kit/construct__new__delete__casts.html
phoenix/starter_kit/lazy_functions.html
phoenix/starter_kit/more.html
phoenix/basics.html
phoenix/organization.html
phoenix/actor.html
phoenix/modules.html
phoenix/modules/core.html
phoenix/modules/core/values.html
phoenix/modules/core/references.html
phoenix/modules/core/arguments.html
phoenix/modules/core/nothing.html
phoenix/modules/function.html
phoenix/modules/function/adapting_functions.html
phoenix/modules/operator.html
phoenix/modules/statement.html
phoenix/modules/statement/block_statement.html
phoenix/modules/statement/if__statement.html
phoenix/modules/statement/___if_else_____statement.html
phoenix/modules/statement/switch__statement.html
phoenix/modules/statement/while__statement.html
phoenix/modules/statement/___do_while_____statement.html
phoenix/modules/statement/for_statement.html
phoenix/modules/statement/try__catch__statement.html
phoenix/modules/statement/throw_.html
phoenix/modules/object.html
phoenix/modules/object/construction.html
phoenix/modules/object/new.html
phoenix/modules/object/delete.html
phoenix/modules/object/casts.html
phoenix/modules/scope.html
phoenix/modules/scope/local_variables.html
phoenix/modules/scope/let.html
phoenix/modules/scope/lambda.html
phoenix/modules/bind.html
phoenix/modules/bind/binding_function_objects.html
phoenix/modules/bind/binding_functions.html
phoenix/modules/bind/binding_member_functions.html
phoenix/modules/bind/binding_member_variables.html
phoenix/modules/bind/compatibility_with_boost_bind.html
phoenix/modules/stl.html
phoenix/modules/stl/container.html
phoenix/modules/stl/algorithm.html
phoenix/inside.html
phoenix/inside/actor.html
phoenix/inside/expression.html
phoenix/inside/expression/boilerplate_macros.html
phoenix/inside/actions.html
phoenix/inside/rules.html
phoenix/inside/custom_terminals.html
phoenix/inside/placeholder_unification.html
phoenix/examples.html
phoenix/examples/extending_actors.html
phoenix/examples/adding_an_expression.html
phoenix/examples/transforming_the_expression_tree.html
phoenix/lazy_list.html
phoenix/lazy_list/background.html
phoenix/lazy_list/what_is_provided.html
phoenix/lazy_list/tutorial_with_examples.html
phoenix/lazy_list/tutorial_with_examples/arithmetic_functions.html
phoenix/lazy_list/tutorial_with_examples/list_generation.html
phoenix/lazy_list/exceptions.html
phoenix/lazy_list/implementation_details.html
phoenix/lazy_list/testing.html
phoenix/lazy_list/where_next_.html
phoenix/maintenance.html
phoenix/maintenance/background.html
phoenix/maintenance/my_understanding_of_how_maintenance_works.html
phoenix/maintenance/method_in_use.html
phoenix/maintenance/experience.html
phoenix/maintenance/experience/maintenance_tools.html
phoenix/maintenance/experience/bugs_to_be_fixed.html
phoenix/maintenance/experience/compilers.html
phoenix/wrap_up.html
phoenix/acknowledgments.html
phoenix/references.html

View File

@@ -0,0 +1,95 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Acknowledgments</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="prev" href="wrap_up.html" title="Wrap Up">
<link rel="next" href="references.html" title="References">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="wrap_up.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="references.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="phoenix.acknowledgments"></a><a class="link" href="acknowledgments.html" title="Acknowledgments">Acknowledgments</a>
</h2></div></div></div>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
Hartmut Kaiser implemented the original lazy casts and constructors based
on his original work on Spirit SE "semantic expressions" (the
precursor to Phoenix), and guided Phoenix from the initial review of V2
to the release of V3.
</li>
<li class="listitem">
Eric Niebler did a 2.0 pre-release review and wrote some range related
code that Phoenix stole and used in the algorithms. Additionally he played
the leading role in inventing the extension mechanism as well as providing
early prototypes and helping with Boost.Proto code. DA Proto MAN!
</li>
<li class="listitem">
Angus Leeming implemented the container functions on Phoenix-1 which I
then ported to Phoenix-2.
</li>
<li class="listitem">
Daniel Wallin helped with the scope module, local variables, let and lambda
and the algorithms. I frequently discuss design issues with Daniel on Yahoo
Messenger.
</li>
<li class="listitem">
Jaakko Jarvi. DA Lambda MAN!
</li>
<li class="listitem">
Dave Abrahams, for his constant presence, wherever, whenever.
</li>
<li class="listitem">
Aleksey Gurtovoy, DA MPL MAN!
</li>
<li class="listitem">
Doug Gregor, always a source of inspiration.
</li>
<li class="listitem">
Dan Marsden, did almost all the work in bringing Phoenix-2 out the door.
</li>
<li class="listitem">
Thorsten Ottosen; Eric's range_ex code began life as "container_algo"
in the old boost sandbox, by Thorsten in 2002-2003.
</li>
<li class="listitem">
Jeremy Siek, even prior to Thorsten, in 2001, started the "container_algo".
</li>
<li class="listitem">
Vladimir Prus wrote the mutating algorithms code from the Boost Wiki.
</li>
<li class="listitem">
Daryle Walker did a 2.0 pre-release review.
</li>
</ol></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="wrap_up.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="references.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,91 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Actor</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="prev" href="organization.html" title="Organization">
<link rel="next" href="modules.html" title="Modules">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="organization.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="modules.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="phoenix.actor"></a><a class="link" href="actor.html" title="Actor">Actor</a>
</h2></div></div></div>
<p>
The <code class="computeroutput"><span class="identifier">Actor</span></code> is the main concept
behind the library. Actors are function objects. An actor can accept 0 to
<code class="computeroutput"><span class="identifier">BOOST_PHOENIX_LIMIT</span></code> arguments.
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
You can set <code class="computeroutput"><span class="identifier">BOOST_PHOENIX_LIMIT</span></code>,
the predefined maximum arity an actor can take. By default, <code class="computeroutput"><span class="identifier">BOOST_PHOENIX_LIMIT</span></code> is set to 10.
</p></td></tr>
</table></div>
<p>
Phoenix supplies an <code class="computeroutput"><span class="identifier">actor</span></code> class
template whose specializations model the <code class="computeroutput"><span class="identifier">Actor</span></code>
concept. <code class="computeroutput"><span class="identifier">actor</span></code> has one template
parameter, <code class="computeroutput"><span class="identifier">Expr</span></code>, that supplies
the underlying expression to evaluate.
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Expr</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">actor</span>
<span class="special">{</span>
<span class="identifier">return_type</span>
<span class="keyword">operator</span><span class="special">()()</span> <span class="keyword">const</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T0</span><span class="special">&gt;</span>
<span class="identifier">return_type</span>
<span class="keyword">operator</span><span class="special">()(</span><span class="identifier">T0</span><span class="special">&amp;</span> <span class="identifier">_0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">T1</span><span class="special">&gt;</span>
<span class="identifier">return_type</span>
<span class="keyword">operator</span><span class="special">()(</span><span class="identifier">T0</span><span class="special">&amp;</span> <span class="identifier">_0</span><span class="special">,</span> <span class="identifier">T1</span><span class="special">&amp;</span> <span class="identifier">_1</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="comment">//...</span>
<span class="special">};</span>
</pre>
<p>
The actor class accepts the arguments through a set of function call operators
for 0 to <code class="computeroutput"><span class="identifier">BOOST_PHOENIX_LIMIT</span></code>
arities (Don't worry about the details, for now. Note, for example, that we
skimp over the details regarding <code class="computeroutput"><span class="identifier">return_type</span></code>).
The arguments are passed through to the evaluation mechanism. For more information
see <a class="link" href="inside/actor.html" title="Actors in Detail">Inside Actors</a>.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="organization.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="modules.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,274 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Basics</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="prev" href="starter_kit/more.html" title="More">
<link rel="next" href="organization.html" title="Organization">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="starter_kit/more.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="organization.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="phoenix.basics"></a><a class="link" href="basics.html" title="Basics">Basics</a>
</h2></div></div></div>
<p>
Almost everything is a function in the Phoenix library that can be evaluated
as <code class="computeroutput"><span class="identifier">f</span><span class="special">(</span><span class="identifier">a1</span><span class="special">,</span> <span class="identifier">a2</span><span class="special">,</span> <span class="special">...,</span> a/n/<span class="special">)</span></code>, where <span class="emphasis"><em>n</em></span> is the function's
arity, or number of arguments that the function expects. Operators are also
functions. For example, <code class="computeroutput"><span class="identifier">a</span> <span class="special">+</span> <span class="identifier">b</span></code> is just
a function with arity == 2 (or binary). <code class="computeroutput"><span class="identifier">a</span>
<span class="special">+</span> <span class="identifier">b</span></code>
is the same as <code class="computeroutput"><span class="identifier">add</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">)</span></code>, <code class="computeroutput"><span class="identifier">a</span>
<span class="special">+</span> <span class="identifier">b</span> <span class="special">+</span> <span class="identifier">c</span></code> is the
same as <code class="computeroutput"><span class="identifier">add</span><span class="special">(</span><span class="identifier">add</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">),</span>
<span class="identifier">c</span><span class="special">)</span></code>.
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
Amusingly, functions may even return functions. We shall see what this means
in a short while.
</p></td></tr>
</table></div>
<h4>
<a name="phoenix.basics.h0"></a>
<span><a name="phoenix.basics.partial_function_application"></a></span><a class="link" href="basics.html#phoenix.basics.partial_function_application">Partial
Function Application</a>
</h4>
<p>
Think of a function as a black box. You pass arguments and it returns something
back. The figure below depicts the typical scenario.
</p>
<p>
<span class="inlinemediaobject"><img src="../images/fbox.png"></span>
</p>
<p>
A fully evaluated function is one in which all the arguments are given. All
functions in plain C++ are fully evaluated. When you call the <code class="computeroutput"><span class="identifier">sin</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code> function, you have to pass a number x. The
function will return a result in return: the sin of x. When you call the <code class="computeroutput"><span class="identifier">add</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">)</span></code>
function, you have to pass two numbers x and y. The function will return the
sum of the two numbers. The figure below is a fully evaluated <code class="computeroutput"><span class="identifier">add</span></code> function.
</p>
<p>
<span class="inlinemediaobject"><img src="../images/adder.png"></span>
</p>
<p>
A partially applied function, on the other hand, is one in which not all the
arguments are supplied. If we are able to partially apply the function <code class="computeroutput"><span class="identifier">add</span></code> above, we may pass only the first argument.
In doing so, the function does not have all the required information it needs
to perform its task to compute and return a result. What it returns instead
is another function, a lambda function. Unlike the original <code class="computeroutput"><span class="identifier">add</span></code>
function which has an arity of 2, the resulting lambda function has an arity
of 1. Why? because we already supplied part of the input: <code class="computeroutput"><span class="number">2</span></code>
</p>
<p>
<span class="inlinemediaobject"><img src="../images/add2.png"></span>
</p>
<p>
Now, when we shove in a number into our lambda function, it will return 2 plus
whatever we pass in. The lambda function essentially remembers 1) the original
function, <code class="computeroutput"><span class="identifier">add</span></code>, and 2) the partial
input, 2. The figure below illustrates a case where we pass 3 to our lambda
function, which then returns 5:
</p>
<p>
<span class="inlinemediaobject"><img src="../images/add2_call.png"></span>
</p>
<p>
Obviously, partially applying the <code class="computeroutput"><span class="identifier">add</span></code>
function, as we see above, cannot be done directly in C++ where we are expected
to supply all the arguments that a function expects. That's where the Phoenix
library comes in. The library provides the facilities to do partial function
application. And even more, with Phoenix, these resulting functions won't be
black boxes anymore.
</p>
<h4>
<a name="phoenix.basics.h1"></a>
<span><a name="phoenix.basics.stl_and_higher_order_functions"></a></span><a class="link" href="basics.html#phoenix.basics.stl_and_higher_order_functions">STL
and higher order functions</a>
</h4>
<p>
So, what's all the fuss? What makes partial function application so useful?
Recall our original example in the <a class="link" href="starter_kit/lazy_operators.html" title="Lazy Operators">previous
section</a>:
</p>
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">find_if</span><span class="special">(</span><span class="identifier">c</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">c</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">arg1</span> <span class="special">%</span> <span class="number">2</span> <span class="special">==</span> <span class="number">1</span><span class="special">)</span>
</pre>
<p>
The expression <code class="computeroutput"><span class="identifier">arg1</span> <span class="special">%</span>
<span class="number">2</span> <span class="special">==</span> <span class="number">1</span></code> evaluates to a lambda function. <code class="computeroutput"><span class="identifier">arg1</span></code> is a placeholder for an argument to
be supplied later. Hence, since there's only one unsupplied argument, the lambda
function has an arity 1. It just so happens that <code class="computeroutput"><span class="identifier">find_if</span></code>
supplies the unsupplied argument as it loops from <code class="computeroutput"><span class="identifier">c</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span></code>
to <code class="computeroutput"><span class="identifier">c</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span></code>.
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
Higher order functions are functions which can take other functions as arguments,
and may also return functions as results. Higher order functions are functions
that are treated like any other objects and can be used as arguments and
return values from functions.
</p></td></tr>
</table></div>
<h4>
<a name="phoenix.basics.h2"></a>
<span><a name="phoenix.basics.lazy_evaluation"></a></span><a class="link" href="basics.html#phoenix.basics.lazy_evaluation">Lazy
Evaluation</a>
</h4>
<p>
In Phoenix, to put it more accurately, function evaluation has two stages:
</p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
Partial application
</li>
<li class="listitem">
Final evaluation
</li>
</ol></div>
<p>
The first stage is handled by a set of generator functions. These are your
front ends (in the client's perspective). These generators create (through
partial function application), higher order functions that can be passed on
just like any other function pointer or function object. The second stage,
the actual function call, can be invoked or executed anytime in the future,
or not at all; hence <span class="emphasis"><em>"lazy"</em></span>.
</p>
<p>
If we look more closely, the first step involves partial function application:
</p>
<pre class="programlisting"><span class="identifier">arg1</span> <span class="special">%</span> <span class="number">2</span> <span class="special">==</span> <span class="number">1</span>
</pre>
<p>
The second step is the actual function invocation (done inside the <code class="computeroutput"><span class="identifier">find_if</span></code> function. These are the back-ends
(often, the final invocation is never actually seen by the client). In our
example, the <code class="computeroutput"><span class="identifier">find_if</span></code>, if we
take a look inside, we'll see something like:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">InputIterator</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Predicate</span><span class="special">&gt;</span>
<span class="identifier">InputIterator</span>
<span class="identifier">find_if</span><span class="special">(</span><span class="identifier">InputIterator</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">InputIterator</span> <span class="identifier">last</span><span class="special">,</span> <span class="identifier">Predicate</span> <span class="identifier">pred</span><span class="special">)</span>
<span class="special">{</span>
<span class="keyword">while</span> <span class="special">(</span><span class="identifier">first</span> <span class="special">!=</span> <span class="identifier">last</span> <span class="special">&amp;&amp;</span> <span class="special">!</span><span class="identifier">pred</span><span class="special">(*</span><span class="identifier">first</span><span class="special">))</span> <span class="comment">// &lt;--- The lambda function is called here</span>
<span class="special">++</span><span class="identifier">first</span><span class="special">;</span> <span class="comment">// passing in *first</span>
<span class="keyword">return</span> <span class="identifier">first</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
Again, typically, we, as clients, see only the first step. However, in this
document and in the examples and tests provided, don't be surprised to see
the first and second steps juxtaposed in order to illustrate the complete semantics
of Phoenix expressions. Examples:
</p>
<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>
<span class="keyword">int</span> <span class="identifier">y</span> <span class="special">=</span> <span class="number">2</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(</span><span class="identifier">arg1</span> <span class="special">%</span> <span class="number">2</span> <span class="special">==</span> <span class="number">1</span><span class="special">)(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// prints 1 or true</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="special">(</span><span class="identifier">arg1</span> <span class="special">%</span> <span class="number">2</span> <span class="special">==</span> <span class="number">1</span><span class="special">)(</span><span class="identifier">y</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// prints 0 or false</span>
</pre>
<h4>
<a name="phoenix.basics.h3"></a>
<span><a name="phoenix.basics.forwarding_function_problem"></a></span><a class="link" href="basics.html#phoenix.basics.forwarding_function_problem">Forwarding
Function Problem</a>
</h4>
<p>
Usually, we, as clients, write the call-back functions while libraries (such
as STL) provide the callee (e.g. <code class="computeroutput"><span class="identifier">find_if</span></code>).
In case the role is reversed, e.g. if you have to write an STL algorithm that
takes in a predicate, or develop a GUI library that accepts event handlers,
you have to be aware of a little known problem in C++ called the "<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm" target="_top">Forwarding
Function Problem</a>".
</p>
<p>
Look again at the code above:
</p>
<pre class="programlisting"><span class="special">(</span><span class="identifier">arg1</span> <span class="special">%</span> <span class="number">2</span> <span class="special">==</span> <span class="number">1</span><span class="special">)(</span><span class="identifier">x</span><span class="special">)</span>
</pre>
<p>
Notice that, in the second-stage (the final evaluation), we used a variable
<code class="computeroutput"><span class="identifier">x</span></code>.
</p>
<p>
In Phoenix we emulated perfect forwarding through preprocessor macros generating
code to allow const and non-const references.
</p>
<p>
We generate these second-stage overloads for Phoenix expression up to <code class="computeroutput"><span class="identifier">BOOST_PHOENIX_PERFECT_FORWARD_LIMIT</span></code>
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
You can set <code class="computeroutput"><span class="identifier">BOOST_PHOENIX_PERFECT_FORWARD_LIMIT</span></code>,
the predefined maximum perfect forward arguments an actor can take. By default,
<code class="computeroutput"><span class="identifier">BOOST_PHOENIX_PERFECT_FORWARDLIMIT</span></code>
is set to 3.
</p></td></tr>
</table></div>
<h4>
<a name="phoenix.basics.h4"></a>
<span><a name="phoenix.basics.polymorphic_functions"></a></span><a class="link" href="basics.html#phoenix.basics.polymorphic_functions">Polymorphic
Functions</a>
</h4>
<p>
Unless otherwise noted, Phoenix generated functions are fully polymorphic.
For instance, the <code class="computeroutput"><span class="identifier">add</span></code> example
above can apply to integers, floating points, user defined complex numbers
or even strings. Example:
</p>
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">h</span><span class="special">(</span><span class="string">"Hello"</span><span class="special">);</span>
<span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">w</span> <span class="special">=</span> <span class="string">" World"</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">r</span> <span class="special">=</span> <span class="identifier">add</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">)(</span><span class="identifier">h</span><span class="special">,</span> <span class="identifier">w</span><span class="special">);</span>
</pre>
<p>
evaluates to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">(</span><span class="string">"Hello
World"</span><span class="special">)</span></code>. The observant
reader might notice that this function call in fact takes in heterogeneous
arguments where <code class="computeroutput"><span class="identifier">arg1</span></code> is of
type <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code> and <code class="computeroutput"><span class="identifier">arg2</span></code>
is of type <code class="computeroutput"><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span></code>. <code class="computeroutput"><span class="identifier">add</span></code>
still works because the C++ standard library allows the expression <code class="computeroutput"><span class="identifier">a</span> <span class="special">+</span> <span class="identifier">b</span></code>
where <code class="computeroutput"><span class="identifier">a</span></code> is a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code>
and <code class="computeroutput"><span class="identifier">b</span></code> is a <code class="computeroutput"><span class="keyword">char</span>
<span class="keyword">const</span><span class="special">*</span></code>.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="starter_kit/more.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="organization.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,50 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Advanced Examples</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="prev" href="inside/placeholder_unification.html" title="Placeholder Unification">
<link rel="next" href="examples/extending_actors.html" title="Extending Actors">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="inside/placeholder_unification.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="examples/extending_actors.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="phoenix.examples"></a><a class="link" href="examples.html" title="Advanced Examples">Advanced Examples</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="examples/extending_actors.html">Extending Actors</a></span></dt>
<dt><span class="section"><a href="examples/adding_an_expression.html">Adding an expression</a></span></dt>
<dt><span class="section"><a href="examples/transforming_the_expression_tree.html">Transforming
the Expression Tree</a></span></dt>
</dl></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="inside/placeholder_unification.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="examples/extending_actors.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,159 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Adding an expression</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../examples.html" title="Advanced Examples">
<link rel="prev" href="extending_actors.html" title="Extending Actors">
<link rel="next" href="transforming_the_expression_tree.html" title="Transforming the Expression Tree">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="extending_actors.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="transforming_the_expression_tree.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.examples.adding_an_expression"></a><a class="link" href="adding_an_expression.html" title="Adding an expression">Adding an expression</a>
</h3></div></div></div>
<p>
This is not a toy example. This is actually part of the library. Remember
the <a class="link" href="../modules/statement/while__statement.html" title="while_ Statement"><code class="computeroutput"><span class="keyword">while</span></code></a> lazy statement? Putting together
everything we've learned so far, we eill present it here in its entirety
(verbatim):
</p>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_DEFINE_EXPRESSION</span><span class="special">(</span>
<span class="special">(</span><span class="identifier">boost</span><span class="special">)(</span><span class="identifier">phoenix</span><span class="special">)(</span><span class="identifier">while_</span><span class="special">)</span>
<span class="special">,</span> <span class="special">(</span><span class="identifier">meta_grammar</span><span class="special">)</span> <span class="comment">// Cond</span>
<span class="special">(</span><span class="identifier">meta_grammar</span><span class="special">)</span> <span class="comment">// Do</span>
<span class="special">)</span>
<span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">phoenix</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">while_eval</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="keyword">void</span> <span class="identifier">result_type</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Cond</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Do</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Context</span><span class="special">&gt;</span>
<span class="identifier">result_type</span>
<span class="keyword">operator</span><span class="special">()(</span><span class="identifier">Cond</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">cond</span><span class="special">,</span> <span class="identifier">Do</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">do_</span><span class="special">,</span> <span class="identifier">Context</span> <span class="special">&amp;</span> <span class="identifier">ctx</span><span class="special">)</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">while</span><span class="special">(</span><span class="identifier">eval</span><span class="special">(</span><span class="identifier">cond</span><span class="special">,</span> <span class="identifier">ctx</span><span class="special">))</span>
<span class="special">{</span>
<span class="identifier">eval</span><span class="special">(</span><span class="identifier">do_</span><span class="special">,</span> <span class="identifier">ctx</span><span class="special">);</span>
<span class="special">}</span>
<span class="special">}</span>
<span class="special">};</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Dummy</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">default_actions</span><span class="special">::</span><span class="identifier">when</span><span class="special">&lt;</span><span class="identifier">rule</span><span class="special">::</span><span class="identifier">while_</span><span class="special">,</span> <span class="identifier">Dummy</span><span class="special">&gt;</span>
<span class="special">:</span> <span class="identifier">call</span><span class="special">&lt;</span><span class="identifier">while_eval</span><span class="special">,</span> <span class="identifier">Dummy</span><span class="special">&gt;</span>
<span class="special">{};</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Cond</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">while_gen</span>
<span class="special">{</span>
<span class="identifier">while_gen</span><span class="special">(</span><span class="identifier">Cond</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">cond</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">cond</span><span class="special">(</span><span class="identifier">cond</span><span class="special">)</span> <span class="special">{}</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Do</span><span class="special">&gt;</span>
<span class="keyword">typename</span> <span class="identifier">expression</span><span class="special">::</span><span class="identifier">while_</span><span class="special">&lt;</span><span class="identifier">Cond</span><span class="special">,</span> <span class="identifier">Do</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span>
<span class="keyword">operator</span><span class="special">[](</span><span class="identifier">Do</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">do_</span><span class="special">)</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">expression</span><span class="special">::</span><span class="identifier">while_</span><span class="special">&lt;</span><span class="identifier">Cond</span><span class="special">,</span> <span class="identifier">Do</span><span class="special">&gt;::</span><span class="identifier">make</span><span class="special">(</span><span class="identifier">cond</span><span class="special">,</span> <span class="identifier">do_</span><span class="special">);</span>
<span class="special">}</span>
<span class="identifier">Cond</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">cond</span><span class="special">;</span>
<span class="special">};</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Cond</span><span class="special">&gt;</span>
<span class="identifier">while_gen</span><span class="special">&lt;</span><span class="identifier">Cond</span><span class="special">&gt;</span> <span class="keyword">const</span>
<span class="identifier">while_</span><span class="special">(</span><span class="identifier">Cond</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">cond</span><span class="special">)</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">while_gen</span><span class="special">&lt;</span><span class="identifier">Cond</span><span class="special">&gt;(</span><span class="identifier">cond</span><span class="special">);</span>
<span class="special">}</span>
<span class="special">}}</span>
</pre>
<p>
<code class="computeroutput"><span class="identifier">while_eval</span></code> is an example
of how to evaluate an expression. It gets called in the <code class="computeroutput"><span class="identifier">rule</span><span class="special">::</span><span class="keyword">while</span></code> action.
<code class="computeroutput"><span class="identifier">while_gen</span></code> and <code class="computeroutput"><span class="identifier">while_</span></code> are the expression template front
ends. Let's break this apart to undestand what's happening. Let's start at
the bottom. It's easier that way.
</p>
<p>
When you write:
</p>
<pre class="programlisting"><span class="identifier">while_</span><span class="special">(</span><span class="identifier">cond</span><span class="special">)</span>
</pre>
<p>
we generate an instance of <code class="computeroutput"><span class="identifier">while_gen</span><span class="special">&lt;</span><span class="identifier">Cond</span><span class="special">&gt;</span></code>, where <code class="computeroutput"><span class="identifier">Cond</span></code>
is the type of <code class="computeroutput"><span class="identifier">cond</span></code>. <code class="computeroutput"><span class="identifier">cond</span></code> can be an arbitrarily complex actor
expression. The <code class="computeroutput"><span class="identifier">while_gen</span></code>
template class has an <code class="computeroutput"><span class="keyword">operator</span><span class="special">[]</span></code> accepting another expression. If we write:
</p>
<pre class="programlisting"><span class="identifier">while_</span><span class="special">(</span><span class="identifier">cond</span><span class="special">)</span>
<span class="special">[</span>
<span class="identifier">do_</span>
<span class="special">]</span>
</pre>
<p>
it will generate a proper composite with the type:
</p>
<pre class="programlisting"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">while_</span><span class="special">&lt;</span><span class="identifier">Cond</span><span class="special">,</span> <span class="identifier">Do</span><span class="special">&gt;::</span><span class="identifier">type</span>
</pre>
<p>
where <code class="computeroutput"><span class="identifier">Cond</span></code> is the type of
<code class="computeroutput"><span class="identifier">cond</span></code> and <code class="computeroutput"><span class="identifier">Do</span></code>
is the type of <code class="computeroutput"><span class="identifier">do_</span></code>. Notice
how we are using Phoenix's <a class="link" href="../inside/expression.html" title="Phoenix Expressions">Expression</a>
mechanism here
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Do</span><span class="special">&gt;</span>
<span class="keyword">typename</span> <span class="identifier">expression</span><span class="special">::</span><span class="identifier">while_</span><span class="special">&lt;</span><span class="identifier">Cond</span><span class="special">,</span> <span class="identifier">Do</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span>
<span class="keyword">operator</span><span class="special">[](</span><span class="identifier">Do</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">do_</span><span class="special">)</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">expression</span><span class="special">::</span><span class="identifier">while_</span><span class="special">&lt;</span><span class="identifier">Cond</span><span class="special">,</span> <span class="identifier">Do</span><span class="special">&gt;::</span><span class="identifier">make</span><span class="special">(</span><span class="identifier">cond</span><span class="special">,</span> <span class="identifier">do_</span><span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
Finally, the <code class="computeroutput"><span class="identifier">while_eval</span></code> does
its thing:
</p>
<pre class="programlisting"><span class="keyword">while</span><span class="special">(</span><span class="identifier">eval</span><span class="special">(</span><span class="identifier">cond</span><span class="special">,</span> <span class="identifier">ctx</span><span class="special">))</span>
<span class="special">{</span>
<span class="identifier">eval</span><span class="special">(</span><span class="identifier">do_</span><span class="special">,</span> <span class="identifier">ctx</span><span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
<code class="computeroutput"><span class="identifier">cond</span></code> and <code class="computeroutput"><span class="identifier">do_</span></code>,
at this point, are instances of <a class="link" href="../inside/actor.html" title="Actors in Detail">Actor</a>.
<code class="computeroutput"><span class="identifier">cond</span></code> and <code class="computeroutput"><span class="identifier">do_</span></code>
are the <a class="link" href="../inside/actor.html" title="Actors in Detail">Actors</a> passed as parameters
by <code class="computeroutput"><span class="identifier">call</span></code>, ctx is the <a class="link" href="../inside/actor.html" title="Actors in Detail">Context</a>
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="extending_actors.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="transforming_the_expression_tree.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,321 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Extending Actors</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../examples.html" title="Advanced Examples">
<link rel="prev" href="../examples.html" title="Advanced Examples">
<link rel="next" href="adding_an_expression.html" title="Adding an expression">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../examples.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="adding_an_expression.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.examples.extending_actors"></a><a class="link" href="extending_actors.html" title="Extending Actors">Extending Actors</a>
</h3></div></div></div>
<p>
<a class="link" href="../inside/actor.html" title="Actors in Detail">Actors</a> are one of the main parts
of the library, and one of the many customization points. The default actor
implementation provides several operator() overloads which deal with the
evaluation of expressions.
</p>
<p>
For some use cases this might not be enough. For convenience it is thinkable
to provide custom member functions which generate new expressions. An example
is the <a class="link" href="../modules/statement/___if_else_____statement.html" title="if_else_ Statement">if_else_
Statement</a>
which provides an additional else member for generating a lazy if-else expression.
With this the actual Phoenix expression becomes more expressive.
</p>
<p>
Another scenario is to give actors the semantics of a certain well known
interface or concept. This tutorial like section will provide information
on how to implement a custom actor which is usable as if it were a <a href="http://www.sgi.com/tech/stl/Container.html" target="_top">STL Container</a>.
</p>
<h5>
<a name="phoenix.examples.extending_actors.h0"></a>
<span><a name="phoenix.examples.extending_actors.requirements"></a></span><a class="link" href="extending_actors.html#phoenix.examples.extending_actors.requirements">Requirements</a>
</h5>
<p>
Let's repeat what we want to have:
</p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Expression
</p>
</th>
<th>
<p>
Semantics
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
Returns an iterator pointing to the first element in the container.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
Returns an iterator pointing one past the last element in the container.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
Returns the size of the container, that is, its number of elements.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">max_size</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
Returns the largest size that this container can ever have.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">empty</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
Equivalent to a.size() == 0. (But possibly faster.)
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">swap</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
Equivalent to swap(a,b)
</p>
</td>
</tr>
</tbody>
</table></div>
<p>
Additionally, we want all the operator() overloads of the regular actor.
</p>
<h5>
<a name="phoenix.examples.extending_actors.h1"></a>
<span><a name="phoenix.examples.extending_actors.defining_the_actor"></a></span><a class="link" href="extending_actors.html#phoenix.examples.extending_actors.defining_the_actor">Defining the
actor</a>
</h5>
<p>
The first version of our <code class="computeroutput"><span class="identifier">container_actor</span></code>
interface will show the general principle. This will be continually extended.
For the sake of simplicity, every member function generator will return
<a class="link" href="../modules/core/nothing.html" title="Nothing"><code class="computeroutput"><span class="identifier">nothing</span></code></a>
at first.
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Expr</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">container_actor</span>
<span class="special">:</span> <span class="identifier">actor</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">&gt;</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="identifier">actor</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">&gt;</span> <span class="identifier">base_type</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">container_actor</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">&gt;</span> <span class="identifier">that_type</span><span class="special">;</span>
<span class="identifier">container_actor</span><span class="special">(</span> <span class="identifier">base_type</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">base</span> <span class="special">)</span>
<span class="special">:</span> <span class="identifier">base_type</span><span class="special">(</span> <span class="identifier">base</span> <span class="special">)</span> <span class="special">{}</span>
<span class="identifier">expression</span><span class="special">::</span><span class="identifier">null</span><span class="special">&lt;</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">void_</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span> <span class="identifier">begin</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">nothing</span><span class="special">;</span> <span class="special">}</span>
<span class="identifier">expression</span><span class="special">::</span><span class="identifier">null</span><span class="special">&lt;</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">void_</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span> <span class="identifier">end</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">nothing</span><span class="special">;</span> <span class="special">}</span>
<span class="identifier">expression</span><span class="special">::</span><span class="identifier">null</span><span class="special">&lt;</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">void_</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span> <span class="identifier">size</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">nothing</span><span class="special">;</span> <span class="special">}</span>
<span class="identifier">expression</span><span class="special">::</span><span class="identifier">null</span><span class="special">&lt;</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">void_</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span> <span class="identifier">max_size</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">nothing</span><span class="special">;</span> <span class="special">}</span>
<span class="identifier">expression</span><span class="special">::</span><span class="identifier">null</span><span class="special">&lt;</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">void_</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span> <span class="identifier">empty</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">nothing</span><span class="special">;</span> <span class="special">}</span>
<span class="comment">// Note that swap is the only function needing another container.</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Container</span><span class="special">&gt;</span>
<span class="identifier">expression</span><span class="special">::</span><span class="identifier">null</span><span class="special">&lt;</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">void_</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span> <span class="identifier">swap</span><span class="special">(</span> <span class="identifier">actor</span><span class="special">&lt;</span><span class="identifier">Container</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">nothing</span><span class="special">;</span> <span class="special">}</span>
<span class="special">};</span>
</pre>
<h5>
<a name="phoenix.examples.extending_actors.h2"></a>
<span><a name="phoenix.examples.extending_actors.using_the_actor"></a></span><a class="link" href="extending_actors.html#phoenix.examples.extending_actors.using_the_actor">Using
the actor</a>
</h5>
<p>
Although the member functions do nothing right now, we want to test if we
can use our new actor.
</p>
<p>
First, lets create a generator which wraps the <code class="computeroutput"><span class="identifier">container_actor</span></code>
around any other expression:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Expr</span><span class="special">&gt;</span>
<span class="identifier">container_actor</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">&gt;</span> <span class="keyword">const</span>
<span class="identifier">container</span><span class="special">(</span> <span class="identifier">actor</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">expr</span> <span class="special">)</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">expr</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
Now let's test this:
</p>
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">v</span><span class="special">;</span>
<span class="identifier">v</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="number">0</span><span class="special">);</span>
<span class="identifier">v</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">v</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
<span class="identifier">v</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="number">3</span><span class="special">);</span>
<span class="special">(</span><span class="identifier">container</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">).</span><span class="identifier">size</span><span class="special">())(</span><span class="identifier">v</span><span class="special">);</span>
</pre>
<p>
Granted, this is not really elegant and not very practical (we could have
just used phoenix::begin(v) from the <a class="link" href="../modules/stl/algorithm.html" title="Algorithm">Phoenix
algorithm module</a>, but we can do better.
</p>
<p>
Let's have an <a class="link" href="../modules/core/arguments.html" title="Arguments">argument placeholder</a>
which is usable as if it was a STL container:
</p>
<pre class="programlisting"><span class="identifier">container_actor</span><span class="special">&lt;</span><span class="identifier">expression</span><span class="special">::</span><span class="identifier">argument</span><span class="special">&lt;</span><span class="number">1</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">&gt;</span> <span class="keyword">const</span> <span class="identifier">con1</span><span class="special">;</span>
<span class="comment">// and so on ...</span>
</pre>
<p>
The above example can be rewritten as:
</p>
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">v</span><span class="special">;</span>
<span class="identifier">v</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="number">0</span><span class="special">);</span>
<span class="identifier">v</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">v</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
<span class="identifier">v</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="number">3</span><span class="special">);</span>
<span class="special">(</span><span class="identifier">con1</span><span class="special">.</span><span class="identifier">size</span><span class="special">())(</span><span class="identifier">v</span><span class="special">);</span>
</pre>
<p>
Wow, that was easy!
</p>
<h5>
<a name="phoenix.examples.extending_actors.h3"></a>
<span><a name="phoenix.examples.extending_actors.adding_life_to_the_actor"></a></span><a class="link" href="extending_actors.html#phoenix.examples.extending_actors.adding_life_to_the_actor">Adding
life to the actor</a>
</h5>
<p>
This one will be even easier!
</p>
<p>
First, we define a <a class="link" href="../modules/function.html" title="Function">lazy function</a>
which evaluates the expression we want to implement. Following is the implementation
of the size function:
</p>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">size_impl</span>
<span class="special">{</span>
<span class="comment">// result_of protocol:</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Sig</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">result</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">This</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Container</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">This</span><span class="special">(</span><span class="identifier">Container</span><span class="special">)&gt;</span>
<span class="special">{</span>
<span class="comment">// Note, remove reference here, because Container can be anything</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_reference</span><span class="special">&lt;</span><span class="identifier">Container</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">container_type</span><span class="special">;</span>
<span class="comment">// The result will be size_type</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">container_type</span><span class="special">::</span><span class="identifier">size_type</span> <span class="identifier">type</span><span class="special">;</span>
<span class="special">};</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Container</span><span class="special">&gt;</span>
<span class="keyword">typename</span> <span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">size_impl</span><span class="special">(</span><span class="identifier">Container</span> <span class="keyword">const</span><span class="special">&amp;)&gt;::</span><span class="identifier">type</span>
<span class="keyword">operator</span><span class="special">()(</span><span class="identifier">Container</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">container</span><span class="special">)</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">container</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span>
<span class="special">}</span>
<span class="special">};</span>
</pre>
<p>
Good, this was the first part. The second part will be to implement the size
member function of <code class="computeroutput"><span class="identifier">container_actor</span></code>:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Expr</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">container_actor</span>
<span class="special">:</span> <span class="identifier">actor</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">&gt;</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="identifier">actor</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">&gt;</span> <span class="identifier">base_type</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">container_actor</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">&gt;</span> <span class="identifier">that_type</span><span class="special">;</span>
<span class="identifier">container_actor</span><span class="special">(</span> <span class="identifier">base_type</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">base</span> <span class="special">)</span>
<span class="special">:</span> <span class="identifier">base_type</span><span class="special">(</span> <span class="identifier">base</span> <span class="special">)</span> <span class="special">{}</span>
<span class="keyword">typename</span> <span class="identifier">expression</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="identifier">size_impl</span><span class="special">,</span> <span class="identifier">that_type</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span>
<span class="identifier">size</span><span class="special">()</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="identifier">function</span><span class="special">&lt;</span><span class="identifier">size_impl</span><span class="special">&gt;</span> <span class="keyword">const</span> <span class="identifier">f</span> <span class="special">=</span> <span class="identifier">size_impl</span><span class="special">();</span>
<span class="keyword">return</span> <span class="identifier">f</span><span class="special">(*</span><span class="keyword">this</span><span class="special">);</span>
<span class="special">}</span>
<span class="comment">// the rest ...</span>
<span class="special">};</span>
</pre>
<p>
It is left as an exercise to the user to implement the missing parts by reusing
functions from the <a class="link" href="../modules/stl/algorithm.html" title="Algorithm">Phoenix
Algorithm Module</a> (the impatient take a look here: <a href="../../../../example/container_actor.cpp" target="_top">container_actor.cpp</a>).
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../examples.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="adding_an_expression.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,217 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Transforming the Expression Tree</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../examples.html" title="Advanced Examples">
<link rel="prev" href="adding_an_expression.html" title="Adding an expression">
<link rel="next" href="../lazy_list.html" title="Lazy List">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="adding_an_expression.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../lazy_list.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.examples.transforming_the_expression_tree"></a><a class="link" href="transforming_the_expression_tree.html" title="Transforming the Expression Tree">Transforming
the Expression Tree</a>
</h3></div></div></div>
<p>
This example will show how to write <a class="link" href="../inside/actions.html" title="More on Actions">Actions</a>
that transform the Phoenix AST.
</p>
<div class="blockquote"><blockquote class="blockquote">
<p>
"<span class="emphasis"><em>Lisp macros transform the program structure itself, with
the full language available to express such transformations.</em></span>"
</p>
<p>
<a href="http://en.wikipedia.org/wiki/Lisp_macro#Lisp_macros" target="_top">Wikipedia</a>
</p>
</blockquote></div>
<p>
What we want to do is to invert some arithmetic operators, i.e. plus will
be transformed to minus, minus to plus, multiplication to division and division
to multiplication.
</p>
<p>
Let's start with defining our default action:
</p>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">invert_actions</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Rule</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">when</span>
<span class="special">:</span> <a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/nary_expr.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">nary_expr</span></code></a>
<a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/_.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">_</span></code></a>
<span class="special">,</span> <a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/vararg.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">vararg</span></code></a>
<a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/when.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">when</span></code></a><span class="special">&lt;</span><a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/_.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">_</span></code></a><span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">evaluator</span><span class="special">(</span><a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/_.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">_</span></code></a><span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">_context</span><span class="special">)</span>
<span class="special">&gt;</span>
<span class="special">&gt;</span>
<span class="special">{};</span>
<span class="special">};</span>
</pre>
<p>
Wow, this looks complicated! Granted you need to know a little bit about
<a href="http://www.boost.org/doc/libs/release/libs/proto/index.html" target="_top">Boost.Proto</a>
(For a good introduction read through the <a href="http://cpp-next.com/archive/2010/08/expressive-c-introduction/" target="_top">Expressive
C++</a> series).
</p>
<p>
By default, we don't want to do anything, well, not exactly nothing, but
just continue transformation into its arguments.
</p>
<p>
So, it is done by the following:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
For each arguments are passed to evaluator (with the current context,
that contains our invert_actions)
</li>
<li class="listitem">
Create new expression using current expression tag, what is done by
<a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/_.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">_</span></code></a>, with the result of evaluated
arguments
</li>
</ul></div>
<p>
So, after the basics are set up, we can start by writing the transformations
we want to have on our tree:
</p>
<pre class="programlisting"><span class="comment">// Transform plus to minus</span>
<span class="keyword">template</span> <span class="special">&lt;&gt;</span>
<span class="keyword">struct</span> <span class="identifier">invert_actions</span><span class="special">::</span><span class="identifier">when</span><span class="special">&lt;</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">rule</span><span class="special">::</span><span class="identifier">plus</span><span class="special">&gt;</span>
<span class="special">:</span> <a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/call.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">call</span></code></a><span class="special">&lt;</span>
<a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/functional/make_expr.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">make_expr</span></code></a><span class="special">&lt;</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">minus</span><span class="special">&gt;(</span>
<span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">evaluator</span><span class="special">(</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">_left</span><span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">_context</span><span class="special">)</span>
<span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">evaluator</span><span class="special">(</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">_right</span><span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">_context</span><span class="special">)</span>
<span class="special">)</span>
<span class="special">&gt;</span>
<span class="special">{};</span>
</pre>
<p>
What is done is the following:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
The left expression is passed to evaluator (with the current context,
that contains our invert_actions)
</li>
<li class="listitem">
The right expression is passed to evaluator (with the current context,
that contains our invert_actions)
</li>
<li class="listitem">
The result of these two <a href="http://www.boost.org/doc/libs/release/doc/html/Transform.html" target="_top">Proto
Transforms</a> are passed to <a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/functional/make_expr.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">make_expr</span></code></a> which returns the
freshly created expression
</li>
</ul></div>
<p>
After you know what is going on, maybe the rest doesn't look so scary anymore:
</p>
<pre class="programlisting"><span class="comment">// Transform minus to plus</span>
<span class="keyword">template</span> <span class="special">&lt;&gt;</span>
<span class="keyword">struct</span> <span class="identifier">invert_actions</span><span class="special">::</span><span class="identifier">when</span><span class="special">&lt;</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">rule</span><span class="special">::</span><span class="identifier">minus</span><span class="special">&gt;</span>
<span class="special">:</span> <a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/call.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">call</span></code></a><span class="special">&lt;</span>
<a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/functional/make_expr.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">make_expr</span></code></a><span class="special">&lt;</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">plus</span><span class="special">&gt;(</span>
<span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">evaluator</span><span class="special">(</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">_left</span><span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">_context</span><span class="special">)</span>
<span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">evaluator</span><span class="special">(</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">_right</span><span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">_context</span><span class="special">)</span>
<span class="special">)</span>
<span class="special">&gt;</span>
<span class="special">{};</span>
<span class="comment">// Transform multiplies to divides</span>
<span class="keyword">template</span> <span class="special">&lt;&gt;</span>
<span class="keyword">struct</span> <span class="identifier">invert_actions</span><span class="special">::</span><span class="identifier">when</span><span class="special">&lt;</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">rule</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&gt;</span>
<span class="special">:</span> <a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/call.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">call</span></code></a><span class="special">&lt;</span>
<a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/functional/make_expr.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">make_expr</span></code></a><span class="special">&lt;</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">divides</span><span class="special">&gt;(</span>
<span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">evaluator</span><span class="special">(</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">_left</span><span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">_context</span><span class="special">)</span>
<span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">evaluator</span><span class="special">(</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">_right</span><span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">_context</span><span class="special">)</span>
<span class="special">)</span>
<span class="special">&gt;</span>
<span class="special">{};</span>
<span class="comment">// Transform divides to multiplies</span>
<span class="keyword">template</span> <span class="special">&lt;&gt;</span>
<span class="keyword">struct</span> <span class="identifier">invert_actions</span><span class="special">::</span><span class="identifier">when</span><span class="special">&lt;</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">rule</span><span class="special">::</span><span class="identifier">divides</span><span class="special">&gt;</span>
<span class="special">:</span> <a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/call.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">call</span></code></a><span class="special">&lt;</span>
<a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/functional/make_expr.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">make_expr</span></code></a><span class="special">&lt;</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&gt;(</span>
<span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">evaluator</span><span class="special">(</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">_left</span><span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">_context</span><span class="special">)</span>
<span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">evaluator</span><span class="special">(</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">_right</span><span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">_context</span><span class="special">)</span>
<span class="special">)</span>
<span class="special">&gt;</span>
<span class="special">{};</span>
</pre>
<p>
That's it! Now that we have our actions defined, we want to evaluate some
of our expressions with them:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Expr</span><span class="special">&gt;</span>
<span class="comment">// Calculate the result type: our transformed AST</span>
<span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">result_of</span><span class="special">&lt;</span>
<span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">evaluator</span><span class="special">(</span>
<span class="identifier">Expr</span> <span class="keyword">const</span><span class="special">&amp;</span>
<span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">context</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">invert_actions</span><span class="special">&gt;::</span><span class="identifier">type</span>
<span class="special">)</span>
<span class="special">&gt;::</span><span class="identifier">type</span>
<span class="identifier">invert</span><span class="special">(</span><span class="identifier">Expr</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">expr</span><span class="special">)</span>
<span class="special">{</span>
<span class="keyword">return</span>
<span class="comment">// Evaluate it with our actions</span>
<span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">eval</span><span class="special">(</span>
<span class="identifier">expr</span>
<span class="special">,</span> <span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">context</span><span class="special">(</span>
<span class="keyword">int</span><span class="special">()</span>
<span class="special">,</span> <span class="identifier">invert_actions</span><span class="special">()</span>
<span class="special">)</span>
<span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
Run some tests to see if it is working:
</p>
<pre class="programlisting"><span class="identifier">invert</span><span class="special">(</span><span class="identifier">_1</span><span class="special">);</span> <span class="comment">// --&gt; _1</span>
<span class="identifier">invert</span><span class="special">(</span><span class="identifier">_1</span> <span class="special">+</span> <span class="identifier">_2</span><span class="special">);</span> <span class="comment">// --&gt; _1 - _2</span>
<span class="identifier">invert</span><span class="special">(</span><span class="identifier">_1</span> <span class="special">+</span> <span class="identifier">_2</span> <span class="special">-</span> <span class="identifier">_3</span><span class="special">);</span> <span class="comment">// --&gt; _1 - _2 + _3</span>
<span class="identifier">invert</span><span class="special">(</span><span class="identifier">_1</span> <span class="special">*</span> <span class="identifier">_2</span><span class="special">);</span> <span class="comment">// --&gt; _1 / _2</span>
<span class="identifier">invert</span><span class="special">(</span><span class="identifier">_1</span> <span class="special">*</span> <span class="identifier">_2</span> <span class="special">/</span> <span class="identifier">_3</span><span class="special">);</span> <span class="comment">// --&gt; _1 / _2 * _3</span>
<span class="identifier">invert</span><span class="special">(</span><span class="identifier">_1</span> <span class="special">*</span> <span class="identifier">_2</span> <span class="special">+</span> <span class="identifier">_3</span><span class="special">);</span> <span class="comment">// --&gt; _1 / _2 - _3</span>
<span class="identifier">invert</span><span class="special">(</span><span class="identifier">_1</span> <span class="special">*</span> <span class="identifier">_2</span> <span class="special">-</span> <span class="identifier">_3</span><span class="special">);</span> <span class="comment">// --&gt; _1 / _2 + _2</span>
<span class="identifier">invert</span><span class="special">(</span><span class="identifier">if_</span><span class="special">(</span><span class="identifier">_1</span> <span class="special">*</span> <span class="identifier">_4</span><span class="special">)[</span><span class="identifier">_2</span> <span class="special">-</span> <span class="identifier">_3</span><span class="special">]);</span> <span class="comment">// --&gt; if_(_1 / _4)[_2 + _3]</span>
<span class="identifier">_1</span> <span class="special">*</span> <span class="identifier">invert</span><span class="special">(</span><span class="identifier">_2</span> <span class="special">-</span> <span class="identifier">_3</span><span class="special">));</span> <span class="comment">// --&gt; _1 * _2 + _3</span>
</pre>
<p>
<span class="inlinemediaobject"><img src="../../images/note.png"></span>
The complete example can be found here: <a href="../../../../example/invert.cpp" target="_top">example/invert.cpp</a>
</p>
<p>
<span class="emphasis"><em>Pretty simple ...</em></span>
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="adding_an_expression.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../lazy_list.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,60 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Inside Phoenix</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="prev" href="modules/stl/algorithm.html" title="Algorithm">
<link rel="next" href="inside/actor.html" title="Actors in Detail">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="modules/stl/algorithm.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="inside/actor.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="phoenix.inside"></a><a class="link" href="inside.html" title="Inside Phoenix">Inside Phoenix</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="inside/actor.html">Actors in Detail</a></span></dt>
<dt><span class="section"><a href="inside/expression.html">Phoenix Expressions</a></span></dt>
<dd><dl><dt><span class="section"><a href="inside/expression/boilerplate_macros.html">Boilerplate
Macros</a></span></dt></dl></dd>
<dt><span class="section"><a href="inside/actions.html">More on Actions</a></span></dt>
<dt><span class="section"><a href="inside/rules.html">Predefined Expressions and Rules</a></span></dt>
<dt><span class="section"><a href="inside/custom_terminals.html">Custom Terminals</a></span></dt>
<dt><span class="section"><a href="inside/placeholder_unification.html">Placeholder Unification</a></span></dt>
</dl></div>
<p>
This chapter explains in more detail how the library operates. The information
henceforth should not be necessary to those who are interested in just using
the library. However, a microscopic view might prove to be beneficial to advanced
programmers who wish to extend the library.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="modules/stl/algorithm.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="inside/actor.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,210 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>More on Actions</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../inside.html" title="Inside Phoenix">
<link rel="prev" href="expression/boilerplate_macros.html" title="Boilerplate Macros">
<link rel="next" href="rules.html" title="Predefined Expressions and Rules">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="expression/boilerplate_macros.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../inside.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="rules.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.inside.actions"></a><a class="link" href="actions.html" title="More on Actions">More on Actions</a>
</h3></div></div></div>
<p>
As you know from the <a class="link" href="actor.html" title="Actors in Detail">Actors in Detail</a>
section, Actions are what brings life to a Phoenix expression tree.
</p>
<p>
When dealing with a Phoenix expression tree, it gets evaluated top-down.
Example:
</p>
<pre class="programlisting"><span class="identifier">_1</span> <span class="special">+</span> <span class="number">3</span> <span class="special">*</span> <span class="identifier">_2</span>
</pre>
<p>
Can be visualized as an AST in the following way:
</p>
<p>
<span class="inlinemediaobject"><img src="../../images/simple_ast.png"></span>
</p>
<p>
In terms of actions this means:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
<code class="computeroutput"><span class="identifier">rule</span><span class="special">::</span><span class="identifier">plus</span></code> is matched
</li>
<li class="listitem">
evaluate left:
<div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem">
<code class="computeroutput"><span class="identifier">rule</span><span class="special">::</span><span class="identifier">placeholder</span></code> is matched
</li></ul></div>
</li>
<li class="listitem">
evaluate right:
<div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem">
<code class="computeroutput"><span class="identifier">rule</span><span class="special">::</span><span class="identifier">multiplies</span></code> is matched
<div class="itemizedlist"><ul class="itemizedlist" type="square">
<li class="listitem">
evaluate left:
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<code class="computeroutput"><span class="identifier">rule</span><span class="special">::</span><span class="identifier">value</span></code>
is matched
</li></ul></div>
</li>
<li class="listitem">
evaluate right:
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<code class="computeroutput"><span class="identifier">rule</span><span class="special">::</span><span class="identifier">placeholder</span></code>
is matched
</li></ul></div>
</li>
</ul></div>
</li></ul></div>
</li>
</ul></div>
<p>
Every time a rule is matched, an action will be called. The action determines
how the Phoenix AST will be traversed.
</p>
<h5>
<a name="phoenix.inside.actions.h0"></a>
<span><a name="phoenix.inside.actions.writing_an_action"></a></span><a class="link" href="actions.html#phoenix.inside.actions.writing_an_action">Writing
an Action</a>
</h5>
<p>
As mentioned in <a class="link" href="actor.html" title="Actors in Detail">Actors in Detail</a>
actions are <a href="http://www.boost.org/doc/libs/release/doc/html/PrimitiveTransform.html" target="_top">Proto
Primitive Transforms</a> for convenience Phoenix provides an abstraction
to this:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Fun</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">call</span><span class="special">;</span>
</pre>
<p>
This is similar to <a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/call.html" target="_top"><code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">call</span></code></a> but does more. It calls the
<code class="computeroutput"><span class="identifier">Fun</span></code> function object passed
as template parameter with the <code class="computeroutput"><span class="identifier">Context</span></code>
and the children of the expression associated with the rule.
</p>
<p>
Lets have an (simplified) example on how to write an evaluation action for
<code class="computeroutput"><span class="identifier">rule</span><span class="special">::</span><span class="identifier">plus</span></code>:
</p>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">plus_eval</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="keyword">int</span> <span class="identifier">result_type</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Lhs</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Rhs</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Context</span><span class="special">&gt;</span>
<span class="identifier">result_type</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">Lhs</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">lhs</span><span class="special">,</span> <span class="identifier">Rhs</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="identifier">rhs</span><span class="special">,</span> <span class="identifier">Context</span> <span class="special">&amp;</span> <span class="identifier">ctx</span><span class="special">)</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">eval</span><span class="special">(</span><span class="identifier">lhs</span><span class="special">,</span> <span class="identifier">ctx</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">eval</span><span class="special">(</span><span class="identifier">rhs</span><span class="special">,</span> <span class="identifier">ctx</span><span class="special">);</span>
<span class="special">}</span>
<span class="special">};</span>
<span class="keyword">template</span> <span class="special">&lt;&gt;</span>
<span class="keyword">struct</span> <span class="identifier">default_actions</span><span class="special">::</span><span class="identifier">when</span><span class="special">&lt;</span><span class="identifier">rule</span><span class="special">::</span><span class="identifier">plus</span><span class="special">&gt;</span>
<span class="special">:</span> <span class="identifier">call</span><span class="special">&lt;</span><span class="identifier">plus_eval</span><span class="special">&gt;</span>
<span class="special">{};</span>
</pre>
<p>
That's it. When evaluating a <code class="computeroutput"><span class="identifier">plus</span></code>
expression, the <code class="computeroutput"><span class="identifier">plus_eval</span></code>
callable gets called with the left hand side and right hand side expression
and the associated Context.
</p>
<p>
<span class="bold"><strong>But there is more:</strong></span> As Actions <span class="emphasis"><em>can</em></span>
be full fletched <a href="http://www.boost.org/doc/libs/release/doc/html/Transform.html" target="_top">Proto
Transforms</a>, you can in fact use any proto expression you can imagine
as the action. Phoenix predifines a set of callables and transform to deal
with the Context information passed along and of course every Phoenix expression
can be used as a Phoenix grammar or <a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/pass_through.html" target="_top">Proto
Pass Through Transform</a>.
</p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term"><code class="computeroutput"><span class="identifier">functional</span><span class="special">::</span><span class="identifier">context</span><span class="special">(</span><span class="identifier">Env</span><span class="special">,</span> <span class="identifier">Actions</span><span class="special">)</span></code></span></dt>
<dd><p>
A <a href="http://www.boost.org/doc/libs/release/doc/html/Callable.html" target="_top">Proto
Callable Transform</a> that creates a new context out of the <code class="computeroutput"><span class="identifier">Env</span></code> and <code class="computeroutput"><span class="identifier">Actions</span></code>
parameter
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">functional</span><span class="special">::</span><span class="identifier">env</span><span class="special">(</span><span class="identifier">Context</span><span class="special">)</span></code></span></dt>
<dd><p>
A <a href="http://www.boost.org/doc/libs/release/doc/html/Callable.html" target="_top">Proto
Callable Transform</a> that returns the environment out of the
<code class="computeroutput"><span class="identifier">Context</span></code> parameter
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">functional</span><span class="special">::</span><span class="identifier">actions</span><span class="special">(</span><span class="identifier">Context</span><span class="special">)</span></code></span></dt>
<dd><p>
A <a href="http://www.boost.org/doc/libs/release/doc/html/Callable.html" target="_top">Proto
Callable Transform</a> that returns the actions out of the <code class="computeroutput"><span class="identifier">Context</span></code> parameter
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">_context</span></code></span></dt>
<dd><p>
A <a href="http://www.boost.org/doc/libs/release/doc/html/PrimitiveTransform.html" target="_top">Proto
Primitive Transform</a> that returns the current context
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">_env</span></code></span></dt>
<dd><p>
A <a href="http://www.boost.org/doc/libs/release/doc/html/PrimitiveTransform.html" target="_top">Proto
Primitive Transform</a> that returns the current environment
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">_actions</span></code></span></dt>
<dd><p>
A <a href="http://www.boost.org/doc/libs/release/doc/html/PrimitiveTransform.html" target="_top">Proto
Primitive Transform</a> that returns the current actions
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">context</span><span class="special">(</span><span class="identifier">env</span><span class="special">,</span> <span class="identifier">actions</span><span class="special">)</span></code></span></dt>
<dd><p>
A regular function that creates a context
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">env</span><span class="special">(</span><span class="identifier">ctx</span><span class="special">)</span></code></span></dt>
<dd><p>
A regular function that returns the environment from the given context
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">actions</span><span class="special">(</span><span class="identifier">ctx</span><span class="special">)</span></code></span></dt>
<dd><p>
A regular function that returns the actions from the given context
</p></dd>
</dl>
</div>
<p>
Phoenix is equipped with a predefined set of expressions, rules and actions
to make all the stuff work you learned in the <a class="link" href="../starter_kit.html" title="Starter Kit">Starter
Kit</a> and <a class="link" href="../modules.html" title="Modules">Modules</a> sections. See
the <a class="link" href="rules.html" title="Predefined Expressions and Rules">next section</a> for more details!
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="expression/boilerplate_macros.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../inside.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="rules.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,412 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Actors in Detail</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../inside.html" title="Inside Phoenix">
<link rel="prev" href="../inside.html" title="Inside Phoenix">
<link rel="next" href="expression.html" title="Phoenix Expressions">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../inside.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../inside.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="expression.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.inside.actor"></a><a class="link" href="actor.html" title="Actors in Detail">Actors in Detail</a>
</h3></div></div></div>
<h5>
<a name="phoenix.inside.actor.h0"></a>
<span><a name="phoenix.inside.actor.actor"></a></span><a class="link" href="actor.html#phoenix.inside.actor.actor">Actor</a>
</h5>
<p>
The main concept is the <code class="computeroutput"><span class="identifier">Actor</span></code>.
An <code class="computeroutput"><span class="identifier">Actor</span></code> is a model of the
<a href="http://www.boost.org/doc/libs/release/libs/fusion/doc/html/fusion/functional/concepts/poly.html" target="_top">Polymorphic
Function Object</a> concept (that can accept 0 to N arguments (where
N is a predefined maximum).
</p>
<p>
An <code class="computeroutput"><span class="identifier">Actor</span></code> contains a valid
Phoenix Expression, a call to one of the function call operator overloads,
starts the evaluation process.
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
You can set <code class="computeroutput"><span class="identifier">BOOST_PHOENIX_LIMIT</span></code>,
the predefined maximum arity an actor can take. By default, <code class="computeroutput"><span class="identifier">BOOST_PHOENIX_LIMIT</span></code> is set to 10.
</p></td></tr>
</table></div>
<p>
The <code class="computeroutput"><span class="identifier">actor</span></code> template class
models the <code class="computeroutput"><span class="identifier">Actor</span></code> concept:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Expr</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">actor</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Sig</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">result</span><span class="special">;</span>
<span class="keyword">typename</span> <span class="identifier">result_of</span><span class="special">::</span><span class="identifier">actor</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">&gt;::</span><span class="identifier">type</span>
<span class="keyword">operator</span><span class="special">()()</span> <span class="keyword">const</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T0</span><span class="special">&gt;</span>
<span class="keyword">typename</span> <span class="identifier">result_of</span><span class="special">::</span><span class="identifier">actor</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">,</span> <span class="identifier">T0</span> <span class="special">&amp;&gt;::</span><span class="identifier">type</span>
<span class="keyword">operator</span><span class="special">()(</span><span class="identifier">T0</span><span class="special">&amp;</span> <span class="identifier">_0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T0</span><span class="special">&gt;</span>
<span class="keyword">typename</span> <span class="identifier">result_of</span><span class="special">::</span><span class="identifier">actor</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">,</span> <span class="identifier">T0</span> <span class="keyword">const</span> <span class="special">&amp;&gt;::</span><span class="identifier">type</span>
<span class="keyword">operator</span><span class="special">()(</span><span class="identifier">T0</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">_0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="comment">//...</span>
<span class="special">};</span>
</pre>
<div class="table">
<a name="phoenix.inside.actor.t0"></a><p class="title"><b>Table&#160;1.9.&#160;Actor Concept Requirements</b></p>
<div class="table-contents"><table class="table" summary="Actor Concept Requirements">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Expression
</p>
</th>
<th>
<p>
Semantics
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">actor</span><span class="special">(</span><span class="identifier">arg0</span><span class="special">,</span>
<span class="identifier">arg1</span><span class="special">,</span>
<span class="special">...,</span> <span class="identifier">argN</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
Function call operators to start the evaluation
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">result_of</span><span class="special">&lt;</span><span class="identifier">Actor</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">&gt;(</span><span class="identifier">Arg0</span><span class="special">,</span>
<span class="identifier">Arg1</span><span class="special">,</span>
<span class="special">...,</span> <span class="identifier">ArgN</span><span class="special">)&gt;::</span><span class="identifier">type</span></code>
</p>
</td>
<td>
<p>
Result of the evaluation
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">actor</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">,</span>
<span class="identifier">Arg0</span><span class="special">,</span>
<span class="identifier">Arg1</span><span class="special">,</span>
<span class="special">...,</span> <span class="identifier">ArgN</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
</p>
</td>
<td>
<p>
Result of the evaluation
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><h5>
<a name="phoenix.inside.actor.h1"></a>
<span><a name="phoenix.inside.actor.function_call_operators"></a></span><a class="link" href="actor.html#phoenix.inside.actor.function_call_operators">Function
Call Operators</a>
</h5>
<p>
There are 2*N function call operators for 0 to N arguments (N == <code class="computeroutput"><span class="identifier">BOOST_PHOENIX_LIMIT</span></code>). The actor class accepts
the arguments and forwards the arguments to the default evaluation action.
</p>
<p>
Additionally, there exist function call operators accepting permutations
of const and non-const references. These operators are created for all N
&lt;= <code class="computeroutput"><span class="identifier">BOOST_PHOENIX_PERFECT_FORWARD_LIMIT</span></code>
(which defaults to 3).
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top">
<p>
<span class="bold"><strong>Forwarding Function Problem</strong></span>
</p>
<p>
There is a known issue with current C++ called the "<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm" target="_top">Forwarding
Function Problem</a>". The problem is that given an arbitrary
function <code class="computeroutput"><span class="identifier">F</span></code>, using current
C++ language rules, one cannot create a forwarding function <code class="computeroutput"><span class="identifier">FF</span></code> that transparently assumes the arguments
of <code class="computeroutput"><span class="identifier">F</span></code>.
</p>
</td></tr>
</table></div>
<h5>
<a name="phoenix.inside.actor.h2"></a>
<span><a name="phoenix.inside.actor.context"></a></span><a class="link" href="actor.html#phoenix.inside.actor.context">Context</a>
</h5>
<p>
On an actor function call, before calling the evaluation function, the actor
created a <span class="bold"><strong>context</strong></span>. This context consists
of an <code class="computeroutput"><span class="identifier">Environment</span></code> and an
<code class="computeroutput"><span class="identifier">Action</span></code> part. These contain
all information necessary to evaluate the given expression.
</p>
<div class="table">
<a name="phoenix.inside.actor.t1"></a><p class="title"><b>Table&#160;1.10.&#160;Context Concept Requirements</b></p>
<div class="table-contents"><table class="table" summary="Context Concept Requirements">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Expression
</p>
</th>
<th>
<p>
Semantics
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">context</span><span class="special">&lt;</span><span class="identifier">Env</span><span class="special">,</span>
<span class="identifier">Actions</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
</p>
</td>
<td>
<p>
Type of a Context
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">context</span><span class="special">(</span><span class="identifier">e</span><span class="special">,</span>
<span class="identifier">a</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
A Context containing environment <code class="computeroutput"><span class="identifier">e</span></code>
and actions <code class="computeroutput"><span class="identifier">a</span></code>
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">env</span><span class="special">&lt;</span><span class="identifier">Context</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
</p>
</td>
<td>
<p>
Type of the contained Environment
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">env</span><span class="special">(</span><span class="identifier">ctx</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
The environment
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">actions</span><span class="special">&lt;</span><span class="identifier">Context</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
</p>
</td>
<td>
<p>
Type of the contained Actions
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">actions</span><span class="special">(</span><span class="identifier">ctx</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
The actions
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><h5>
<a name="phoenix.inside.actor.h3"></a>
<span><a name="phoenix.inside.actor.environment"></a></span><a class="link" href="actor.html#phoenix.inside.actor.environment">Environment</a>
</h5>
<p>
The Environment is a model of <a href="http://www.boost.org/doc/libs/release/libs/fusion/doc/html/fusion/sequence/concepts/random_access_sequence.html" target="_top">Random
Access Sequence</a>.
</p>
<p>
The arguments passed to the actor's function call operator are collected
inside the Environment:
</p>
<p>
<span class="inlinemediaobject"><img src="../../images/funnel_in.png"></span>
</p>
<p>
Other parts of the library (e.g. the scope module) extends the <code class="computeroutput"><span class="identifier">Environment</span></code> concept to hold other information
such as local variables, etc.
</p>
<h5>
<a name="phoenix.inside.actor.h4"></a>
<span><a name="phoenix.inside.actor.actions"></a></span><a class="link" href="actor.html#phoenix.inside.actor.actions">Actions</a>
</h5>
<p>
Actions is the part of Phoenix which are responsible for giving the actual
expressions a specific behaviour. During the traversal of the Phoenix Expression
Tree these actions are called whenever a specified rule in the grammar matches.
</p>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">actions</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Rule</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">when</span><span class="special">;</span>
<span class="special">};</span>
</pre>
<p>
The nested <code class="computeroutput"><span class="identifier">when</span></code> template
is required to be <a href="http://www.boost.org/doc/libs/release/doc/html/PrimitiveTransform.html" target="_top">Proto
Primitive Transform</a>. No worries, you don't have to learn <a href="http://www.boost.org/doc/libs/release/libs/proto/index.html" target="_top">Boost.Proto</a>
just yet! Phoenix provides some wrappers to let you define simple actions
without the need to dive deep into proto.
</p>
<p>
Phoenix ships with a predefined <code class="computeroutput"><span class="identifier">default_actions</span></code>
class that evaluates the expressions with C++ semantics:
</p>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">default_actions</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Rule</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Dummy</span> <span class="special">=</span> <span class="keyword">void</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">when</span>
<span class="special">:</span> <span class="identifier">proto</span><span class="special">::</span><span class="identifier">_default</span><span class="special">&lt;</span><span class="identifier">meta_grammar</span><span class="special">&gt;</span>
<span class="special">{};</span>
<span class="special">};</span>
</pre>
<p>
For more information on how to use the default_actions class and how to attach
custom actions to the evaluation process, see <a class="link" href="actions.html" title="More on Actions">more
on actions</a>.
</p>
<h5>
<a name="phoenix.inside.actor.h5"></a>
<span><a name="phoenix.inside.actor.evaluation"></a></span><a class="link" href="actor.html#phoenix.inside.actor.evaluation">Evaluation</a>
</h5>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">evaluator</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Expr</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Context</span><span class="special">&gt;</span>
<span class="emphasis"><em>unspecified</em></span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">Expr</span> <span class="special">&amp;,</span> <span class="identifier">Context</span> <span class="special">&amp;);</span>
<span class="special">};</span>
<span class="identifier">evaluator</span> <span class="keyword">const</span> <span class="identifier">eval</span> <span class="special">=</span> <span class="special">{};</span>
</pre>
<p>
The evaluation of a Phoenix expression is started by a call to the function
call operator of <code class="computeroutput"><span class="identifier">evaluator</span></code>.
</p>
<p>
The evaluator is called by the <code class="computeroutput"><span class="identifier">actor</span></code>
function operator overloads after the context is built up. For reference,
here is a typical <code class="computeroutput"><span class="identifier">actor</span><span class="special">::</span><span class="keyword">operator</span><span class="special">()</span></code>
that accepts two arguments:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">T1</span><span class="special">&gt;</span>
<span class="keyword">typename</span> <span class="identifier">result_of</span><span class="special">::</span><span class="identifier">actor</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">,</span> <span class="identifier">T0</span> <span class="special">&amp;,</span> <span class="identifier">T1</span> <span class="special">&amp;&gt;::</span><span class="identifier">type</span>
<span class="keyword">operator</span><span class="special">()(</span><span class="identifier">T0</span> <span class="special">&amp;</span><span class="identifier">t0</span><span class="special">,</span> <span class="identifier">T1</span> <span class="special">&amp;</span><span class="identifier">t1</span><span class="special">)</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="identifier">fusion</span><span class="special">::</span><span class="identifier">vector2</span><span class="special">&lt;</span><span class="identifier">T0</span> <span class="special">&amp;,</span> <span class="identifier">T1</span> <span class="special">&amp;&gt;</span> <span class="identifier">env</span><span class="special">(</span><span class="identifier">t0</span><span class="special">,</span> <span class="identifier">t1</span><span class="special">);</span>
<span class="keyword">return</span> <span class="identifier">eval</span><span class="special">(*</span><span class="keyword">this</span><span class="special">,</span> <span class="identifier">context</span><span class="special">(</span><span class="identifier">env</span><span class="special">,</span> <span class="identifier">default_actions</span><span class="special">()));</span>
<span class="special">}</span>
</pre>
<h5>
<a name="phoenix.inside.actor.h6"></a>
<span><a name="phoenix.inside.actor.result_of__actor"></a></span><a class="link" href="actor.html#phoenix.inside.actor.result_of__actor">result_of::actor</a>
</h5>
<p>
For reasons of symmetry to the family of <code class="computeroutput"><span class="identifier">actor</span><span class="special">::</span><span class="keyword">operator</span><span class="special">()</span></code> there is a special metafunction usable
for actor result type calculation named <code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">actor</span></code>.
This metafunction allows us to directly specify the types of the parameters
to be passed to the <code class="computeroutput"><span class="identifier">actor</span><span class="special">::</span><span class="keyword">operator</span><span class="special">()</span></code> function. Here's a typical <code class="computeroutput"><span class="identifier">actor_result</span></code> that accepts two arguments:
</p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">result_of</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Expr</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">T0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">T1</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">actor</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="identifier">fusion</span><span class="special">::</span><span class="identifier">vector2</span><span class="special">&lt;</span><span class="identifier">T0</span><span class="special">,</span> <span class="identifier">T1</span><span class="special">&gt;</span> <span class="identifier">env_tpe</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">result_of</span><span class="special">::</span><span class="identifier">context</span><span class="special">&lt;</span><span class="identifier">env_type</span><span class="special">,</span> <span class="identifier">default_actions</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">ctx_type</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">result_of</span><span class="special">&lt;</span><span class="identifier">evaluator</span><span class="special">(</span><span class="identifier">Expr</span> <span class="keyword">const</span><span class="special">&amp;,</span> <span class="identifier">ctx_type</span><span class="special">)&gt;::</span><span class="identifier">type</span> <span class="identifier">type</span><span class="special">;</span>
<span class="special">};</span>
<span class="special">}</span>
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../inside.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../inside.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="expression.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,81 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Custom Terminals</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../inside.html" title="Inside Phoenix">
<link rel="prev" href="rules.html" title="Predefined Expressions and Rules">
<link rel="next" href="placeholder_unification.html" title="Placeholder Unification">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="rules.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../inside.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="placeholder_unification.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.inside.custom_terminals"></a><a class="link" href="custom_terminals.html" title="Custom Terminals">Custom Terminals</a>
</h3></div></div></div>
<p>
Custom Terminals are used in Phoenix to handle special values transparently.
For example, as Phoenix captures everything by value, we needed to use <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">reference_wrapper</span></code> to bring reference semantics
into Phoenix.
</p>
<p>
Custom terminals could be any wrapper class:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">is_custom_terminal</span><span class="special">;</span>
</pre>
<p>
needs to be specialized in order for Phoenix to recognize this wrapper type.
<code class="computeroutput"><span class="identifier">default_action</span></code> calls <code class="computeroutput"><span class="identifier">custom_terminal</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>.
</p>
<p>
Example:
</p>
<pre class="programlisting"><span class="comment">// Call out boost::reference_wrapper for special handling</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">is_custom_terminal</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">reference_wrapper</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="special">&gt;</span>
<span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span>
<span class="special">{};</span>
<span class="comment">// Special handling for boost::reference_wrapper</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">custom_terminal</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">reference_wrapper</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="special">&gt;</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="identifier">T</span> <span class="special">&amp;</span><span class="identifier">result_type</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Context</span><span class="special">&gt;</span>
<span class="identifier">T</span> <span class="special">&amp;</span><span class="keyword">operator</span><span class="special">()(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">reference_wrapper</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">r</span><span class="special">,</span> <span class="identifier">Context</span> <span class="special">&amp;)</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">r</span><span class="special">;</span>
<span class="special">}</span>
<span class="special">};</span>
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="rules.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../inside.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="placeholder_unification.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,274 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Phoenix Expressions</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../inside.html" title="Inside Phoenix">
<link rel="prev" href="actor.html" title="Actors in Detail">
<link rel="next" href="expression/boilerplate_macros.html" title="Boilerplate Macros">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="actor.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../inside.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="expression/boilerplate_macros.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.inside.expression"></a><a class="link" href="expression.html" title="Phoenix Expressions">Phoenix Expressions</a>
</h3></div></div></div>
<div class="toc"><dl><dt><span class="section"><a href="expression/boilerplate_macros.html">Boilerplate
Macros</a></span></dt></dl></div>
<p>
A Phoenix Expression is a model of the <a href="http://www.boost.org/doc/libs/release/doc/html/Expr.html" target="_top">Proto
Expression</a> Concept. These expressions are wrapped inside an <a class="link" href="actor.html" title="Actors in Detail">Actor</a> template. The <code class="computeroutput"><span class="identifier">actor</span></code>
provides the function call operator which evaluates the expressions. The
<code class="computeroutput"><span class="identifier">actor</span></code> is the domain specific
wrapper around Phoenix expressions.
</p>
<p>
By design, Phoenix Expressions do not carry any information on how they will
be evaluated later on. They are the data structure on which the <code class="computeroutput"><span class="identifier">Actions</span></code> will work.
</p>
<p>
The library provides a convenience template to define expressions:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span><span class="special">&gt;</span> <span class="identifier">Actor</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Tag</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="special">...,</span> <span class="keyword">typename</span> <span class="identifier">A1</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">expr_ext</span>
<span class="special">:</span> <span class="identifier">proto</span><span class="special">::</span><span class="identifier">transform</span><span class="special">&lt;</span><span class="identifier">expr_ext</span><span class="special">&lt;</span><span class="identifier">Actor</span><span class="special">,</span> <span class="identifier">Tag</span><span class="special">,</span> <span class="identifier">A0</span><span class="special">,</span> <span class="special">...,</span> <span class="identifier">A1</span><span class="special">&gt;</span> <span class="special">&gt;</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="emphasis"><em>unspecified</em></span> <span class="identifier">base_expr</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">Actor</span><span class="special">&lt;</span><span class="identifier">base_expr</span><span class="special">&gt;</span> <span class="identifier">type</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="emphasis"><em>unspecified</em></span> <span class="identifier">proto_grammar</span><span class="special">;</span>
<span class="keyword">static</span> <span class="identifier">type</span> <span class="identifier">make</span><span class="special">(</span><span class="identifier">A0</span> <span class="identifier">a0</span><span class="special">,</span> <span class="special">...,</span> <span class="identifier">A1</span> <span class="identifier">a1</span><span class="special">);</span>
<span class="special">};</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Tag</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="special">...,</span> <span class="keyword">typename</span> <span class="identifier">A1</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">expr</span> <span class="special">:</span> <span class="identifier">expr_ext</span><span class="special">&lt;</span><span class="identifier">actor</span><span class="special">,</span> <span class="identifier">Tag</span><span class="special">,</span> <span class="identifier">A0</span><span class="special">,</span> <span class="special">...,</span> <span class="identifier">A1</span><span class="special">&gt;</span> <span class="special">{};</span>
</pre>
<p>
<span class="bold"><strong>Notation</strong></span>
</p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term"><code class="computeroutput"><span class="identifier">A0</span><span class="special">...</span><span class="identifier">AN</span></code></span></dt>
<dd><p>
Child node types
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">a0</span><span class="special">...</span><span class="identifier">aN</span></code></span></dt>
<dd><p>
Child node objects
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">G0</span><span class="special">...</span><span class="identifier">GN</span></code></span></dt>
<dd><p>
<a href="http://www.boost.org/doc/libs/release/libs/proto/index.html" target="_top">Boost.Proto</a>
grammar types
</p></dd>
</dl>
</div>
<p>
<span class="bold"><strong>Expression Semantics</strong></span>
</p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Expression
</p>
</th>
<th>
<p>
Semantics
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">expr</span><span class="special">&lt;</span><span class="identifier">Tag</span><span class="special">,</span>
<span class="identifier">A0</span><span class="special">...</span><span class="identifier">AN</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
</p>
</td>
<td>
<p>
The type of Expression having tag <code class="computeroutput"><span class="identifier">Tag</span></code>
and <code class="computeroutput"><span class="identifier">A0</span><span class="special">...</span><span class="identifier">AN</span></code> children
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">expr</span><span class="special">&lt;</span><span class="identifier">Tag</span><span class="special">,</span>
<span class="identifier">G0</span><span class="special">...</span><span class="identifier">GN</span><span class="special">&gt;</span></code>
</p>
</td>
<td>
<p>
A <a href="http://www.boost.org/doc/libs/release/libs/proto/index.html" target="_top">Boost.Proto</a>
grammar and <a href="http://www.boost.org/doc/libs/release/doc/html/boost/proto/pass_through.html" target="_top">Proto
Pass Through Transform</a>
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">expr</span><span class="special">&lt;</span><span class="identifier">Tag</span><span class="special">,</span>
<span class="identifier">A0</span><span class="special">...</span><span class="identifier">AN</span><span class="special">&gt;::</span><span class="identifier">make</span><span class="special">(</span><span class="identifier">a0</span><span class="special">...</span><span class="identifier">aN</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
Returns a Phoenix Expression
</p>
</td>
</tr>
</tbody>
</table></div>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
You might have noticed the template template argument <code class="computeroutput"><span class="identifier">Actor</span></code>
used in <code class="computeroutput"><span class="identifier">expr_ext</span></code>. This
can be a user supplied custom Actor adding other member functions or objects
than the default <code class="computeroutput"><span class="identifier">actor</span></code>
template. See <a class="link" href="../examples/extending_actors.html" title="Extending Actors">Extending
Actors</a> for more details.
</p></td></tr>
</table></div>
<h5>
<a name="phoenix.inside.expression.h0"></a>
<span><a name="phoenix.inside.expression.meta_grammar"></a></span><a class="link" href="expression.html#phoenix.inside.expression.meta_grammar">meta_grammar</a>
</h5>
<p>
Defining expressions is only part of the game to make it a valid Phoenix
Expression. In order to use the expressions in the Phoenix domain, we need
to "register" them to our grammar.
</p>
<p>
The <code class="computeroutput"><span class="identifier">meta_grammar</span></code> is a struct
for exactly that purpose. It is an openly extendable <a href="http://www.boost.org/doc/libs/release/libs/proto/index.html" target="_top">Boost.Proto</a>
Grammar:
</p>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">meta_grammar</span>
<span class="special">:</span> <span class="identifier">proto</span><span class="special">::</span><span class="identifier">switch_</span><span class="special">&lt;</span><span class="identifier">meta_grammar</span><span class="special">&gt;</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Tag</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Dummy</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">case_</span>
<span class="special">:</span> <span class="identifier">proto</span><span class="special">::</span><span class="identifier">not_</span><span class="special">&lt;</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">_</span><span class="special">&gt;</span>
<span class="special">{};</span>
<span class="special">};</span>
</pre>
<p>
As you can see, by default the <code class="computeroutput"><span class="identifier">meta_grammar</span></code>
matches nothing. With every <a class="link" href="../modules.html" title="Modules">Module</a>
you include this grammar gets extended by various expressions.
</p>
<h5>
<a name="phoenix.inside.expression.h1"></a>
<span><a name="phoenix.inside.expression.example"></a></span><a class="link" href="expression.html#phoenix.inside.expression.example">Example</a>
</h5>
<p>
Define an expression:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Lhs</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Rhs</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">plus</span>
<span class="special">:</span> <span class="identifier">expr</span><span class="special">&lt;</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">plus</span><span class="special">,</span> <span class="identifier">Lhs</span><span class="special">,</span> <span class="identifier">Rhs</span><span class="special">&gt;</span>
<span class="special">{};</span>
</pre>
<p>
And add it to the grammar:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;&gt;</span>
<span class="keyword">struct</span> <span class="identifier">meta_grammar</span><span class="special">::</span><span class="identifier">case_</span><span class="special">&lt;</span><span class="identifier">proto</span><span class="special">::</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">plus</span><span class="special">&gt;</span>
<span class="special">:</span> <span class="identifier">enable_rule</span><span class="special">&lt;</span>
<span class="identifier">plus</span><span class="special">&lt;</span>
<span class="identifier">meta_grammar</span>
<span class="special">,</span> <span class="identifier">meta_grammar</span>
<span class="special">&gt;</span>
<span class="special">&gt;</span>
<span class="special">{};</span>
</pre>
<p>
Define a generator function to make the life of our potential users easier:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Lhs</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Rhs</span><span class="special">&gt;</span>
<span class="keyword">typename</span> <span class="identifier">plus</span><span class="special">&lt;</span><span class="identifier">Lhs</span><span class="special">,</span> <span class="identifier">Rhs</span><span class="special">&gt;::</span><span class="identifier">type</span>
<span class="identifier">plus</span><span class="special">(</span><span class="identifier">Lhs</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">lhs</span><span class="special">,</span> <span class="identifier">Rhs</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">rhs</span><span class="special">)</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">expression</span><span class="special">::</span><span class="identifier">plus</span><span class="special">&lt;</span><span class="identifier">Lhs</span><span class="special">,</span> <span class="identifier">Rhs</span><span class="special">&gt;::</span><span class="identifier">make</span><span class="special">(</span><span class="identifier">lhs</span><span class="special">,</span> <span class="identifier">rhs</span><span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
Look if it really works:
</p>
<pre class="programlisting"><span class="identifier">plus</span><span class="special">(</span><span class="number">6</span><span class="special">,</span> <span class="number">5</span><span class="special">)();</span>
</pre>
<p>
returns 11!
</p>
<pre class="programlisting"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">display_expr</span><span class="special">(</span><span class="identifier">plus</span><span class="special">(</span><span class="number">5</span><span class="special">,</span> <span class="number">6</span><span class="special">));</span>
</pre>
<p>
prints:
</p>
<pre class="programlisting"><span class="identifier">plus</span><span class="special">(</span>
<span class="identifier">terminal</span><span class="special">(</span><span class="number">6</span><span class="special">)</span>
<span class="special">,</span> <span class="identifier">terminal</span><span class="special">(</span><span class="number">5</span><span class="special">)</span>
<span class="special">)</span>
</pre>
<p>
See <a href="../../../../example/define_expression.cpp" target="_top">define_expression.cpp</a>
for the full example.
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
The example shown here only works because <code class="computeroutput"><span class="identifier">default_actions</span></code>
knows how to handle an expression having the <code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">plus</span></code>
and two children. This is because <code class="computeroutput"><span class="identifier">default_actions</span></code>
uses the <code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">_default</span><span class="special">&lt;</span><span class="identifier">meta_grammar</span><span class="special">&gt;</span></code>
transform to evaluate operators and functions. Learn more about actions
<a class="link" href="actions.html" title="More on Actions">here</a>.
</p></td></tr>
</table></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="actor.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../inside.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="expression/boilerplate_macros.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,516 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Boilerplate Macros</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../expression.html" title="Phoenix Expressions">
<link rel="prev" href="../expression.html" title="Phoenix Expressions">
<link rel="next" href="../actions.html" title="More on Actions">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../expression.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../expression.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../actions.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.inside.expression.boilerplate_macros"></a><a class="link" href="boilerplate_macros.html" title="Boilerplate Macros">Boilerplate
Macros</a>
</h4></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression">BOOST_PHOENIX_DEFINE_EXPRESSION</a></span></dt>
<dt><span class="section"><a href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg">BOOST_PHOENIX_DEFINE_EXPRESSION_VARARG</a></span></dt>
<dt><span class="section"><a href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext">BOOST_PHOENIX_DEFINE_EXPRESSION_EXT</a></span></dt>
<dt><span class="section"><a href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg">BOOST_PHOENIX_DEFINE_EXPRESSION_EXT_VARARG</a></span></dt>
</dl></div>
<p>
When having more and more expressions, you start to realize that this is
a very repetetive task. Phoenix provides boilerplate macros that make defining
Phoenix Expressions as you have seen in the <a class="link" href="../expression.html" title="Phoenix Expressions">previous
section</a> look like a piece of cake.
</p>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression"></a><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression" title="BOOST_PHOENIX_DEFINE_EXPRESSION">BOOST_PHOENIX_DEFINE_EXPRESSION</a>
</h5></div></div></div>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.h0"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.description"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.description">Description</a>
</h6>
<p>
<code class="computeroutput"><span class="identifier">BOOST_PHOENIX_DEFINE_EXPRESSION</span></code>
is a macro that can be used to generate all the necessary boilerplate
to create Phoenix Expressions
</p>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.h1"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.synopsis"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.synopsis">Synopsis</a>
</h6>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_DEFINE_EXPRESSION</span><span class="special">(</span>
<span class="special">(</span><span class="identifier">namespace_seq</span><span class="special">)(</span><span class="identifier">name</span><span class="special">)</span>
<span class="special">,</span> <span class="special">(</span><span class="identifier">child_grammar0</span><span class="special">)</span>
<span class="special">(</span><span class="identifier">child_grammar1</span><span class="special">)</span>
<span class="special">...</span>
<span class="special">)</span>
</pre>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.h2"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.semantics"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.semantics">Semantics</a>
</h6>
<p>
The above macro generates the necessary code for an expression <code class="computeroutput"><span class="identifier">name</span></code> in namespace <code class="computeroutput"><span class="identifier">namespace_seq</span></code>.
The sequence of <code class="computeroutput"><span class="special">(</span><span class="identifier">child_grammarN</span><span class="special">)</span></code> declares how many children the expression
will have and what <code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">grammar</span></code>
they match.
</p>
<p>
The macro should be used at global scope. <code class="computeroutput"><span class="identifier">namespace_seq</span></code>
shall be the sequence of namespaces under which the following symbols
will be defined:
</p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">tag</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">name</span><span class="special">;</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">expression</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="keyword">typename</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">name</span>
<span class="special">:</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">expr</span><span class="special">&lt;</span>
<span class="identifier">tag</span><span class="special">::</span><span class="identifier">name</span>
<span class="special">,</span> <span class="identifier">A0</span>
<span class="special">,</span> <span class="identifier">A1</span>
<span class="special">...</span>
<span class="special">,</span> <span class="identifier">AN</span>
<span class="special">&gt;</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">rule</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">name</span>
<span class="special">:</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">expr</span><span class="special">&lt;</span>
<span class="identifier">child_grammar0</span>
<span class="special">,</span> <span class="identifier">child_grammar1</span>
<span class="special">...</span>
<span class="special">,</span> <span class="identifier">child_grammarN</span>
<span class="special">&gt;</span>
<span class="special">{};</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">functional</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">make_name</span><span class="special">;</span> <span class="comment">// A polymorphic function object that can be called to create the expression node</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">result_of</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="keyword">typename</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">make_name</span><span class="special">;</span> <span class="comment">// The result type of the expression node</span>
<span class="special">}</span>
<span class="comment">// convenience polymorphic function to create an expression node</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="keyword">typename</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="identifier">result_of</span><span class="special">::</span><span class="identifier">make_name</span><span class="special">&lt;</span><span class="identifier">A0</span><span class="special">,</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="identifier">make_name</span><span class="special">(</span><span class="identifier">A0</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">a0</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">a1</span> <span class="special">...</span> <span class="identifier">AN</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">an</span><span class="special">);</span>
</pre>
<p>
This macros also adds a specialization for <code class="computeroutput"><span class="identifier">meta_grammar</span><span class="special">::</span><span class="identifier">case_</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">name</span><span class="special">&gt;</span></code> to enable the rule for further use
in actions.
</p>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.h3"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.header"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.header">Header</a>
</h6>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">expression</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.h4"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.example"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression.example">Example</a>
</h6>
<p>
The example from the previous section can be rewritten as:
</p>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_DEFINE_EXPRESSION</span><span class="special">(</span>
<span class="special">(</span><span class="identifier">plus</span><span class="special">)</span>
<span class="special">,</span> <span class="special">(</span><span class="identifier">meta_grammar</span><span class="special">)</span> <span class="comment">// Lhs</span>
<span class="special">(</span><span class="identifier">meta_grammar</span><span class="special">)</span> <span class="comment">// Rhs</span>
<span class="special">)</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Lhs</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Rhs</span><span class="special">&gt;</span>
<span class="keyword">typename</span> <span class="identifier">plus</span><span class="special">&lt;</span><span class="identifier">Lhs</span><span class="special">,</span> <span class="identifier">Rhs</span><span class="special">&gt;::</span><span class="identifier">type</span>
<span class="identifier">plus</span><span class="special">(</span><span class="identifier">Lhs</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">lhs</span><span class="special">,</span> <span class="identifier">Rhs</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">rhs</span><span class="special">)</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">expression</span><span class="special">::</span><span class="identifier">plus</span><span class="special">&lt;</span><span class="identifier">Lhs</span><span class="special">,</span> <span class="identifier">Rhs</span><span class="special">&gt;::</span><span class="identifier">make</span><span class="special">(</span><span class="identifier">lhs</span><span class="special">,</span> <span class="identifier">rhs</span><span class="special">);</span>
<span class="special">}</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg"></a><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg" title="BOOST_PHOENIX_DEFINE_EXPRESSION_VARARG">BOOST_PHOENIX_DEFINE_EXPRESSION_VARARG</a>
</h5></div></div></div>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.h0"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.description"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.description">Description</a>
</h6>
<p>
<code class="computeroutput"><span class="identifier">BOOST_PHOENIX_DEFINE_EXPRESSION_VARARG</span></code>
is a macro that can be used to generate all the necessary boilerplate
to create Phoenix Expressions
</p>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.h1"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.synopsis"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.synopsis">Synopsis</a>
</h6>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_DEFINE_EXPRESSION_VARARG</span><span class="special">(</span>
<span class="special">(</span><span class="identifier">namespace_seq</span><span class="special">)(</span><span class="identifier">name</span><span class="special">)</span>
<span class="special">,</span> <span class="special">(</span><span class="identifier">child_grammar0</span><span class="special">)</span>
<span class="special">(</span><span class="identifier">child_grammar1</span><span class="special">)</span>
<span class="special">...</span>
<span class="special">(</span><span class="identifier">child_grammarN</span><span class="special">)</span>
<span class="special">,</span> <span class="identifier">N</span>
<span class="special">)</span>
</pre>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.h2"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.semantics"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.semantics">Semantics</a>
</h6>
<p>
The above macro generates the necessary code for an expression <code class="computeroutput"><span class="identifier">name</span></code> in namespace <code class="computeroutput"><span class="identifier">namespace_seq</span></code>.
<code class="computeroutput"><span class="identifier">N</span></code> is the maximum number
of variable children. All but the last elements in the grammar sequence
are required children of the expression, and the last denotes a variable
number of children. The number of children an expression of this kind
can hold is therefor <code class="computeroutput"><span class="identifier">N</span><span class="special">-</span><span class="number">1</span></code> plus
the size of the sequence
</p>
<p>
The macro should be used at global scope. <code class="computeroutput"><span class="identifier">namespace_seq</span></code>
shall be the sequence of namespaces under which the following symbols
will be defined:
</p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">tag</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">name</span><span class="special">;</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">expression</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="keyword">typename</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">name</span>
<span class="special">:</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">expr</span><span class="special">&lt;</span>
<span class="identifier">tag</span><span class="special">::</span><span class="identifier">name</span>
<span class="special">,</span> <span class="identifier">A0</span>
<span class="special">,</span> <span class="identifier">A1</span>
<span class="special">...</span>
<span class="special">,</span> <span class="identifier">AN</span>
<span class="special">&gt;</span>
<span class="special">{};</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">rule</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">name</span>
<span class="special">:</span> <span class="identifier">expression</span><span class="special">::</span><span class="identifier">name</span><span class="special">&lt;</span>
<span class="identifier">child_grammar0</span>
<span class="special">,</span> <span class="identifier">child_grammar1</span>
<span class="special">...</span>
<span class="special">,</span> <span class="identifier">proto</span><span class="special">::</span><span class="identifier">vararg</span><span class="special">&lt;</span><span class="identifier">child_grammarN</span><span class="special">&gt;</span>
<span class="special">&gt;</span>
<span class="special">{};</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">functional</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">make_name</span><span class="special">;</span> <span class="comment">// A polymorphic function object that can be called to create the expression node</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">result_of</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="keyword">typename</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">make_name</span><span class="special">;</span> <span class="comment">// The result type of the expression node</span>
<span class="special">}</span>
<span class="comment">// convenience polymorphic function to create an expression node</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="keyword">typename</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="identifier">result_of</span><span class="special">::</span><span class="identifier">make_name</span><span class="special">&lt;</span><span class="identifier">A0</span><span class="special">,</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="identifier">make_name</span><span class="special">(</span><span class="identifier">A0</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">a0</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">a1</span> <span class="special">...</span> <span class="identifier">AN</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">an</span><span class="special">);</span>
</pre>
<p>
This macros also adds a specialization for <code class="computeroutput"><span class="identifier">meta_grammar</span><span class="special">::</span><span class="identifier">case_</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">name</span><span class="special">&gt;</span></code> to enable the rule for further use
in actions.
</p>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.h3"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.header"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.header">Header</a>
</h6>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">expression</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.h4"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.example"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_vararg.example">Example</a>
</h6>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_DEFINE_EXPRESSION_VARARG</span><span class="special">(</span>
<span class="special">(</span><span class="identifier">boost</span><span class="special">)(</span><span class="identifier">phoenix</span><span class="special">)(</span><span class="identifier">mem_fun_ptr</span><span class="special">)</span>
<span class="special">,</span> <span class="special">(</span><span class="identifier">meta_grammar</span><span class="special">)</span> <span class="comment">// Pointer to Object</span>
<span class="special">(</span><span class="identifier">meta_grammar</span><span class="special">)</span> <span class="comment">// Member pointer</span>
<span class="special">(</span><span class="identifier">meta_grammar</span><span class="special">)</span> <span class="comment">// Variable number of arguments</span>
<span class="special">,</span> <span class="identifier">BOOST_PHOENIX_LIMIT</span>
<span class="special">)</span>
</pre>
<p>
This defines the member function pointer operator expression as described
in <a class="link" href="../../modules/operator.html" title="Operator">operators</a>.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext"></a><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext" title="BOOST_PHOENIX_DEFINE_EXPRESSION_EXT">BOOST_PHOENIX_DEFINE_EXPRESSION_EXT</a>
</h5></div></div></div>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.h0"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.description"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.description">Description</a>
</h6>
<p>
<code class="computeroutput"><span class="identifier">BOOST_PHOENIX_DEFINE_EXPRESSION_EXT</span></code>
is a macro that can be used to generate all the necessary boilerplate
to create Phoenix Expressions
</p>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.h1"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.synopsis"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.synopsis">Synopsis</a>
</h6>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_DEFINE_EXPRESSION_EXT</span><span class="special">(</span>
<span class="identifier">actor</span>
<span class="special">,</span> <span class="special">(</span><span class="identifier">namespace_seq</span><span class="special">)(</span><span class="identifier">name</span><span class="special">)</span>
<span class="special">,</span> <span class="special">(</span><span class="identifier">child_grammar0</span><span class="special">)</span>
<span class="special">(</span><span class="identifier">child_grammar1</span><span class="special">)</span>
<span class="special">...</span>
<span class="special">(</span><span class="identifier">child_grammarN</span><span class="special">)</span>
<span class="special">,</span> <span class="identifier">N</span>
<span class="special">)</span>
</pre>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.h2"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.semantics"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.semantics">Semantics</a>
</h6>
<p>
The above macro generates the necessary code for an expression <code class="computeroutput"><span class="identifier">name</span></code> in namespace <code class="computeroutput"><span class="identifier">namespace_seq</span></code>.
The sequence of <code class="computeroutput"><span class="special">(</span><span class="identifier">child_grammarN</span><span class="special">)</span></code> declares how many children the expression
will have and what <code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">grammar</span></code>
they match.
</p>
<p>
The macro should be used at global scope. <code class="computeroutput"><span class="identifier">namespace_seq</span></code>
shall be the sequence of namespaces under which the following symbols
will be defined:
</p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">tag</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">name</span><span class="special">;</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">expression</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="keyword">typename</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">name</span>
<span class="special">:</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">expr_ext</span><span class="special">&lt;</span>
<span class="identifier">actor</span>
<span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">name</span>
<span class="special">,</span> <span class="identifier">A0</span>
<span class="special">,</span> <span class="identifier">A1</span>
<span class="special">...</span>
<span class="special">,</span> <span class="identifier">AN</span>
<span class="special">&gt;</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">rule</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">name</span>
<span class="special">:</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">expr</span><span class="special">&lt;</span>
<span class="identifier">child_grammar0</span>
<span class="special">,</span> <span class="identifier">child_grammar1</span>
<span class="special">...</span>
<span class="special">,</span> <span class="identifier">child_grammarN</span>
<span class="special">&gt;</span>
<span class="special">{};</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">functional</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">make_name</span><span class="special">;</span> <span class="comment">// A polymorphic function object that can be called to create the expression node</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">result_of</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="keyword">typename</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">make_name</span><span class="special">;</span> <span class="comment">// The result type of the expression node</span>
<span class="special">}</span>
<span class="comment">// convenience polymorphic function to create an expression node</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="keyword">typename</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="identifier">result_of</span><span class="special">::</span><span class="identifier">make_name</span><span class="special">&lt;</span><span class="identifier">A0</span><span class="special">,</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="identifier">make_name</span><span class="special">(</span><span class="identifier">A0</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">a0</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">a1</span> <span class="special">...</span> <span class="identifier">AN</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">an</span><span class="special">);</span>
</pre>
<p>
This macros also adds a specialization for <code class="computeroutput"><span class="identifier">meta_grammar</span><span class="special">::</span><span class="identifier">case_</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">name</span><span class="special">&gt;</span></code> to enable the rule for further use
in actions.
</p>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.h3"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.header"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.header">Header</a>
</h6>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">expression</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.h4"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.example"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext.example">Example</a>
</h6>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_DEFINE_EXPRESSION_EXT</span><span class="special">(</span>
<span class="identifier">if_actor</span>
<span class="special">,</span> <span class="special">(</span><span class="identifier">boost</span><span class="special">)(</span><span class="identifier">phoenix</span><span class="special">)(</span><span class="identifier">if_</span><span class="special">)</span>
<span class="special">,</span> <span class="special">(</span><span class="identifier">meta_grammar</span><span class="special">)</span> <span class="comment">// Cond</span>
<span class="special">(</span><span class="identifier">meta_grammar</span><span class="special">)</span> <span class="comment">// Then</span>
<span class="special">)</span>
</pre>
<p>
This defines the if_ expression. The custom actor defines <code class="computeroutput"><span class="identifier">else_</span></code> as a member.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg"></a><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg" title="BOOST_PHOENIX_DEFINE_EXPRESSION_EXT_VARARG">BOOST_PHOENIX_DEFINE_EXPRESSION_EXT_VARARG</a>
</h5></div></div></div>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.h0"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.description"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.description">Description</a>
</h6>
<p>
<code class="computeroutput"><span class="identifier">BOOST_PHOENIX_DEFINE_EXPRESSION_EXT_VARARG</span></code>
is a macro that can be used to generate all the necessary boilerplate
to create Phoenix Expressions
</p>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.h1"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.synopsis"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.synopsis">Synopsis</a>
</h6>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_DEFINE_EXPRESSION_EXT_VARARG</span><span class="special">(</span>
<span class="identifier">actor</span>
<span class="special">,</span> <span class="special">(</span><span class="identifier">namespace_seq</span><span class="special">)(</span><span class="identifier">name</span><span class="special">)</span>
<span class="special">,</span> <span class="special">(</span><span class="identifier">child_grammar0</span><span class="special">)</span>
<span class="special">(</span><span class="identifier">child_grammar1</span><span class="special">)</span>
<span class="special">...</span>
<span class="special">(</span><span class="identifier">child_grammarN</span><span class="special">)</span>
<span class="special">,</span> <span class="identifier">N</span>
<span class="special">)</span>
</pre>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.h2"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.semantics"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.semantics">Semantics</a>
</h6>
<p>
The above macro generates the necessary code for an expression <code class="computeroutput"><span class="identifier">name</span></code> in namespace <code class="computeroutput"><span class="identifier">namespace_seq</span></code>.
<code class="computeroutput"><span class="identifier">N</span></code> is the maximum number
of variable children. All but the last elements in the grammar sequence
are required children of the expression, and the last denotes a variable
number of children. The number of children an expression of this kind
can hold is therefor <code class="computeroutput"><span class="identifier">N</span><span class="special">-</span><span class="number">1</span></code> plus
the size of the sequence
</p>
<p>
The macro should be used at global scope. <code class="computeroutput"><span class="identifier">namespace_seq</span></code>
shall be the sequence of namespaces under which the following symbols
will be defined:
</p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">tag</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">name</span><span class="special">;</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">expression</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="keyword">typename</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">name</span>
<span class="special">:</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">expr_ext</span><span class="special">&lt;</span>
<span class="identifier">actor</span>
<span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">name</span>
<span class="special">,</span> <span class="identifier">A0</span>
<span class="special">,</span> <span class="identifier">A1</span>
<span class="special">...</span>
<span class="special">,</span> <span class="identifier">AN</span>
<span class="special">&gt;</span>
<span class="special">{};</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">rule</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">name</span>
<span class="special">:</span> <span class="identifier">expression</span><span class="special">::</span><span class="identifier">name</span><span class="special">&lt;</span>
<span class="identifier">child_grammar0</span>
<span class="special">,</span> <span class="identifier">child_grammar1</span>
<span class="special">...</span>
<span class="special">,</span> <span class="identifier">proto</span><span class="special">::</span><span class="identifier">vararg</span><span class="special">&lt;</span><span class="identifier">child_grammarN</span><span class="special">&gt;</span>
<span class="special">&gt;</span>
<span class="special">{};</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">functional</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">make_name</span><span class="special">;</span> <span class="comment">// A polymorphic function object that can be called to create the expression node</span>
<span class="special">}</span>
<span class="keyword">namespace</span> <span class="identifier">result_of</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="keyword">typename</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">make_name</span><span class="special">;</span> <span class="comment">// The result type of the expression node</span>
<span class="special">}</span>
<span class="comment">// convenience polymorphic function to create an expression node</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="keyword">typename</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="identifier">result_of</span><span class="special">::</span><span class="identifier">make_name</span><span class="special">&lt;</span><span class="identifier">A0</span><span class="special">,</span> <span class="identifier">A1</span> <span class="special">...</span> <span class="identifier">AN</span><span class="special">&gt;</span>
<span class="identifier">make_name</span><span class="special">(</span><span class="identifier">A0</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">a0</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">a1</span> <span class="special">...</span> <span class="identifier">AN</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">an</span><span class="special">);</span>
</pre>
<p>
This macros also adds a specialization for <code class="computeroutput"><span class="identifier">meta_grammar</span><span class="special">::</span><span class="identifier">case_</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">name</span><span class="special">&gt;</span></code> to enable the rule for further use
in actions.
</p>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.h3"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.header"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.header">Header</a>
</h6>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">expression</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<h6>
<a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.h4"></a>
<span><a name="phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.example"></a></span><a class="link" href="boilerplate_macros.html#phoenix.inside.expression.boilerplate_macros.boost_phoenix_define_expression_ext_vararg.example">Example</a>
</h6>
<p>
TBD
</p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../expression.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../expression.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../actions.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,57 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Placeholder Unification</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../inside.html" title="Inside Phoenix">
<link rel="prev" href="custom_terminals.html" title="Custom Terminals">
<link rel="next" href="../examples.html" title="Advanced Examples">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="custom_terminals.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../inside.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../examples.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.inside.placeholder_unification"></a><a class="link" href="placeholder_unification.html" title="Placeholder Unification">Placeholder Unification</a>
</h3></div></div></div>
<p>
Phoenix uses <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_placeholder</span></code> for recognizing placeholders:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">is_placeholder</span>
<span class="special">{</span>
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">value</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
<span class="special">};</span>
</pre>
<p>
To adapt your own placeholder, the nested value needs to be greater than
0 for your types. This is done by specializing this trait.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="custom_terminals.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../inside.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../examples.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,71 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Introduction</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="prev" href="what_s_new/phoenix_3_0.html" title="Phoenix 3.0">
<link rel="next" href="starter_kit.html" title="Starter Kit">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="what_s_new/phoenix_3_0.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="starter_kit.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="phoenix.introduction"></a><a class="link" href="introduction.html" title="Introduction">Introduction</a>
</h2></div></div></div>
<p>
<span class="inlinemediaobject"><img src="../images/banner.png"></span>
</p>
<p>
The Phoenix library enables FP techniques such as higher order functions,
<span class="emphasis"><em>lambda</em></span> (unnamed functions), <span class="emphasis"><em>currying</em></span>
(partial function application) and lazy evaluation in C++. The focus is more
on usefulness and practicality than purity, elegance and strict adherence to
FP principles.
</p>
<p>
FP is a programming discipline that is not at all tied to a specific language.
FP as a programming discipline can, in fact, be applied to many programming
languages. In the realm of C++ for instance, we are seeing more FP techniques
being applied. C++ is sufficiently rich to support at least some of the most
important facets of FP. C++ is a multiparadigm programming language. It is
not only procedural. It is not only object oriented. Beneath the core of the
standard C++ library, a closer look into STL gives us a glimpse of FP already
in place. It is obvious that the authors of STL know and practice FP. In the
near future, we shall surely see more FP trickle down into the mainstream.
</p>
<p>
The truth is, most of the FP techniques can coexist quite well with the standard
object oriented and imperative programming paradigms. When we are using STL
algorithms and functors (function objects) for example, we are already doing
FP. Phoenix is an evolutionary next step.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="what_s_new/phoenix_3_0.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="starter_kit.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,122 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Lazy List</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="prev" href="examples/transforming_the_expression_tree.html" title="Transforming the Expression Tree">
<link rel="next" href="lazy_list/background.html" title="Background">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="examples/transforming_the_expression_tree.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="lazy_list/background.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="phoenix.lazy_list"></a><a class="link" href="lazy_list.html" title="Lazy List">Lazy List</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="lazy_list/background.html">Background</a></span></dt>
<dt><span class="section"><a href="lazy_list/what_is_provided.html">What is provided</a></span></dt>
<dt><span class="section"><a href="lazy_list/tutorial_with_examples.html">Tutorial with
examples</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="lazy_list/tutorial_with_examples/arithmetic_functions.html">Arithmetic
functions</a></span></dt>
<dt><span class="section"><a href="lazy_list/tutorial_with_examples/list_generation.html">List
Generation</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="lazy_list/exceptions.html">Exceptions</a></span></dt>
<dt><span class="section"><a href="lazy_list/implementation_details.html">Implementation
Details</a></span></dt>
<dt><span class="section"><a href="lazy_list/testing.html">Testing</a></span></dt>
<dt><span class="section"><a href="lazy_list/where_next_.html">Where Next?</a></span></dt>
</dl></div>
<h2>
<a name="phoenix.lazy_list.h0"></a>
<span><a name="phoenix.lazy_list.summary"></a></span><a class="link" href="lazy_list.html#phoenix.lazy_list.summary">Summary</a>
</h2>
<p>
Phoenix now has a lazy list implementation which is very similar but not identical
to the implementation provided by <a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>.
This provides a set of objects defined by list&lt;type&gt;, for example this
which defines an empty list of type int.
</p>
<pre class="programlisting"><span class="identifier">list</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">example</span><span class="special">;</span>
</pre>
<p>
A list can contain zero or more elements of the same type. It can also be declared
using a function returning values of the correct type. Such lists are only
evaluated on demand. A set of functions are defined which enable many ways
of manipulating and using lists. Examples are provided for the features available.
</p>
<p>
Exceptions are provided to deal with certain cases and these can be turned
off if desired. There is a check on the maximum list length which has a default
of 1000 which can be changed by the user.
</p>
<p>
This is an extension to Boost Phoenix which does not change the public interface
except to define new features in the namespace
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span>
</pre>
<p>
It has to be explicitly included using the header
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">function</span><span class="special">/</span><span class="identifier">lazy_prelude</span><span class="special">.</span><span class="identifier">hpp</span>
</pre>
<h2>
<a name="phoenix.lazy_list.h1"></a>
<span><a name="phoenix.lazy_list.introduction"></a></span><a class="link" href="lazy_list.html#phoenix.lazy_list.introduction">Introduction</a>
</h2>
<p>
Boost Phoenix provides many features of functional_programming. One of the
things which has been missing until now is a lazy list implementation. One
is available in the library <a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>
which although not part of Boost has many similarities. It has been possible
to reimplement the strategy of the <a href="http://people.cs.umass.edu/~yannis/fc++/New/new_list_implementation.html" target="_top">FC++
List Implementation</a> using the facilties in Phoenix. This provides something
which has up until now not been available anywhere in Phoenix and probably
not anywhere else in Boost. This new implementation is very well integrated
with other features in Phoenix as it uses the same mechanism. In turn that
is well integrated with Boost Function.
</p>
<p>
There is a great deal of material in <a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>
and it is not proposed to replicate all of it. A great deal has changed since
<a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a> was written and
many things are already available in Phoenix or elsewhere. The emphasis here
is to add to Phoenix in a way which will make it easier to implement functional_programming.
</p>
<p>
Progress is being made in implementing both the basic list&lt;T&gt; and the
functions needed to manipulate lists.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="examples/transforming_the_expression_tree.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="lazy_list/background.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,82 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Background</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../lazy_list.html" title="Lazy List">
<link rel="prev" href="../lazy_list.html" title="Lazy List">
<link rel="next" href="what_is_provided.html" title="What is provided">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../lazy_list.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../lazy_list.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="what_is_provided.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.lazy_list.background"></a><a class="link" href="background.html" title="Background">Background</a>
</h3></div></div></div>
<p>
The original code of <a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>
was developed by Brian McNamara and Yannis Smaragdakis between 2000 and 2003.
One of the aims of their work was to implement as much as possible of the
Haskell prelude in C++. In the end they achieved a very large part of that
and went on to implement other similar things not in the Haskell prelude.
This was made up of a large amount of code written very carefully in a consistent
style which made it easy to extend it to provide more facilities.
</p>
<p>
At the end of that time, two versions of it existed, FC++ 1.5 and <a href="http://cgi.di.uoa.gr/~smaragd/fc++/boostpaper/" target="_top">Boost FC++</a> which
was proposed for inclusion in Boost and rejected. Both are documented on
<a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>.
</p>
<p>
After 2003 John Fletcher spent a lot of time developing both these versions
and adding new features to them. One of the reasons intially was that the
existing versions could handle only a small number of function arguments.
He was able to inclrease the limit on the number of arguments and use the
new version to implement a number of new ideas. No new release has ever been
made although a draft release 1.5.2 exists. Much of his activity is documented
by <a href="http://c2.com/cgi/wiki?FunctoidsInCpp" target="_top">FunctoidsInCpp</a>
where some discussion took place with other people about this work.
</p>
<p>
John discussed with Joel de Guzman how to make <a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>
compatible with Phoenix. Joel suggested using Phoenix as a basis for a new
version of <a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>.
</p>
<p>
In 2014 John became the maintainer of Phoenix and after spending time getting
to know it he has now started to fulfil his idea of a new version of <a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>. What is emerging
is significantly different from <a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>
in the detail of the implementation. In some ways it will be more powerful
as it is well integrated with the facilities of Phoenix. In other ways it
will lack some features of <a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>
as they can now be implemented in other ways.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../lazy_list.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../lazy_list.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="what_is_provided.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,101 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Exceptions</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../lazy_list.html" title="Lazy List">
<link rel="prev" href="tutorial_with_examples/list_generation.html" title="List Generation">
<link rel="next" href="implementation_details.html" title="Implementation Details">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="tutorial_with_examples/list_generation.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../lazy_list.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="implementation_details.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.lazy_list.exceptions"></a><a class="link" href="exceptions.html" title="Exceptions">Exceptions</a>
</h3></div></div></div>
<p>
Exceptions are used when there is a danger of a runaway or illegal operations
on an empty list.
</p>
<p>
The key example is to take the length of a non-terminating list, e.g.
</p>
<pre class="programlisting"><span class="identifier">length</span><span class="special">(</span><span class="identifier">enum_from</span><span class="special">(</span><span class="number">1</span><span class="special">))</span>
</pre>
<p>
This is protected using an exception:
</p>
<pre class="programlisting"><span class="identifier">lazy_exception</span>
</pre>
<p>
Note that this is implemented such that defining
</p>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_NO_LAZY_EXCEPTIONS</span>
</pre>
<p>
will enable the user to turn off the exceptions at their own risk.
</p>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_FUNCTION_MAX_LAZY_LIST_LENGTH</span>
</pre>
<p>
is currently defined as 1000 and again the user can define their own value.
</p>
<p>
In the length function this how it is implemented:
</p>
<pre class="programlisting"> <span class="keyword">struct</span> <span class="identifier">Length</span> <span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Sig</span><span class="special">&gt;</span> <span class="keyword">struct</span> <span class="identifier">result</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">This</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">L</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">This</span><span class="special">(</span><span class="identifier">L</span><span class="special">)&gt;</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="identifier">size_t</span> <span class="identifier">type</span><span class="special">;</span>
<span class="special">};</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">L</span><span class="special">&gt;</span>
<span class="identifier">size_t</span> <span class="keyword">operator</span><span class="special">()(</span> <span class="keyword">const</span> <span class="identifier">L</span><span class="special">&amp;</span> <span class="identifier">ll</span> <span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span>
<span class="keyword">typename</span> <span class="identifier">L</span><span class="special">::</span><span class="identifier">delay_result_type</span> <span class="identifier">l</span> <span class="special">=</span> <span class="identifier">delay</span><span class="special">(</span><span class="identifier">ll</span><span class="special">);</span>
<span class="identifier">size_t</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
<span class="keyword">while</span><span class="special">(</span> <span class="special">!</span><span class="identifier">null</span><span class="special">(</span><span class="identifier">l</span><span class="special">)()</span> <span class="special">)</span> <span class="special">{</span>
<span class="identifier">l</span> <span class="special">=</span> <span class="identifier">tail</span><span class="special">(</span><span class="identifier">l</span><span class="special">);</span>
<span class="special">++</span><span class="identifier">x</span><span class="special">;</span>
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">x</span> <span class="special">&gt;</span> <span class="identifier">BOOST_PHOENIX_FUNCTION_MAX_LAZY_LIST_LENGTH</span><span class="special">)</span>
<span class="keyword">break</span><span class="special">;</span>
<span class="special">}</span>
<span class="preprocessor">#ifndef</span> <span class="identifier">BOOST_PHOENIX_NO_LAZY_EXCEPTIONS</span>
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">x</span> <span class="special">&gt;</span> <span class="identifier">BOOST_PHOENIX_FUNCTION_MAX_LAZY_LIST_LENGTH</span><span class="special">)</span>
<span class="keyword">throw</span> <span class="identifier">lazy_exception</span><span class="special">(</span><span class="string">"Your list is too long!!"</span><span class="special">);</span>
<span class="preprocessor">#endif</span>
<span class="keyword">return</span> <span class="identifier">x</span><span class="special">;</span>
<span class="special">}</span>
<span class="special">};</span>
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="tutorial_with_examples/list_generation.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../lazy_list.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="implementation_details.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,292 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Implementation Details</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../lazy_list.html" title="Lazy List">
<link rel="prev" href="exceptions.html" title="Exceptions">
<link rel="next" href="testing.html" title="Testing">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="exceptions.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../lazy_list.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="testing.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.lazy_list.implementation_details"></a><a class="link" href="implementation_details.html" title="Implementation Details">Implementation
Details</a>
</h3></div></div></div>
<h3>
<a name="phoenix.lazy_list.implementation_details.h0"></a>
<span><a name="phoenix.lazy_list.implementation_details.introduction"></a></span><a class="link" href="implementation_details.html#phoenix.lazy_list.implementation_details.introduction">Introduction</a>
</h3>
<p>
The implementation has depended on close study of the existing code of <a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>. The <a href="http://people.cs.umass.edu/~yannis/fc++/New/new_list_implementation.html" target="_top">FC++
List Implementation</a> is a carefully crafted code which allows for
efficient processing of a number of different cases. In particular it makes
use of the <a href="http://people.cs.umass.edu/~yannis/fc++/New/reusers.html" target="_top">FC++
Reuser Implementation</a> for processing of repetitive evaluations.
</p>
<p>
<a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a> uses a combination
of polymorphic and single type functions which can be passed as arguments
to other functions.
</p>
<p>
The implementation of list&lt;T&gt; has needed new implementations of the
strategy using the facilities of Boost Phoenix and also Boost Function. It
turns out that a combination of both can be used to meet the needs of list&lt;T&gt;.
</p>
<p>
The fact that the functions are defined by boost::phoenix::function means
that they work with phoenix arguments such as 'arg1'. This is the fact which
ensures the flexibility needed for the user to build new functions as needed.
</p>
<h3>
<a name="phoenix.lazy_list.implementation_details.h1"></a>
<span><a name="phoenix.lazy_list.implementation_details.fc___legacy"></a></span><a class="link" href="implementation_details.html#phoenix.lazy_list.implementation_details.fc___legacy">FC++ legacy</a>
</h3>
<p>
The <a href="http://people.cs.umass.edu/~yannis/fc++/New/new_list_implementation.html" target="_top">FC++
List Implementation</a> and the <a href="http://people.cs.umass.edu/~yannis/fc++/New/reusers.html" target="_top">FC++
Reuser Implementation</a> have been followed very closely in building
this code. The version used as the starting point was the <a href="http://cgi.di.uoa.gr/~smaragd/fc++/boostpaper/" target="_top">Boost
FC++</a> version.
</p>
<h3>
<a name="phoenix.lazy_list.implementation_details.h2"></a>
<span><a name="phoenix.lazy_list.implementation_details.polymorphic_function_types"></a></span><a class="link" href="implementation_details.html#phoenix.lazy_list.implementation_details.polymorphic_function_types">Polymorphic
Function Types</a>
</h3>
<p>
Functions are implemented as a struct within namespace impl. For an example
funcion 'x' the type is defined like this:
</p>
<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="identifier">impl</span><span class="special">::</span><span class="identifier">X</span><span class="special">&gt;</span> <span class="identifier">X</span><span class="special">;</span>
<span class="identifier">X</span> <span class="identifier">x</span>
</pre>
<p>
This alternative will work to provide a function 'x' but it is not then possible
to pass it as an argument.
</p>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_ADAPT_CALLABLE</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">impl</span><span class="special">::</span><span class="identifier">X</span><span class="special">,</span> <span class="number">1</span><span class="special">)</span>
</pre>
<h4>
<a name="phoenix.lazy_list.implementation_details.h3"></a>
<span><a name="phoenix.lazy_list.implementation_details.implementation_example"></a></span><a class="link" href="implementation_details.html#phoenix.lazy_list.implementation_details.implementation_example">Implementation
Example</a>
</h4>
<p>
This example implements id() which simply returns its argument:
</p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">impl</span> <span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">Id</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Sig</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">result</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">This</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">This</span><span class="special">(</span><span class="identifier">A0</span><span class="special">)&gt;</span>
<span class="special">:</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_reference</span><span class="special">&lt;</span><span class="identifier">A0</span><span class="special">&gt;</span>
<span class="special">{};</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">&gt;</span>
<span class="identifier">A0</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">A0</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">a0</span><span class="special">)</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">a0</span><span class="special">;</span>
<span class="special">}</span>
<span class="special">};</span>
<span class="special">}</span>
<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="identifier">impl</span><span class="special">::</span><span class="identifier">Id</span><span class="special">&gt;</span> <span class="identifier">Id</span><span class="special">;</span>
<span class="identifier">Id</span> <span class="identifier">id</span><span class="special">;</span>
</pre>
<h3>
<a name="phoenix.lazy_list.implementation_details.h4"></a>
<span><a name="phoenix.lazy_list.implementation_details.functions_with_defined_return_type"></a></span><a class="link" href="implementation_details.html#phoenix.lazy_list.implementation_details.functions_with_defined_return_type">Functions
with defined return type</a>
</h3>
<p>
Sometimes it is necessary to define a function using a templated struct,
where the template parameter type defines the return type.
</p>
<h4>
<a name="phoenix.lazy_list.implementation_details.h5"></a>
<span><a name="phoenix.lazy_list.implementation_details.example_with_one_argument"></a></span><a class="link" href="implementation_details.html#phoenix.lazy_list.implementation_details.example_with_one_argument">Example
with one argument</a>
</h4>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">impl</span> <span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Result</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">what</span> <span class="special">{</span>
<span class="keyword">typedef</span> <span class="identifier">Result</span> <span class="identifier">result_type</span><span class="special">;</span>
<span class="identifier">Result</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">Result</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">r</span><span class="special">)</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">r</span><span class="special">;</span>
<span class="special">}</span>
<span class="special">};</span>
<span class="special">}</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">function1</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">what_int</span> <span class="special">=</span> <span class="identifier">impl</span><span class="special">::</span><span class="identifier">what</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;();</span>
<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function1</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">fun1_int_int</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="identifier">fun1_int_int</span><span class="special">&gt;</span> <span class="identifier">What_arg</span><span class="special">;</span>
<span class="identifier">What_arg</span> <span class="identifier">what_arg</span><span class="special">(</span><span class="identifier">what_int</span><span class="special">);</span>
</pre>
<h4>
<a name="phoenix.lazy_list.implementation_details.h6"></a>
<span><a name="phoenix.lazy_list.implementation_details.example_with_zero_arguments"></a></span><a class="link" href="implementation_details.html#phoenix.lazy_list.implementation_details.example_with_zero_arguments">Example
with zero arguments</a>
</h4>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">impl</span> <span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Result</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">what0</span> <span class="special">{</span>
<span class="keyword">typedef</span> <span class="identifier">Result</span> <span class="identifier">result_type</span><span class="special">;</span>
<span class="identifier">Result</span> <span class="keyword">operator</span><span class="special">()()</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">Result</span><span class="special">(</span><span class="number">100</span><span class="special">);</span>
<span class="special">}</span>
<span class="special">};</span>
<span class="special">}</span>
<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function0</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">fun0_int</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">function0</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">what0_int</span> <span class="special">=</span> <span class="identifier">impl</span><span class="special">::</span><span class="identifier">what0</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;();</span>
<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="identifier">fun0_int</span><span class="special">&gt;</span> <span class="identifier">What0_arg</span><span class="special">;</span>
<span class="identifier">What0_arg</span> <span class="identifier">what0_arg</span><span class="special">(</span><span class="identifier">what0_int</span><span class="special">);</span>
</pre>
<h3>
<a name="phoenix.lazy_list.implementation_details.h7"></a>
<span><a name="phoenix.lazy_list.implementation_details.list_generation_implementation"></a></span><a class="link" href="implementation_details.html#phoenix.lazy_list.implementation_details.list_generation_implementation">List
Generation Implementation</a>
</h3>
<p>
The implementation of the function
</p>
<pre class="programlisting"><span class="identifier">enum_from</span><span class="special">(</span><span class="number">1</span><span class="special">)</span>
</pre>
<p>
requires a functor which will evaluate the successive numbers on demand.
The code from <a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>
has been reimplemented using internal functors as follows.
</p>
<p>
This code has to carefully manipulate the input type T to construct the result
type which is a list.
</p>
<p>
The code in EFH is used to build a series of objects which each add one element
to the list and return the function which will add the next element. That
only gets called when it is needed.
</p>
<pre class="programlisting"> <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">EFH</span>
<span class="special">{</span>
<span class="keyword">mutable</span> <span class="identifier">T</span> <span class="identifier">x</span><span class="special">;</span>
<span class="identifier">EFH</span><span class="special">(</span> <span class="keyword">const</span> <span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">xx</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">x</span><span class="special">(</span><span class="identifier">xx</span><span class="special">)</span> <span class="special">{}</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Sig</span><span class="special">&gt;</span> <span class="keyword">struct</span> <span class="identifier">result</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">This</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">TT</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">This</span><span class="special">(</span><span class="identifier">TT</span><span class="special">)&gt;</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">UseList</span><span class="special">::</span><span class="keyword">template</span>
<span class="identifier">List</span><span class="special">&lt;</span><span class="identifier">TT</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">LType</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">result_of</span><span class="special">::</span>
<span class="identifier">ListType</span><span class="special">&lt;</span><span class="identifier">LType</span><span class="special">&gt;::</span><span class="identifier">delay_result_type</span> <span class="identifier">type</span><span class="special">;</span>
<span class="special">};</span>
<span class="keyword">typename</span> <span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">EFH</span><span class="special">(</span><span class="identifier">T</span><span class="special">)&gt;::</span><span class="identifier">type</span> <span class="keyword">operator</span><span class="special">()()</span> <span class="keyword">const</span> <span class="special">{</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">UseList</span><span class="special">::</span><span class="keyword">template</span> <span class="identifier">List</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">LType</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">result_of</span><span class="special">::</span><span class="identifier">ListType</span><span class="special">&lt;</span><span class="identifier">LType</span><span class="special">&gt;::</span>
<span class="identifier">delay_result_type</span> <span class="identifier">result_type</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function0</span><span class="special">&lt;</span><span class="identifier">result_type</span><span class="special">&gt;</span> <span class="identifier">fun1_R_TTT</span><span class="special">;</span>
<span class="special">++</span><span class="identifier">x</span><span class="special">;</span>
<span class="identifier">fun1_R_TTT</span> <span class="identifier">efh_R_TTT</span> <span class="special">=</span> <span class="identifier">EFH</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="identifier">x</span><span class="special">);</span>
<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="identifier">fun1_R_TTT</span><span class="special">&gt;</span> <span class="identifier">EFH_R_T</span><span class="special">;</span>
<span class="identifier">EFH_R_T</span> <span class="identifier">efh_R_T</span><span class="special">(</span><span class="identifier">efh_R_TTT</span><span class="special">);</span>
<span class="preprocessor">#ifndef</span> <span class="identifier">BOOST_PHOENIX_NO_LAZY_EXCEPTIONS</span>
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">x</span> <span class="special">&gt;</span> <span class="identifier">BOOST_PHOENIX_FUNCTION_MAX_LAZY_LIST_LENGTH</span><span class="special">)</span>
<span class="keyword">throw</span> <span class="identifier">lazy_exception</span><span class="special">(</span><span class="string">"Running away in EFH!!"</span><span class="special">);</span>
<span class="preprocessor">#endif</span>
<span class="keyword">return</span> <span class="identifier">cons</span><span class="special">(</span> <span class="identifier">x</span><span class="special">-</span><span class="number">1</span><span class="special">,</span> <span class="identifier">efh_R_T</span><span class="special">()</span> <span class="special">);</span>
<span class="special">}</span>
<span class="special">};</span>
<span class="keyword">struct</span> <span class="identifier">Enum_from</span> <span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Sig</span><span class="special">&gt;</span> <span class="keyword">struct</span> <span class="identifier">result</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">This</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">This</span><span class="special">(</span><span class="identifier">T</span><span class="special">)&gt;</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_reference</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">TT</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_const</span><span class="special">&lt;</span><span class="identifier">TT</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">TTT</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">UseList</span><span class="special">::</span><span class="keyword">template</span> <span class="identifier">List</span><span class="special">&lt;</span><span class="identifier">TTT</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">LType</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">result_of</span><span class="special">::</span><span class="identifier">ListType</span><span class="special">&lt;</span><span class="identifier">LType</span><span class="special">&gt;::</span>
<span class="identifier">delay_result_type</span> <span class="identifier">type</span><span class="special">;</span>
<span class="special">};</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">typename</span> <span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">Enum_from</span><span class="special">(</span><span class="identifier">T</span><span class="special">)&gt;::</span><span class="identifier">type</span> <span class="keyword">operator</span><span class="special">()</span>
<span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span> <span class="identifier">x</span><span class="special">)</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_reference</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">TT</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_const</span><span class="special">&lt;</span><span class="identifier">TT</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">TTT</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">UseList</span><span class="special">::</span><span class="keyword">template</span> <span class="identifier">List</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">LType</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">result_of</span><span class="special">::</span><span class="identifier">ListType</span><span class="special">&lt;</span><span class="identifier">LType</span><span class="special">&gt;::</span>
<span class="identifier">delay_result_type</span> <span class="identifier">result_type</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function0</span><span class="special">&lt;</span><span class="identifier">result_type</span><span class="special">&gt;</span> <span class="identifier">fun1_R_TTT</span><span class="special">;</span>
<span class="identifier">fun1_R_TTT</span> <span class="identifier">efh_R_TTT</span> <span class="special">=</span> <span class="identifier">EFH</span><span class="special">&lt;</span><span class="identifier">TTT</span><span class="special">&gt;(</span><span class="identifier">x</span><span class="special">);</span>
<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="identifier">fun1_R_TTT</span><span class="special">&gt;</span> <span class="identifier">EFH_R_T</span><span class="special">;</span>
<span class="identifier">EFH_R_T</span> <span class="identifier">efh_R_T</span><span class="special">(</span><span class="identifier">efh_R_TTT</span><span class="special">);</span>
<span class="comment">//std::cout &lt;&lt; "enum_from (" &lt;&lt; x &lt;&lt; ")" &lt;&lt; std::endl;</span>
<span class="keyword">return</span> <span class="identifier">efh_R_T</span><span class="special">();</span>
<span class="special">}</span>
<span class="special">};</span>
</pre>
<p>
Similar code is used in the related functors
</p>
<pre class="programlisting"><span class="identifier">enum_from_to</span>
<span class="identifier">filter</span>
</pre>
<h3>
<a name="phoenix.lazy_list.implementation_details.h8"></a>
<span><a name="phoenix.lazy_list.implementation_details.conclusion"></a></span><a class="link" href="implementation_details.html#phoenix.lazy_list.implementation_details.conclusion">Conclusion</a>
</h3>
<p>
These implementation mechanisms have been carried through consistently in
the implementation.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="exceptions.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../lazy_list.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="testing.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,47 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Testing</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../lazy_list.html" title="Lazy List">
<link rel="prev" href="implementation_details.html" title="Implementation Details">
<link rel="next" href="where_next_.html" title="Where Next?">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="implementation_details.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../lazy_list.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="where_next_.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.lazy_list.testing"></a><a class="link" href="testing.html" title="Testing">Testing</a>
</h3></div></div></div>
<p>
Several tests are currently on develop and master in time for Boost 1.58.0.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="implementation_details.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../lazy_list.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="where_next_.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,66 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Tutorial with examples</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../lazy_list.html" title="Lazy List">
<link rel="prev" href="what_is_provided.html" title="What is provided">
<link rel="next" href="tutorial_with_examples/arithmetic_functions.html" title="Arithmetic functions">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="what_is_provided.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../lazy_list.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="tutorial_with_examples/arithmetic_functions.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.lazy_list.tutorial_with_examples"></a><a class="link" href="tutorial_with_examples.html" title="Tutorial with examples">Tutorial with
examples</a>
</h3></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="tutorial_with_examples/arithmetic_functions.html">Arithmetic
functions</a></span></dt>
<dt><span class="section"><a href="tutorial_with_examples/list_generation.html">List
Generation</a></span></dt>
</dl></div>
<p>
These examples require the following header:
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">function</span><span class="special">/</span><span class="identifier">lazy_prelude</span><span class="special">.</span><span class="identifier">hpp</span>
</pre>
<p>
The following statements should be in the execution code:
</p>
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">arg_names</span><span class="special">::</span><span class="identifier">arg1</span><span class="special">;</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">arg_names</span><span class="special">::</span><span class="identifier">arg2</span><span class="special">;</span>
<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">;</span>
</pre>
<p>
To be developed.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="what_is_provided.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../lazy_list.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="tutorial_with_examples/arithmetic_functions.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,80 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Arithmetic functions</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../tutorial_with_examples.html" title="Tutorial with examples">
<link rel="prev" href="../tutorial_with_examples.html" title="Tutorial with examples">
<link rel="next" href="list_generation.html" title="List Generation">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../tutorial_with_examples.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../tutorial_with_examples.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="list_generation.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.lazy_list.tutorial_with_examples.arithmetic_functions"></a><a class="link" href="arithmetic_functions.html" title="Arithmetic functions">Arithmetic
functions</a>
</h4></div></div></div>
<p>
Assume the values
</p>
<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">a</span> <span class="special">=</span> <span class="number">123</span><span class="special">;</span>
<span class="keyword">int</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">256</span><span class="special">;</span>
</pre>
<p>
The following are all valid expressions returning a+b
</p>
<pre class="programlisting"><span class="identifier">plus</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">)(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">)</span>
<span class="identifier">plus</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">b</span><span class="special">)(</span><span class="identifier">a</span><span class="special">)</span>
<span class="identifier">plus</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">)(</span><span class="identifier">a</span><span class="special">,</span><span class="identifier">b</span><span class="special">)</span>
<span class="identifier">plus</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">arg1</span><span class="special">)(</span><span class="identifier">b</span><span class="special">)</span>
<span class="identifier">plus</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">)()</span>
</pre>
<p>
The expressions can be combined like this
</p>
<pre class="programlisting"><span class="identifier">plus</span><span class="special">(</span><span class="identifier">minus</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">),</span><span class="identifier">b</span><span class="special">)()</span>
<span class="identifier">plus</span><span class="special">(</span><span class="identifier">minus</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">b</span><span class="special">),</span><span class="identifier">b</span><span class="special">)(</span><span class="identifier">a</span><span class="special">)</span>
<span class="identifier">plus</span><span class="special">(</span><span class="identifier">minus</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">),</span><span class="identifier">b</span><span class="special">)(</span><span class="identifier">a</span><span class="special">,</span><span class="identifier">b</span><span class="special">)</span>
<span class="identifier">plus</span><span class="special">(</span><span class="identifier">minus</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">),</span><span class="identifier">arg2</span><span class="special">)(</span><span class="identifier">a</span><span class="special">,</span><span class="identifier">b</span><span class="special">)</span>
</pre>
<p>
Other numerical operators can be used like this
</p>
<pre class="programlisting"><span class="identifier">multiplies</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span><span class="identifier">arg2</span><span class="special">)(</span><span class="number">3</span><span class="special">,</span><span class="number">6</span><span class="special">)</span>
<span class="identifier">divides</span><span class="special">(</span><span class="identifier">arg2</span><span class="special">,</span><span class="identifier">arg1</span><span class="special">)(</span><span class="number">3</span><span class="special">,</span><span class="number">6</span><span class="special">)</span>
<span class="identifier">modulus</span><span class="special">(</span><span class="identifier">arg2</span><span class="special">,</span><span class="identifier">arg1</span><span class="special">)(</span><span class="number">4</span><span class="special">,</span><span class="number">6</span><span class="special">)</span>
<span class="identifier">min</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span><span class="identifier">arg2</span><span class="special">)(</span><span class="number">4</span><span class="special">,</span><span class="number">6</span><span class="special">)</span>
<span class="identifier">max</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span><span class="identifier">arg2</span><span class="special">)(</span><span class="number">4</span><span class="special">,</span><span class="number">6</span><span class="special">)</span>
<span class="identifier">inc</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">)(</span><span class="identifier">a</span><span class="special">)</span>
<span class="identifier">dec</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">)(</span><span class="identifier">a</span><span class="special">)</span>
<span class="identifier">negate</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">)(</span><span class="identifier">a</span><span class="special">)</span>
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../tutorial_with_examples.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../tutorial_with_examples.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="list_generation.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,66 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>List Generation</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../tutorial_with_examples.html" title="Tutorial with examples">
<link rel="prev" href="arithmetic_functions.html" title="Arithmetic functions">
<link rel="next" href="../exceptions.html" title="Exceptions">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="arithmetic_functions.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../tutorial_with_examples.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../exceptions.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.lazy_list.tutorial_with_examples.list_generation"></a><a class="link" href="list_generation.html" title="List Generation">List
Generation</a>
</h4></div></div></div>
<p>
One of the most interesting capabilities of <a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>
is the generation of infinite lazy lists which are evaluated only at need.
The most simple example of this is
</p>
<pre class="programlisting"><span class="identifier">enum_from</span><span class="special">(</span><span class="number">1</span><span class="special">)</span>
</pre>
<p>
which returns the generator for integers 1,2,3,..... infinity.
</p>
<pre class="programlisting"><span class="identifier">take</span><span class="special">(</span><span class="number">4</span><span class="special">,</span><span class="identifier">enum_from</span><span class="special">(</span><span class="number">1</span><span class="special">))</span>
</pre>
<p>
returns a list of the first 4 of the list.
</p>
<pre class="programlisting"><span class="identifier">at</span><span class="special">(</span><span class="identifier">enum_from</span><span class="special">(</span><span class="number">1</span><span class="special">),</span><span class="number">3</span><span class="special">)</span>
</pre>
<p>
returns the fourth member using zero indexed access. Both of the lists
returned are lazy and only evaluated when the list members are accessed.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="arithmetic_functions.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../tutorial_with_examples.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../exceptions.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,180 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>What is provided</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../lazy_list.html" title="Lazy List">
<link rel="prev" href="background.html" title="Background">
<link rel="next" href="tutorial_with_examples.html" title="Tutorial with examples">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="background.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../lazy_list.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="tutorial_with_examples.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.lazy_list.what_is_provided"></a><a class="link" href="what_is_provided.html" title="What is provided">What is provided</a>
</h3></div></div></div>
<p>
Functions are provided to build and manipulate objects of the list type
</p>
<pre class="programlisting"><span class="identifier">list</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span>
</pre>
<h3>
<a name="phoenix.lazy_list.what_is_provided.h0"></a>
<span><a name="phoenix.lazy_list.what_is_provided.namespace_and_header"></a></span><a class="link" href="what_is_provided.html#phoenix.lazy_list.what_is_provided.namespace_and_header">Namespace
and header</a>
</h3>
<p>
The functions are in the namespace
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span>
</pre>
<p>
defined by the header file
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">function</span><span class="special">/</span><span class="identifier">lazy_prelude</span><span class="special">.</span><span class="identifier">hpp</span>
</pre>
<p>
which includes all other needed headers. It is not currently included in
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">function</span><span class="special">.</span><span class="identifier">hpp</span>
</pre>
<p>
so it must be explicitly included to use these types and functions.
</p>
<h3>
<a name="phoenix.lazy_list.what_is_provided.h1"></a>
<span><a name="phoenix.lazy_list.what_is_provided.integration_with_boost_phoenix"></a></span><a class="link" href="what_is_provided.html#phoenix.lazy_list.what_is_provided.integration_with_boost_phoenix">Integration
with Boost Phoenix</a>
</h3>
<p>
The functions are defined by boost::phoenix::function which means that they
work with phoenix arguments such as 'arg1'. They have been defined in such
a way that when needed they can be passed as arguments to other functions.
</p>
<h2>
<a name="phoenix.lazy_list.what_is_provided.h2"></a>
<span><a name="phoenix.lazy_list.what_is_provided.lazy_list_type"></a></span><a class="link" href="what_is_provided.html#phoenix.lazy_list.what_is_provided.lazy_list_type">Lazy
List Type</a>
</h2>
<pre class="programlisting"><span class="identifier">list</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="special">(</span><span class="identifier">where</span> <span class="identifier">T</span> <span class="identifier">is</span> <span class="identifier">the</span> <span class="identifier">element</span> <span class="identifier">type</span><span class="special">)</span>
</pre>
<h2>
<a name="phoenix.lazy_list.what_is_provided.h3"></a>
<span><a name="phoenix.lazy_list.what_is_provided.functions"></a></span><a class="link" href="what_is_provided.html#phoenix.lazy_list.what_is_provided.functions">Functions</a>
</h2>
<p>
The functions are grouped as follows:
</p>
<h3>
<a name="phoenix.lazy_list.what_is_provided.h4"></a>
<span><a name="phoenix.lazy_list.what_is_provided.arithmetic_functions"></a></span><a class="link" href="what_is_provided.html#phoenix.lazy_list.what_is_provided.arithmetic_functions">Arithmetic
functions</a>
</h3>
<pre class="programlisting"><span class="identifier">plus</span>
<span class="identifier">minus</span>
<span class="identifier">multiplies</span>
<span class="identifier">divides</span>
<span class="identifier">modulus</span>
<span class="identifier">negate</span>
</pre>
<h3>
<a name="phoenix.lazy_list.what_is_provided.h5"></a>
<span><a name="phoenix.lazy_list.what_is_provided.boolean_functions"></a></span><a class="link" href="what_is_provided.html#phoenix.lazy_list.what_is_provided.boolean_functions">Boolean functions</a>
</h3>
<pre class="programlisting"><span class="identifier">equal</span>
<span class="identifier">not_equal</span>
<span class="identifier">greater</span>
<span class="identifier">less</span>
<span class="identifier">greater_equal</span>
<span class="identifier">less_equal</span>
</pre>
<h3>
<a name="phoenix.lazy_list.what_is_provided.h6"></a>
<span><a name="phoenix.lazy_list.what_is_provided.logical_functions"></a></span><a class="link" href="what_is_provided.html#phoenix.lazy_list.what_is_provided.logical_functions">Logical functions</a>
</h3>
<pre class="programlisting"><span class="identifier">logical_and</span>
<span class="identifier">logical_or</span>
<span class="identifier">logical_not</span>
</pre>
<h3>
<a name="phoenix.lazy_list.what_is_provided.h7"></a>
<span><a name="phoenix.lazy_list.what_is_provided.operational_functions"></a></span><a class="link" href="what_is_provided.html#phoenix.lazy_list.what_is_provided.operational_functions">Operational
functions</a>
</h3>
<pre class="programlisting"><span class="identifier">apply</span>
<span class="identifier">until</span>
<span class="identifier">until2</span>
<span class="identifier">max</span>
<span class="identifier">min</span>
<span class="identifier">inc</span>
<span class="identifier">dec</span>
<span class="identifier">make_pair</span>
</pre>
<h3>
<a name="phoenix.lazy_list.what_is_provided.h8"></a>
<span><a name="phoenix.lazy_list.what_is_provided.logical_predicates"></a></span><a class="link" href="what_is_provided.html#phoenix.lazy_list.what_is_provided.logical_predicates">Logical predicates</a>
</h3>
<pre class="programlisting"><span class="identifier">odd</span>
<span class="identifier">even</span>
</pre>
<h3>
<a name="phoenix.lazy_list.what_is_provided.h9"></a>
<span><a name="phoenix.lazy_list.what_is_provided.list_functions"></a></span><a class="link" href="what_is_provided.html#phoenix.lazy_list.what_is_provided.list_functions">List
Functions</a>
</h3>
<pre class="programlisting"><span class="identifier">cons</span>
<span class="identifier">cat</span>
<span class="identifier">take</span>
<span class="identifier">drop</span>
<span class="identifier">last</span>
<span class="identifier">all_but_last</span>
<span class="identifier">at</span>
<span class="identifier">length</span>
<span class="identifier">filter</span>
</pre>
<h4>
<a name="phoenix.lazy_list.what_is_provided.h10"></a>
<span><a name="phoenix.lazy_list.what_is_provided.list_generation_functions"></a></span><a class="link" href="what_is_provided.html#phoenix.lazy_list.what_is_provided.list_generation_functions">List
Generation Functions</a>
</h4>
<pre class="programlisting"><span class="identifier">enum_from</span>
<span class="identifier">enum_from_to</span>
<span class="identifier">list_with</span>
</pre>
<h3>
<a name="phoenix.lazy_list.what_is_provided.h11"></a>
<span><a name="phoenix.lazy_list.what_is_provided.futher_functions"></a></span><a class="link" href="what_is_provided.html#phoenix.lazy_list.what_is_provided.futher_functions">Futher
functions</a>
</h3>
<p>
Further functions are in development from the resources available in <a href="http://cgi.di.uoa.gr/~smaragd/fc++/" target="_top">FC++</a>.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="background.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../lazy_list.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="tutorial_with_examples.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,47 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Where Next?</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../lazy_list.html" title="Lazy List">
<link rel="prev" href="testing.html" title="Testing">
<link rel="next" href="../maintenance.html" title="Maintenance">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="testing.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../lazy_list.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../maintenance.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.lazy_list.where_next_"></a><a class="link" href="where_next_.html" title="Where Next?">Where Next?</a>
</h3></div></div></div>
<p>
Further functions are going to be implemented and more examples provided.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="testing.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../lazy_list.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../maintenance.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,100 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Maintenance</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="prev" href="lazy_list/where_next_.html" title="Where Next?">
<link rel="next" href="maintenance/background.html" title="Background">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="lazy_list/where_next_.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="maintenance/background.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="phoenix.maintenance"></a><a class="link" href="maintenance.html" title="Maintenance">Maintenance</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="maintenance/background.html">Background</a></span></dt>
<dt><span class="section"><a href="maintenance/my_understanding_of_how_maintenance_works.html">My
Understanding of how maintenance works</a></span></dt>
<dt><span class="section"><a href="maintenance/method_in_use.html">Method in use</a></span></dt>
<dt><span class="section"><a href="maintenance/experience.html">Experience</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="maintenance/experience/maintenance_tools.html">Maintenance
Tools</a></span></dt>
<dt><span class="section"><a href="maintenance/experience/bugs_to_be_fixed.html">Bugs
to be fixed</a></span></dt>
<dt><span class="section"><a href="maintenance/experience/compilers.html">Compilers</a></span></dt>
</dl></dd>
</dl></div>
<p>
The experience of the maintenance of Boost Phoenix during 2014 and 2015.
</p>
<p>
This section is being used to set out the maintenance policy for Boost Phoenix
and how it is being carried out. One reason for doing this is that in January
2015 there is a lot of discussion within Boost about how best to do this. There
are also a number of issues for which the answers are not clear to me and I
am going to set those out here.
</p>
<p>
Phoenix is a complicated library and the current version 3 is built on two
other libraries <a href="http://www.boost.org/doc/libs/release/libs/proto/index.html" target="_top">Boost.Proto</a>
and <a href="http://www.boost.org/doc/libs/release/libs/fusion/index.html" target="_top">Boost.Fusion</a>
which are themselves quite complicated. Version 3 of Phoenix is a rebuilding
of the previous version using <a href="http://www.boost.org/doc/libs/release/libs/proto/index.html" target="_top">Boost.Proto</a>.
</p>
<p>
There are two ways to work with Phoenix.
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
One is to ignore the previous statement and assume everything works.
</li>
<li class="listitem">
The second is to understand the relationships between the libraries.
</li>
</ul></div>
<p>
Unfortunately, while most things now work, there are a number of subtle bugs
where things do not work as expected, and that is the challenge which is there
for the maintainer who did not write any version of the library.
</p>
<p>
The remainder of this page is found from the index above.
</p>
<p>
John Fletcher
</p>
<p>
January and February 2015
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="lazy_list/where_next_.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="maintenance/background.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,79 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Background</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../maintenance.html" title="Maintenance">
<link rel="prev" href="../maintenance.html" title="Maintenance">
<link rel="next" href="my_understanding_of_how_maintenance_works.html" title="My Understanding of how maintenance works">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../maintenance.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../maintenance.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="my_understanding_of_how_maintenance_works.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.maintenance.background"></a><a class="link" href="background.html" title="Background">Background</a>
</h3></div></div></div>
<p>
Almost exactly a year ago, Joel de Guzman asked me to take on the lead maintenance
of Boost Phoenix and I agreed to do so, not really knowing what I was taking
on. In the first few months I fixed a lot of the things which could be fixed
easily, while at the same time learning how to use git to keep things in
order. Then things got tougher as I started to meet things which are not
so easy to fix. I also found there were things I did not understand well
enough.
</p>
<p>
At the end of 2014 I came back to the task anew. In the meantime I have learned
a lot, particularly about Boost Fusion and Boost Proto which are used a lot
by Boost Phoenix. I have also learned how to edit the QuickBooks files and
regenerate them.
</p>
<p>
I have still not solved all the problems in Boost Phoenix. I think I am closing
in on some of the remaining ones. I now know that some of the problems in
Phoenix V3 were also present in Phoenix V2. This has changed the approach
to how to solve them as I know that the problems cannot be in the use of
Boost Proto as it was not used in V2.
</p>
<p>
I have made further progress during 2015 on understanding what the problems
are and how to avoid them or work around them. That has given me the confidence
to explore further applications of the code, which I expect will develop
a lot in the next few months.
</p>
<p>
I want in this document to share some of what I have been doing and how I
have solved some of the problems. One reason for doing this is that there
may be other people who are considering taking on library maintenance of
a library they did not themselves write. I hope I can make that easier for
people to do.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../maintenance.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../maintenance.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="my_understanding_of_how_maintenance_works.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,54 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Experience</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../maintenance.html" title="Maintenance">
<link rel="prev" href="method_in_use.html" title="Method in use">
<link rel="next" href="experience/maintenance_tools.html" title="Maintenance Tools">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="method_in_use.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../maintenance.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="experience/maintenance_tools.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.maintenance.experience"></a><a class="link" href="experience.html" title="Experience">Experience</a>
</h3></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="experience/maintenance_tools.html">Maintenance
Tools</a></span></dt>
<dt><span class="section"><a href="experience/bugs_to_be_fixed.html">Bugs
to be fixed</a></span></dt>
<dt><span class="section"><a href="experience/compilers.html">Compilers</a></span></dt>
</dl></div>
<p>
A summary of experience during testing of Boost Phoenix.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="method_in_use.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../maintenance.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="experience/maintenance_tools.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,55 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Bugs to be fixed</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../experience.html" title="Experience">
<link rel="prev" href="maintenance_tools.html" title="Maintenance Tools">
<link rel="next" href="compilers.html" title="Compilers">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="maintenance_tools.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../experience.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="compilers.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.maintenance.experience.bugs_to_be_fixed"></a><a class="link" href="bugs_to_be_fixed.html" title="Bugs to be fixed">Bugs
to be fixed</a>
</h4></div></div></div>
<p>
The bugs to be fixed have come from several sources.
</p>
<p>
One type of bug which has been very difficult to understand has been that
some test cases failed when compiled with optimisation and not without
it. I now believe that this is related to the use of references in the
arguments passed back, and I have one test where the cure is demonstrated,
lazy_make_pair_tests.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="maintenance_tools.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../experience.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="compilers.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,102 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Compilers</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../experience.html" title="Experience">
<link rel="prev" href="bugs_to_be_fixed.html" title="Bugs to be fixed">
<link rel="next" href="../../wrap_up.html" title="Wrap Up">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="bugs_to_be_fixed.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../experience.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../../wrap_up.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.maintenance.experience.compilers"></a><a class="link" href="compilers.html" title="Compilers">Compilers</a>
</h4></div></div></div>
<p>
I have been attempting to understand the differences between compilers
and environments when running tests on Boost Phoenix.
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
Some environments are limited in the memory available for testing and
I have broken some large tests into smaller pieces.
</li>
<li class="listitem">
Some of the problems experienced in testing are specific to particular
compilers being used.
</li>
<li class="listitem">
Some problems have occurred with several more recent compilers.
</li>
<li class="listitem">
One problem is that I do not have access to all of the compilers used
in the tests or by users.
<div class="itemizedlist"><ul class="itemizedlist" type="circle">
<li class="listitem">
My system is <a href="http://www.ubuntu.com/" target="_top">Ubuntu </a>
12.04
</li>
<li class="listitem">
I have expanded the compilers I have available to include the
following
</li>
<li class="listitem">
<a href="https://gcc.gnu.org" target="_top">gcc </a> 4.6, 4.8.2, 4.9.0
&amp; 4.9.2 (I will add 5.0 when released)
</li>
<li class="listitem">
<a href="http://clang.llvm.org" target="_top">Clang </a> 3.4, 3.5 &amp;
3.6 (pre-release in the last case)
</li>
</ul></div>
</li>
<li class="listitem">
The most difficult problems to diagnose have been some which occur
when the compilation uses optimization.
<div class="itemizedlist"><ul class="itemizedlist" type="circle">
<li class="listitem">
Some of the boost tests use optimization but most do not.
</li>
<li class="listitem">
It is not usually documented which tests are optimized.
</li>
<li class="listitem">
This means that a lot of tests run there which fail when optimized.
</li>
<li class="listitem">
This has made the identification of the cause of the problems
more difficult.
</li>
</ul></div>
</li>
</ul></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="bugs_to_be_fixed.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../experience.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../../wrap_up.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,53 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Maintenance Tools</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../experience.html" title="Experience">
<link rel="prev" href="../experience.html" title="Experience">
<link rel="next" href="bugs_to_be_fixed.html" title="Bugs to be fixed">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../experience.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../experience.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bugs_to_be_fixed.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.maintenance.experience.maintenance_tools"></a><a class="link" href="maintenance_tools.html" title="Maintenance Tools">Maintenance
Tools</a>
</h4></div></div></div>
<p>
My experience has been that not all the tools and knowledge to be a maintainer
are available in one place to a new maintainer. A lot of things which are
well known to experienced maintainers are just not readily available. In
some cases they are buried in the detailed manuals of several different
tools. One reason for writing up my experience as a maintainer to help
others.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../experience.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../experience.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bugs_to_be_fixed.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,72 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Method in use</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../maintenance.html" title="Maintenance">
<link rel="prev" href="my_understanding_of_how_maintenance_works.html" title="My Understanding of how maintenance works">
<link rel="next" href="experience.html" title="Experience">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="my_understanding_of_how_maintenance_works.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../maintenance.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="experience.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.maintenance.method_in_use"></a><a class="link" href="method_in_use.html" title="Method in use">Method in use</a>
</h3></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
I have been using the <a href="http://nvie.com/posts/a-successful-git-branching-model/" target="_top">git
branching model</a> to maintain the Boost Phoenix.
</li>
<li class="listitem">
I have been making most of the changes on branch develop or on branches
from it.
<div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem">
I test the changes on the develop branch.
</li></ul></div>
</li>
<li class="listitem">
When I want to move things from develop to master I first branch from
develop a new branch which I give a version number of my own within Phoenix.
<div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem">
I can then test that before merging it into master.
</li></ul></div>
</li>
<li class="listitem">
I now also have a separate branch for developing and testing documentation
changes.
<div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem">
I move selected changes from documentation onto the develop branch
and then onto master branch.
</li></ul></div>
</li>
</ul></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="my_understanding_of_how_maintenance_works.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../maintenance.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="experience.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,82 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>My Understanding of how maintenance works</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../maintenance.html" title="Maintenance">
<link rel="prev" href="background.html" title="Background">
<link rel="next" href="method_in_use.html" title="Method in use">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="background.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../maintenance.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="method_in_use.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.maintenance.my_understanding_of_how_maintenance_works"></a><a class="link" href="my_understanding_of_how_maintenance_works.html" title="My Understanding of how maintenance works">My
Understanding of how maintenance works</a>
</h3></div></div></div>
<p>
There has been some discussion on the mailing list of how best to get patches
available to users of libraries. This is the understanding I have been using.
I posted this and have had no comments on it.
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
Maintainers can have write access to the particular library for which
they have responsibility. This includes all the branches and in particular
both develop and master.
</li>
<li class="listitem">
It is up to the maintainer to put patches and tests onto develop and
see whether there are any remaining problems.
</li>
<li class="listitem">
It is then up to the maintainer to move the patches and tests from develop
to master.
<div class="itemizedlist"><ul class="itemizedlist" type="circle">
<li class="listitem">
This does not have to wait for a release of Boost.
</li>
<li class="listitem">
It can be done any time and at some point master will then become
the next release.
</li>
</ul></div>
</li>
<li class="listitem">
I do not think that develop is moved to master in any other way. It is
the maintainer who will know when that is the correct action.
</li>
</ul></div>
<p>
If there is more than one maintainer then any of them can do this. Each will
be able to see what has happened from the git log.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="background.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../maintenance.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="method_in_use.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,102 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Modules</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="prev" href="actor.html" title="Actor">
<link rel="next" href="modules/core.html" title="Core">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="actor.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="modules/core.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="phoenix.modules"></a><a class="link" href="modules.html" title="Modules">Modules</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="modules/core.html">Core</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="modules/core/values.html">Values</a></span></dt>
<dt><span class="section"><a href="modules/core/references.html">References</a></span></dt>
<dt><span class="section"><a href="modules/core/arguments.html">Arguments</a></span></dt>
<dt><span class="section"><a href="modules/core/nothing.html">Nothing</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="modules/function.html">Function</a></span></dt>
<dd><dl><dt><span class="section"><a href="modules/function/adapting_functions.html">Adapting
Functions</a></span></dt></dl></dd>
<dt><span class="section"><a href="modules/operator.html">Operator</a></span></dt>
<dt><span class="section"><a href="modules/statement.html">Statement</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="modules/statement/block_statement.html">Block Statement</a></span></dt>
<dt><span class="section"><a href="modules/statement/if__statement.html">if_ Statement</a></span></dt>
<dt><span class="section"><a href="modules/statement/___if_else_____statement.html">if_else_ Statement</a></span></dt>
<dt><span class="section"><a href="modules/statement/switch__statement.html">switch_
Statement</a></span></dt>
<dt><span class="section"><a href="modules/statement/while__statement.html">while_
Statement</a></span></dt>
<dt><span class="section"><a href="modules/statement/___do_while_____statement.html">do_while_ Statement</a></span></dt>
<dt><span class="section"><a href="modules/statement/for_statement.html">for_ Statement</a></span></dt>
<dt><span class="section"><a href="modules/statement/try__catch__statement.html">try_
catch_ Statement</a></span></dt>
<dt><span class="section"><a href="modules/statement/throw_.html">throw_</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="modules/object.html">Object</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="modules/object/construction.html">Construction</a></span></dt>
<dt><span class="section"><a href="modules/object/new.html">New</a></span></dt>
<dt><span class="section"><a href="modules/object/delete.html">Delete</a></span></dt>
<dt><span class="section"><a href="modules/object/casts.html">Casts</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="modules/scope.html">Scope</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="modules/scope/local_variables.html">Local Variables</a></span></dt>
<dt><span class="section"><a href="modules/scope/let.html">let</a></span></dt>
<dt><span class="section"><a href="modules/scope/lambda.html">lambda</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="modules/bind.html">Bind</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="modules/bind/binding_function_objects.html">Binding
Function Objects</a></span></dt>
<dt><span class="section"><a href="modules/bind/binding_functions.html">Binding Functions</a></span></dt>
<dt><span class="section"><a href="modules/bind/binding_member_functions.html">Binding
Member Functions</a></span></dt>
<dt><span class="section"><a href="modules/bind/binding_member_variables.html">Binding
Member Variables</a></span></dt>
<dt><span class="section"><a href="modules/bind/compatibility_with_boost_bind.html">Compatibility
with Boost.Bind</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="modules/stl.html">STL</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="modules/stl/container.html">Container</a></span></dt>
<dt><span class="section"><a href="modules/stl/algorithm.html">Algorithm</a></span></dt>
</dl></dd>
</dl></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="actor.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="modules/core.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,81 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Bind</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../modules.html" title="Modules">
<link rel="prev" href="scope/lambda.html" title="lambda">
<link rel="next" href="bind/binding_function_objects.html" title="Binding Function Objects">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="scope/lambda.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../modules.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bind/binding_function_objects.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.modules.bind"></a><a class="link" href="bind.html" title="Bind">Bind</a>
</h3></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="bind/binding_function_objects.html">Binding
Function Objects</a></span></dt>
<dt><span class="section"><a href="bind/binding_functions.html">Binding Functions</a></span></dt>
<dt><span class="section"><a href="bind/binding_member_functions.html">Binding
Member Functions</a></span></dt>
<dt><span class="section"><a href="bind/binding_member_variables.html">Binding
Member Variables</a></span></dt>
<dt><span class="section"><a href="bind/compatibility_with_boost_bind.html">Compatibility
with Boost.Bind</a></span></dt>
</dl></div>
<p>
<span class="emphasis"><em>Binding</em></span> is the act of tying together a function to some
arguments for deferred (lazy) evaluation. Named <a class="link" href="function.html" title="Function">lazy
functions</a> require a bit of typing. Unlike (unnamed) lambda expressions,
we need to write a functor somewhere offline, detached from the call site.
If you wish to transform a plain function, member function or member variable
to a lambda expression, <code class="computeroutput"><span class="identifier">bind</span></code>
is your friend.
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
Take note that binding functions, member functions or member variables
is monomorphic. Rather than binding functions, the preferred way is to
write true generic and polymorphic <a class="link" href="function.html" title="Function">lazy
functions</a>.
</p></td></tr>
</table></div>
<p>
There is a set of overloaded <code class="computeroutput"><span class="identifier">bind</span></code>
template functions. Each <code class="computeroutput"><span class="identifier">bind</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
function generates a suitable binder object.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="scope/lambda.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../modules.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bind/binding_function_objects.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,57 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Binding Function Objects</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../bind.html" title="Bind">
<link rel="prev" href="../bind.html" title="Bind">
<link rel="next" href="binding_functions.html" title="Binding Functions">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../bind.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bind.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="binding_functions.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.modules.bind.binding_function_objects"></a><a class="link" href="binding_function_objects.html" title="Binding Function Objects">Binding
Function Objects</a>
</h4></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">bind</span><span class="special">/</span><span class="identifier">bind_function_object</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<p>
Binding function objects serves two purposes: * Partial function application
* Quick adaption of already existing function objects
</p>
<p>
In order to deduce the return type of the function object, it has to implement
the <a href="http://www.boost.org/doc/libs/release/libs/utility/utility.htm#result_of" target="_top">Boost.Result
Of</a> protocol. If the bound function object is polymorphic, the resulting
binding object is polymorphic.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../bind.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bind.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="binding_functions.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,70 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Binding Functions</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../bind.html" title="Bind">
<link rel="prev" href="binding_function_objects.html" title="Binding Function Objects">
<link rel="next" href="binding_member_functions.html" title="Binding Member Functions">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="binding_function_objects.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bind.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="binding_member_functions.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.modules.bind.binding_functions"></a><a class="link" href="binding_functions.html" title="Binding Functions">Binding Functions</a>
</h4></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">bind</span><span class="special">/</span><span class="identifier">bind_function</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<p>
Example, given a function <code class="computeroutput"><span class="identifier">foo</span></code>:
</p>
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
<span class="special">{</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">n</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
Here's how the function <code class="computeroutput"><span class="identifier">foo</span></code>
may be bound:
</p>
<pre class="programlisting"><span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">foo</span><span class="special">,</span> <span class="identifier">arg1</span><span class="special">)</span>
</pre>
<p>
This is now a full-fledged expression that can finally be evaluated by
another function call invocation. A second function call will invoke the
actual <code class="computeroutput"><span class="identifier">foo</span></code> function. Example:
</p>
<pre class="programlisting"><span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">foo</span><span class="special">,</span> <span class="identifier">arg1</span><span class="special">)(</span><span class="number">4</span><span class="special">);</span>
</pre>
<p>
will print out "4".
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="binding_function_objects.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bind.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="binding_member_functions.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,73 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Binding Member Functions</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../bind.html" title="Bind">
<link rel="prev" href="binding_functions.html" title="Binding Functions">
<link rel="next" href="binding_member_variables.html" title="Binding Member Variables">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="binding_functions.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bind.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="binding_member_variables.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.modules.bind.binding_member_functions"></a><a class="link" href="binding_member_functions.html" title="Binding Member Functions">Binding
Member Functions</a>
</h4></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">bind</span><span class="special">/</span><span class="identifier">bind_member_function</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<p>
Binding member functions can be done similarly. A bound member function
takes in a pointer or reference to an object as the first argument. For
instance, given:
</p>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">xyz</span>
<span class="special">{</span>
<span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="keyword">int</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="special">};</span>
</pre>
<p>
<code class="computeroutput"><span class="identifier">xyz</span></code>'s <code class="computeroutput"><span class="identifier">foo</span></code>
member function can be bound as:
</p>
<pre class="programlisting"><span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">xyz</span><span class="special">::</span><span class="identifier">foo</span><span class="special">,</span> <span class="identifier">obj</span><span class="special">,</span> <span class="identifier">arg1</span><span class="special">)</span> <span class="comment">// obj is an xyz object</span>
</pre>
<p>
Take note that a lazy-member functions expects the first argument to be
a pointer or reference to an object. Both the object (reference or pointer)
and the arguments can be lazily bound. Examples:
</p>
<pre class="programlisting"><span class="identifier">xyz</span> <span class="identifier">obj</span><span class="special">;</span>
<span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">xyz</span><span class="special">::</span><span class="identifier">foo</span><span class="special">,</span> <span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">)</span> <span class="comment">// arg1.foo(arg2)</span>
<span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">xyz</span><span class="special">::</span><span class="identifier">foo</span><span class="special">,</span> <span class="identifier">obj</span><span class="special">,</span> <span class="identifier">arg1</span><span class="special">)</span> <span class="comment">// obj.foo(arg1)</span>
<span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">xyz</span><span class="special">::</span><span class="identifier">foo</span><span class="special">,</span> <span class="identifier">obj</span><span class="special">,</span> <span class="number">100</span><span class="special">)</span> <span class="comment">// obj.foo(100)</span>
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="binding_functions.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bind.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="binding_member_variables.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,75 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Binding Member Variables</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../bind.html" title="Bind">
<link rel="prev" href="binding_member_functions.html" title="Binding Member Functions">
<link rel="next" href="compatibility_with_boost_bind.html" title="Compatibility with Boost.Bind">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="binding_member_functions.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bind.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="compatibility_with_boost_bind.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.modules.bind.binding_member_variables"></a><a class="link" href="binding_member_variables.html" title="Binding Member Variables">Binding
Member Variables</a>
</h4></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">bind</span><span class="special">/</span><span class="identifier">bind_member_variable</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<p>
Member variables can also be bound much like member functions. Member variables
are not functions. Yet, like the <a class="link" href="../core/references.html" title="References"><code class="computeroutput"><span class="identifier">ref</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code></a>
that acts like a nullary function returning a reference to the data, member
variables, when bound, act like a unary function, taking in a pointer or
reference to an object as its argument and returning a reference to the
bound member variable. For instance, given:
</p>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">xyz</span>
<span class="special">{</span>
<span class="keyword">int</span> <span class="identifier">v</span><span class="special">;</span>
<span class="special">};</span>
</pre>
<p>
<code class="computeroutput"><span class="identifier">xyz</span><span class="special">::</span><span class="identifier">v</span></code> can be bound as:
</p>
<pre class="programlisting"><span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">xyz</span><span class="special">::</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">obj</span><span class="special">)</span> <span class="comment">// obj is an xyz object</span>
</pre>
<p>
As noted, just like the bound member function, a bound member variable
also expects the first (and only) argument to be a pointer or reference
to an object. The object (reference or pointer) can be lazily bound. Examples:
</p>
<pre class="programlisting"><span class="identifier">xyz</span> <span class="identifier">obj</span><span class="special">;</span>
<span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">xyz</span><span class="special">::</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">arg1</span><span class="special">)</span> <span class="comment">// arg1.v</span>
<span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">xyz</span><span class="special">::</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">obj</span><span class="special">)</span> <span class="comment">// obj.v</span>
<span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">xyz</span><span class="special">::</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">arg1</span><span class="special">)(</span><span class="identifier">obj</span><span class="special">)</span> <span class="special">=</span> <span class="number">4</span> <span class="comment">// obj.v = 4</span>
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="binding_member_functions.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bind.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="compatibility_with_boost_bind.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,55 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Compatibility with Boost.Bind</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../bind.html" title="Bind">
<link rel="prev" href="binding_member_variables.html" title="Binding Member Variables">
<link rel="next" href="../stl.html" title="STL">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="binding_member_variables.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bind.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../stl.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.modules.bind.compatibility_with_boost_bind"></a><a class="link" href="compatibility_with_boost_bind.html" title="Compatibility with Boost.Bind">Compatibility
with Boost.Bind</a>
</h4></div></div></div>
<p>
<code class="computeroutput"><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">bind</span></code> passes the older testcases of the
Boost.Bind library. For those cases it is completely compatible and interchangeable.
Some newer cases have been added to Boost.Bind in 2015 and compatibility
in those cases is not guaranteed.
</p>
<p>
Further tests are needed to check compatibility with std::tr1::bind and
std::bind from the C++11 standard.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="binding_member_variables.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bind.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../stl.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,60 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Core</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../modules.html" title="Modules">
<link rel="prev" href="../modules.html" title="Modules">
<link rel="next" href="core/values.html" title="Values">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../modules.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../modules.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="core/values.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.modules.core"></a><a class="link" href="core.html" title="Core">Core</a>
</h3></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="core/values.html">Values</a></span></dt>
<dt><span class="section"><a href="core/references.html">References</a></span></dt>
<dt><span class="section"><a href="core/arguments.html">Arguments</a></span></dt>
<dt><span class="section"><a href="core/nothing.html">Nothing</a></span></dt>
</dl></div>
<p>
Actors are composed to create more complex actors in a tree-like hierarchy.
The primitives are atomic entities that are like the leaves in the tree.
Phoenix is extensible. New primitives can be added anytime. Right out of
the box, there are only a few primitives, these are all defined in the Core
module.
</p>
<p>
This section shall deal with these preset primitives.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../modules.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../modules.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="core/values.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,195 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Arguments</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../core.html" title="Core">
<link rel="prev" href="references.html" title="References">
<link rel="next" href="nothing.html" title="Nothing">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="references.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../core.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="nothing.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.modules.core.arguments"></a><a class="link" href="arguments.html" title="Arguments">Arguments</a>
</h4></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">argument</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<p>
We use an instance of:
</p>
<pre class="programlisting"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">argument</span><span class="special">&lt;</span><span class="identifier">N</span><span class="special">&gt;::</span><span class="identifier">type</span>
</pre>
<p>
to represent the Nth function argument. The argument placeholder acts as
an imaginary data-bin where a function argument will be placed.
</p>
<h6>
<a name="phoenix.modules.core.arguments.h0"></a>
<span><a name="phoenix.modules.core.arguments.predefined_arguments"></a></span><a class="link" href="arguments.html#phoenix.modules.core.arguments.predefined_arguments">Predefined
Arguments</a>
</h6>
<p>
There are a few predefined instances of <code class="computeroutput"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">argument</span><span class="special">&lt;</span><span class="identifier">N</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
named <code class="computeroutput"><span class="identifier">arg1</span></code>..<code class="computeroutput"><span class="identifier">argN</span></code>, and its <a href="http://www.boost.org/libs/lambda/doc/index.html" target="_top">BLL</a>
counterpart <code class="computeroutput"><span class="identifier">_1</span></code>..<code class="computeroutput"><span class="identifier">_N</span></code>. (where N is a predefined maximum).
</p>
<p>
Here are some sample preset definitions of <code class="computeroutput"><span class="identifier">arg1</span></code>..<code class="computeroutput"><span class="identifier">argN</span></code>
</p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">placeholders</span>
<span class="special">{</span>
<span class="identifier">expression</span><span class="special">::</span><span class="identifier">argument</span><span class="special">&lt;</span><span class="number">1</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span> <span class="identifier">arg1</span> <span class="special">=</span> <span class="special">{};</span>
<span class="identifier">expression</span><span class="special">::</span><span class="identifier">argument</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span> <span class="identifier">arg2</span> <span class="special">=</span> <span class="special">{};</span>
<span class="identifier">expression</span><span class="special">::</span><span class="identifier">argument</span><span class="special">&lt;</span><span class="number">3</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span> <span class="identifier">arg3</span> <span class="special">=</span> <span class="special">{};</span>
<span class="special">}</span>
</pre>
<p>
and its <a href="http://www.boost.org/libs/lambda/doc/index.html" target="_top">BLL</a>
<code class="computeroutput"><span class="identifier">_1</span></code>..<code class="computeroutput"><span class="identifier">_N</span></code>
style counterparts:
</p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">placeholders</span>
<span class="special">{</span>
<span class="identifier">expression</span><span class="special">::</span><span class="identifier">argument</span><span class="special">&lt;</span><span class="number">1</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span> <span class="identifier">_1</span> <span class="special">=</span> <span class="special">{};</span>
<span class="identifier">expression</span><span class="special">::</span><span class="identifier">argument</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span> <span class="identifier">_2</span> <span class="special">=</span> <span class="special">{};</span>
<span class="identifier">expression</span><span class="special">::</span><span class="identifier">argument</span><span class="special">&lt;</span><span class="number">3</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="keyword">const</span> <span class="identifier">_3</span> <span class="special">=</span> <span class="special">{};</span>
<span class="special">}</span>
</pre>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
You can set <code class="computeroutput"><span class="identifier">BOOST_PHOENIX_ARG_LIMIT</span></code>,
the predefined maximum placeholder index. By default, <code class="computeroutput"><span class="identifier">BOOST_PHOENIX_ARG_LIMIT</span></code>
is set to <code class="computeroutput"><span class="identifier">BOOST_PHOENIX_LIMIT</span></code>
(See <a class="link" href="../../actor.html" title="Actor">Actor</a>).
</p></td></tr>
</table></div>
<h6>
<a name="phoenix.modules.core.arguments.h1"></a>
<span><a name="phoenix.modules.core.arguments.user_defined_arguments"></a></span><a class="link" href="arguments.html#phoenix.modules.core.arguments.user_defined_arguments">User Defined
Arguments</a>
</h6>
<p>
When appropriate, you can define your own <code class="computeroutput"><span class="identifier">argument</span></code>
names. For example:
</p>
<pre class="programlisting"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">argument</span><span class="special">&lt;</span><span class="number">1</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">x</span><span class="special">;</span> <span class="comment">// note one based index</span>
</pre>
<p>
<code class="computeroutput"><span class="identifier">x</span></code> may now be used as a
parameter to a lazy function:
</p>
<pre class="programlisting"><span class="identifier">add</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="number">6</span><span class="special">)</span>
</pre>
<p>
which is equivalent to:
</p>
<pre class="programlisting"><span class="identifier">add</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="number">6</span><span class="special">)</span>
</pre>
<h6>
<a name="phoenix.modules.core.arguments.h2"></a>
<span><a name="phoenix.modules.core.arguments.evaluating_an_argument"></a></span><a class="link" href="arguments.html#phoenix.modules.core.arguments.evaluating_an_argument">Evaluating
an Argument</a>
</h6>
<p>
An argument, when evaluated, selects the Nth argument from the those passed
in by the client.
</p>
<p>
For example:
</p>
<pre class="programlisting"><span class="keyword">char</span> <span class="identifier">c</span> <span class="special">=</span> <span class="char">'A'</span><span class="special">;</span>
<span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">123</span><span class="special">;</span>
<span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">s</span> <span class="special">=</span> <span class="string">"Hello World"</span><span class="special">;</span>
<span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">arg1</span><span class="special">(</span><span class="identifier">c</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">endl</span><span class="special">;</span> <span class="comment">// Get the 1st argument: c</span>
<span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">arg1</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">s</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">endl</span><span class="special">;</span> <span class="comment">// Get the 1st argument: i</span>
<span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">arg2</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">s</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">endl</span><span class="special">;</span> <span class="comment">// Get the 2nd argument: s</span>
</pre>
<p>
will print out:
</p>
<pre class="programlisting"><span class="identifier">A</span>
<span class="number">123</span>
<span class="identifier">Hello</span> <span class="identifier">World</span>
</pre>
<h6>
<a name="phoenix.modules.core.arguments.h3"></a>
<span><a name="phoenix.modules.core.arguments.extra_arguments"></a></span><a class="link" href="arguments.html#phoenix.modules.core.arguments.extra_arguments">Extra
Arguments</a>
</h6>
<p>
In C and C++, a function can have extra arguments that are not at all used
by the function body itself. These extra arguments are simply ignored.
</p>
<p>
Phoenix also allows extra arguments to be passed. For example, recall our
original <code class="computeroutput"><span class="identifier">add</span></code> function:
</p>
<pre class="programlisting"><span class="identifier">add</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">)</span>
</pre>
<p>
We know now that partially applying this function results to a function
that expects 2 arguments. However, the library is a bit more lenient and
allows the caller to supply more arguments than is actually required. Thus,
<code class="computeroutput"><span class="identifier">add</span></code> actually allows 2
<span class="emphasis"><em>or more</em></span> arguments. For instance, with:
</p>
<pre class="programlisting"><span class="identifier">add</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">)(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">,</span> <span class="identifier">z</span><span class="special">)</span>
</pre>
<p>
the third argument <code class="computeroutput"><span class="identifier">z</span></code> is
ignored. Taking this further, in-between arguments are also ignored. Example:
</p>
<pre class="programlisting"><span class="identifier">add</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg5</span><span class="special">)(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">c</span><span class="special">,</span> <span class="identifier">d</span><span class="special">,</span> <span class="identifier">e</span><span class="special">)</span>
</pre>
<p>
Here, arguments b, c, and d are ignored. The function <code class="computeroutput"><span class="identifier">add</span></code>
takes in the first argument (<code class="computeroutput"><span class="identifier">arg1</span></code>)
and the fifth argument (<code class="computeroutput"><span class="identifier">arg5</span></code>).
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
There are a few reasons why enforcing strict arity is not desirable.
A case in point is the callback function. Typical callback functions
provide more information than is actually needed. Lambda functions are
often used as callbacks.
</p></td></tr>
</table></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="references.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../core.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="nothing.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,53 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Nothing</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../core.html" title="Core">
<link rel="prev" href="arguments.html" title="Arguments">
<link rel="next" href="../function.html" title="Function">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="arguments.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../core.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../function.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.modules.core.nothing"></a><a class="link" href="nothing.html" title="Nothing">Nothing</a>
</h4></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">nothing</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<p>
Finally, the <code class="computeroutput"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">null</span><span class="special">&lt;</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">void_</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
does nothing; (a "bum", if you will :-) ). There's a sole <code class="computeroutput"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">null</span><span class="special">&lt;</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">void_</span><span class="special">&gt;::</span><span class="identifier">type</span></code> instance named "nothing".
This actor is actually useful in situations where we don't want to do anything.
(See <a class="link" href="../statement/for_statement.html" title="for_ Statement">for_ Statement</a>
for example).
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="arguments.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../core.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../function.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,117 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>References</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../core.html" title="Core">
<link rel="prev" href="values.html" title="Values">
<link rel="next" href="arguments.html" title="Arguments">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="values.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../core.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="arguments.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.modules.core.references"></a><a class="link" href="references.html" title="References">References</a>
</h4></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">reference</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<p>
Values are immutable constants. Attempting to modify a value will result
in a compile time error. When we want the function to modify the parameter,
we use a reference instead. For instance, imagine a lazy function <code class="computeroutput"><span class="identifier">add_assign</span></code>:
</p>
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">add_assign</span><span class="special">(</span><span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">x</span> <span class="special">+=</span> <span class="identifier">y</span><span class="special">;</span> <span class="special">}</span> <span class="comment">// pseudo code</span>
</pre>
<p>
Here, we want the first function argument, x, to be mutable. Obviously,
we cannot write:
</p>
<pre class="programlisting"><span class="identifier">add_assign</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="comment">// error first argument is immutable</span>
</pre>
<p>
In C++, we can pass in a reference to a variable as the first argument
in our example above. Yet, by default, the library forces arguments passed
to partially applied functions to be immutable values (see <a class="link" href="values.html" title="Values">Values</a>).
To achieve our intent, we use:
</p>
<pre class="programlisting"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">reference</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span>
</pre>
<p>
This is similar to <code class="computeroutput"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">value</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
before but instead holds a reference to a variable.
</p>
<p>
We normally don't instantiate <code class="computeroutput"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">reference</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
objects directly. Instead we use:
</p>
<pre class="programlisting"><span class="identifier">ref</span><span class="special">(</span><span class="identifier">v</span><span class="special">)</span>
</pre>
<p>
For example (where <code class="computeroutput"><span class="identifier">i</span></code> is
an <code class="computeroutput"><span class="keyword">int</span></code> variable):
</p>
<pre class="programlisting"><span class="identifier">add_assign</span><span class="special">(</span><span class="identifier">ref</span><span class="special">(</span><span class="identifier">i</span><span class="special">),</span> <span class="number">2</span><span class="special">)</span>
</pre>
<h6>
<a name="phoenix.modules.core.references.h0"></a>
<span><a name="phoenix.modules.core.references.evaluating_a_reference"></a></span><a class="link" href="references.html#phoenix.modules.core.references.evaluating_a_reference">Evaluating
a Reference</a>
</h6>
<p>
References are actors. Hence, references can be evaluated. Such invocation
gives the reference's identity. Example:
</p>
<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">3</span><span class="special">;</span>
<span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">s</span> <span class="special">=</span> <span class="string">"Hello World"</span><span class="special">;</span>
<span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">ref</span><span class="special">(</span><span class="identifier">i</span><span class="special">)()</span> <span class="special">&lt;&lt;</span> <span class="identifier">ref</span><span class="special">(</span><span class="identifier">s</span><span class="special">)();</span>
</pre>
<p>
prints out "3 Hello World"
</p>
<h6>
<a name="phoenix.modules.core.references.h1"></a>
<span><a name="phoenix.modules.core.references.constant_references"></a></span><a class="link" href="references.html#phoenix.modules.core.references.constant_references">Constant
References</a>
</h6>
<p>
Another free function
</p>
<pre class="programlisting"><span class="identifier">cref</span><span class="special">(</span><span class="identifier">cv</span><span class="special">)</span>
</pre>
<p>
may also be used. <code class="computeroutput"><span class="identifier">cref</span><span class="special">(</span><span class="identifier">cv</span><span class="special">)</span></code>
creates an <code class="computeroutput"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">reference</span><span class="special">&lt;</span><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
object. This is similar to <code class="computeroutput"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">value</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
but when the data to be passed as argument to a function is heavy and expensive
to copy by value, the <code class="computeroutput"><span class="identifier">cref</span><span class="special">(</span><span class="identifier">cv</span><span class="special">)</span></code>
offers a lighter alternative.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="values.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../core.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="arguments.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,85 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Values</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../core.html" title="Core">
<link rel="prev" href="../core.html" title="Core">
<link rel="next" href="references.html" title="References">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../core.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../core.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="references.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.modules.core.values"></a><a class="link" href="values.html" title="Values">Values</a>
</h4></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">value</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<p>
Whenever we see a constant in a partially applied function, an
</p>
<pre class="programlisting"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">value</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span>
</pre>
<p>
(where T is the type of the constant) is automatically created for us.
For instance:
</p>
<pre class="programlisting"><span class="identifier">add</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="number">6</span><span class="special">)</span>
</pre>
<p>
Passing a second argument, <code class="computeroutput"><span class="number">6</span></code>,
an <code class="computeroutput"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">value</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span></code> is implicitly created behind the
scenes. This is also equivalent to <code class="computeroutput"><span class="identifier">add</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">val</span><span class="special">(</span><span class="number">6</span><span class="special">))</span></code>.
</p>
<pre class="programlisting"><span class="identifier">val</span><span class="special">(</span><span class="identifier">v</span><span class="special">)</span>
</pre>
<p>
generates an <code class="computeroutput"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">value</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
where <code class="computeroutput"><span class="identifier">T</span></code> is the type of
<code class="computeroutput"><span class="identifier">v</span></code>. In most cases, there's
no need to explicitly use <code class="computeroutput"><span class="identifier">val</span></code>,
but, as we'll see later on, there are situations where this is unavoidable.
</p>
<h3>
<a name="phoenix.modules.core.values.h0"></a>
<span><a name="phoenix.modules.core.values.evaluating_a_value"></a></span><a class="link" href="values.html#phoenix.modules.core.values.evaluating_a_value">Evaluating
a Value</a>
</h3>
<p>
Like arguments, values are also actors. As such, values can be evaluated.
Invoking a value gives the value's identity. Example:
</p>
<pre class="programlisting"><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">val</span><span class="special">(</span><span class="number">3</span><span class="special">)()</span> <span class="special">&lt;&lt;</span> <span class="identifier">val</span><span class="special">(</span><span class="string">"Hello World"</span><span class="special">)();</span>
</pre>
<p>
prints out "3 Hello World".
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../core.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../core.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="references.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,151 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Function</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../modules.html" title="Modules">
<link rel="prev" href="core/nothing.html" title="Nothing">
<link rel="next" href="function/adapting_functions.html" title="Adapting Functions">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="core/nothing.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../modules.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="function/adapting_functions.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.modules.function"></a><a class="link" href="function.html" title="Function">Function</a>
</h3></div></div></div>
<div class="toc"><dl><dt><span class="section"><a href="function/adapting_functions.html">Adapting
Functions</a></span></dt></dl></div>
<p>
The <code class="computeroutput"><span class="identifier">function</span></code> class template
provides a mechanism for implementing lazily evaluated functions. Syntactically,
a lazy function looks like an ordinary C/C++ function. The function call
looks familiar and feels the same as ordinary C++ functions. However, unlike
ordinary functions, the actual function execution is deferred.
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">function</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<p>
Unlike ordinary function pointers or functor objects that need to be explicitly
bound through the bind function (see <a class="link" href="bind.html" title="Bind">Bind</a>),
the argument types of these functions are automatically lazily bound.
</p>
<p>
In order to create a lazy function, we need to implement a model of the
<a href="http://www.boost.org/doc/libs/release/libs/fusion/doc/html/fusion/functional/concepts/poly.html" target="_top">Polymorphic
Function Object</a> concept. For a function that takes <code class="computeroutput"><span class="identifier">N</span></code> arguments, a model of <a href="http://www.boost.org/doc/libs/release/libs/fusion/doc/html/fusion/functional/concepts/poly.html" target="_top">Polymorphic
Function Object</a> must provide:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
An <code class="computeroutput"><span class="keyword">operator</span><span class="special">()</span></code>
that takes <code class="computeroutput"><span class="identifier">N</span></code> arguments,
and implements the function logic. This is also true for ordinary function
pointers.
</li>
<li class="listitem">
A nested metafunction <code class="computeroutput"><span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">Signature</span><span class="special">&gt;</span></code> or nested typedef <code class="computeroutput"><span class="identifier">result_type</span></code>,
following the <a href="http://www.boost.org/doc/libs/release/libs/utility/utility.htm#result_of" target="_top">Boost.Result
Of</a> Protocol
</li>
</ul></div>
<p>
For example, the following type implements the FunctionEval concept, in order
to provide a lazy factorial function:
</p>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">factorial_impl</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Sig</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">result</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">This</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Arg</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">This</span><span class="special">(</span><span class="identifier">Arg</span> <span class="keyword">const</span> <span class="special">&amp;)&gt;</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="identifier">Arg</span> <span class="identifier">type</span><span class="special">;</span>
<span class="special">};</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Arg</span><span class="special">&gt;</span>
<span class="identifier">Arg</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">Arg</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="special">(</span><span class="identifier">n</span> <span class="special">&lt;=</span> <span class="number">0</span><span class="special">)</span> <span class="special">?</span> <span class="number">1</span> <span class="special">:</span> <span class="identifier">n</span> <span class="special">*</span> <span class="special">(*</span><span class="keyword">this</span><span class="special">)(</span><span class="identifier">n</span><span class="special">-</span><span class="number">1</span><span class="special">);</span>
<span class="special">}</span>
<span class="special">};</span>
</pre>
<p>
(See <a href="../../../../example/factorial.cpp" target="_top">factorial.cpp</a>)
</p>
<p>
Having implemented the <code class="computeroutput"><span class="identifier">factorial_impl</span></code>
type, we can declare and instantiate a lazy <code class="computeroutput"><span class="identifier">factorial</span></code>
function this way:
</p>
<pre class="programlisting"><span class="identifier">function</span><span class="special">&lt;</span><span class="identifier">factorial_impl</span><span class="special">&gt;</span> <span class="identifier">factorial</span><span class="special">;</span>
</pre>
<p>
Invoking a lazy function such as <code class="computeroutput"><span class="identifier">factorial</span></code>
does not immediately execute the function object <code class="computeroutput"><span class="identifier">factorial_impl</span></code>.
Instead, an <a class="link" href="../actor.html" title="Actor">actor</a> object is created
and returned to the caller. Example:
</p>
<pre class="programlisting"><span class="identifier">factorial</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">)</span>
</pre>
<p>
does nothing more than return an actor. A second function call will invoke
the actual factorial function. Example:
</p>
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">factorial</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">)(</span><span class="number">4</span><span class="special">);</span>
</pre>
<p>
will print out "24".
</p>
<p>
Take note that in certain cases (e.g. for function objects with state), an
instance of the model of <a href="http://www.boost.org/doc/libs/release/libs/fusion/doc/html/fusion/functional/concepts/poly.html" target="_top">Polymorphic
Function Object</a> may be passed on to the constructor. Example:
</p>
<pre class="programlisting"><span class="identifier">function</span><span class="special">&lt;</span><span class="identifier">factorial_impl</span><span class="special">&gt;</span> <span class="identifier">factorial</span><span class="special">(</span><span class="identifier">ftor</span><span class="special">);</span>
</pre>
<p>
where ftor is an instance of factorial_impl (this is not necessary in this
case as <code class="computeroutput"><span class="identifier">factorial_impl</span></code> does
not require any state).
</p>
<div class="important"><table border="0" summary="Important">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../../doc/src/images/important.png"></td>
<th align="left">Important</th>
</tr>
<tr><td align="left" valign="top"><p>
Take care though when using function objects with state because they are
often copied repeatedly, and state may change in one of the copies, rather
than the original.
</p></td></tr>
</table></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="core/nothing.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../modules.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="function/adapting_functions.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,371 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Adapting Functions</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../function.html" title="Function">
<link rel="prev" href="../function.html" title="Function">
<link rel="next" href="../operator.html" title="Operator">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../function.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../function.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../operator.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.modules.function.adapting_functions"></a><a class="link" href="adapting_functions.html" title="Adapting Functions">Adapting
Functions</a>
</h4></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary">BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY</a></span></dt>
<dt><span class="section"><a href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function">BOOST_PHOENIX_ADAPT_FUNCTION</a></span></dt>
<dt><span class="section"><a href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary">BOOST_PHOENIX_ADAPT_CALLABLE_NULLARY</a></span></dt>
<dt><span class="section"><a href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable">BOOST_PHOENIX_ADAPT_CALLABLE</a></span></dt>
</dl></div>
<p>
If you want to adapt already existing functions or function objects it
will become a repetetive task. Therefor the following boilerplate macros
are provided to help you adapt already exsiting functions, thus reducing
the need to <a class="link" href="../bind.html" title="Bind">phoenix.modules.bind</a>
functions.
</p>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary"></a><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary" title="BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY">BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY</a>
</h5></div></div></div>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.h0"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.description"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.description">Description</a>
</h6>
<p>
<code class="computeroutput"><span class="identifier">BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY</span></code>
is a macro that can be used to generate all the necessary boilerplate
to make an arbitrary nullary function a lazy function.
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
These macros generate no global objects. The resulting lazy functions
are real functions that create the lazy function expression object
</p></td></tr>
</table></div>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.h1"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.synopsis"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.synopsis">Synopsis</a>
</h6>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY</span><span class="special">(</span>
<span class="identifier">RETURN_TYPE</span>
<span class="special">,</span> <span class="identifier">LAZY_FUNCTION</span>
<span class="special">,</span> <span class="identifier">FUNCTION</span>
<span class="special">)</span>
</pre>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.h2"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.semantics"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.semantics">Semantics</a>
</h6>
<p>
The above macro generates all necessary code to have a nullary lazy function
<code class="computeroutput"><span class="identifier">LAZY_FUNCTION</span></code> which calls
the nullary <code class="computeroutput"><span class="identifier">FUNCTION</span></code>
that has the return type <code class="computeroutput"><span class="identifier">RETURN_TYPE</span></code>
</p>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.h3"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.header"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.header">Header</a>
</h6>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">function</span><span class="special">/</span><span class="identifier">adapt_function</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.h4"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.example"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function_nullary.example">Example</a>
</h6>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">demo</span>
<span class="special">{</span>
<span class="keyword">int</span> <span class="identifier">foo</span><span class="special">()</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="number">42</span><span class="special">;</span>
<span class="special">}</span>
<span class="special">}</span>
<span class="identifier">BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY</span><span class="special">(</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">foo</span><span class="special">,</span> <span class="identifier">demo</span><span class="special">::</span><span class="identifier">foo</span><span class="special">)</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">placeholders</span><span class="special">::</span><span class="identifier">_1</span><span class="special">;</span>
<span class="identifier">assert</span><span class="special">((</span><span class="identifier">_1</span> <span class="special">+</span> <span class="identifier">foo</span><span class="special">())(</span><span class="number">1</span><span class="special">)</span> <span class="special">==</span> <span class="number">43</span><span class="special">);</span>
<span class="special">}</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function"></a><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function" title="BOOST_PHOENIX_ADAPT_FUNCTION">BOOST_PHOENIX_ADAPT_FUNCTION</a>
</h5></div></div></div>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.h0"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.description"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.description">Description</a>
</h6>
<p>
<code class="computeroutput"><span class="identifier">BOOST_PHOENIX_ADAPT_FUNCTION</span></code>
is a macro that can be used to generate all the necessary boilerplate
to make an arbitrary function a lazy function.
</p>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.h1"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.synopsis"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.synopsis">Synopsis</a>
</h6>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_ADAPT_FUNCTION</span><span class="special">(</span>
<span class="identifier">RETURN_TYPE</span>
<span class="special">,</span> <span class="identifier">LAZY_FUNCTION</span>
<span class="special">,</span> <span class="identifier">FUNCTION</span>
<span class="special">,</span> <span class="identifier">FUNCTION_ARITY</span>
<span class="special">)</span>
</pre>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.h2"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.semantics"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.semantics">Semantics</a>
</h6>
<p>
The above macro generates all necessary code to have a lazy function
<code class="computeroutput"><span class="identifier">LAZY_FUNCTION</span></code> which calls
<code class="computeroutput"><span class="identifier">FUNCTION</span></code> that has the
return type <code class="computeroutput"><span class="identifier">RETURN_TYPE</span></code>
with <code class="computeroutput"><span class="identifier">FUNCTION_ARITY</span></code> number
of arguments.
</p>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.h3"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.header"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.header">Header</a>
</h6>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">function</span><span class="special">/</span><span class="identifier">adapt_function</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.h4"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.example"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_function.example">Example</a>
</h6>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">demo</span>
<span class="special">{</span>
<span class="keyword">int</span> <span class="identifier">plus</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">a</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">b</span><span class="special">)</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">a</span> <span class="special">+</span> <span class="identifier">b</span><span class="special">;</span>
<span class="special">}</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="identifier">T</span>
<span class="identifier">plus</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">c</span><span class="special">)</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">a</span> <span class="special">+</span> <span class="identifier">b</span> <span class="special">+</span> <span class="identifier">c</span><span class="special">;</span>
<span class="special">}</span>
<span class="special">}</span>
<span class="identifier">BOOST_PHOENIX_ADAPT_FUNCTION</span><span class="special">(</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">plus</span><span class="special">,</span> <span class="identifier">demo</span><span class="special">::</span><span class="identifier">plus</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span>
<span class="identifier">BOOST_PHOENIX_ADAPT_FUNCTION</span><span class="special">(</span>
<span class="keyword">typename</span> <span class="identifier">remove_reference</span><span class="special">&lt;</span><span class="identifier">A0</span><span class="special">&gt;::</span><span class="identifier">type</span>
<span class="special">,</span> <span class="identifier">plus</span>
<span class="special">,</span> <span class="identifier">demo</span><span class="special">::</span><span class="identifier">plus</span>
<span class="special">,</span> <span class="number">3</span>
<span class="special">)</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">arg_names</span><span class="special">::</span><span class="identifier">arg1</span><span class="special">;</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">arg_names</span><span class="special">::</span><span class="identifier">arg2</span><span class="special">;</span>
<span class="keyword">int</span> <span class="identifier">a</span> <span class="special">=</span> <span class="number">123</span><span class="special">;</span>
<span class="keyword">int</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">256</span><span class="special">;</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">plus</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">)(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">plus</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">,</span> <span class="number">3</span><span class="special">)(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span><span class="special">+</span><span class="number">3</span><span class="special">);</span>
<span class="special">}</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary"></a><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary" title="BOOST_PHOENIX_ADAPT_CALLABLE_NULLARY">BOOST_PHOENIX_ADAPT_CALLABLE_NULLARY</a>
</h5></div></div></div>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.h0"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.description"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.description">Description</a>
</h6>
<p>
<code class="computeroutput"><span class="identifier">BOOST_PHOENIX_ADAPT_CALLABLE_NULLARY</span></code>
is a macro that can be used to generate all the necessary boilerplate
to make an arbitrary nullary function object a lazy function.
</p>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.h1"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.synopsis"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.synopsis">Synopsis</a>
</h6>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_ADAPT_CALLABLE_NULLARY</span><span class="special">(</span>
<span class="identifier">LAZY_FUNCTION</span>
<span class="special">,</span> <span class="identifier">CALLABLE</span>
<span class="special">)</span>
</pre>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.h2"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.semantics"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.semantics">Semantics</a>
</h6>
<p>
The above macro generates all necessary code to create <code class="computeroutput"><span class="identifier">LAZY_FUNCTION</span></code> which creates a lazy
function object that represents a nullary call to <code class="computeroutput"><span class="identifier">CALLABLE</span></code>.
The return type is specified by <code class="computeroutput"><span class="identifier">CALLABLE</span></code>
conforming to the <a href="http://www.boost.org/doc/libs/release/libs/utility/utility.htm#result_of" target="_top">Boost.Result
Of</a> protocol.
</p>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.h3"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.header"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.header">Header</a>
</h6>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">function</span><span class="special">/</span><span class="identifier">adapt_callable</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.h4"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.example"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable_nullary.example">Example</a>
</h6>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">demo</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">foo</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="keyword">int</span> <span class="identifier">result_type</span><span class="special">;</span>
<span class="identifier">result_type</span> <span class="keyword">operator</span><span class="special">()()</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="number">42</span><span class="special">;</span>
<span class="special">}</span>
<span class="special">}</span>
<span class="special">}</span>
<span class="identifier">BOOST_PHOENIX_ADAPT_CALLABLE_NULLARY</span><span class="special">(</span><span class="identifier">foo</span><span class="special">,</span> <span class="identifier">demo</span><span class="special">::</span><span class="identifier">foo</span><span class="special">)</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">placeholders</span><span class="special">::</span><span class="identifier">_1</span><span class="special">;</span>
<span class="identifier">assert</span><span class="special">((</span><span class="identifier">_1</span> <span class="special">+</span> <span class="identifier">foo</span><span class="special">())(</span><span class="number">1</span><span class="special">)</span> <span class="special">==</span> <span class="number">43</span><span class="special">);</span>
<span class="special">}</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable"></a><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable" title="BOOST_PHOENIX_ADAPT_CALLABLE">BOOST_PHOENIX_ADAPT_CALLABLE</a>
</h5></div></div></div>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.h0"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.description"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.description">Description</a>
</h6>
<p>
<code class="computeroutput"><span class="identifier">BOOST_PHOENIX_ADAPT_CALLABLE</span></code>
is a macro that can be used to generate all the necessary boilerplate
to make an arbitrary function object a lazy function.
</p>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.h1"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.synopsis"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.synopsis">Synopsis</a>
</h6>
<pre class="programlisting"><span class="identifier">BOOST_PHOENIX_ADAPT_CALLABLE</span><span class="special">(</span>
<span class="identifier">LAZY_FUNCTION</span>
<span class="special">,</span> <span class="identifier">FUNCTION_NAME</span>
<span class="special">,</span> <span class="identifier">FUNCTION_ARITY</span>
<span class="special">)</span>
</pre>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.h2"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.semantics"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.semantics">Semantics</a>
</h6>
<p>
The above macro generates all necessary code to create <code class="computeroutput"><span class="identifier">LAZY_FUNCTION</span></code> which creates a lazy
function object that represents a call to <code class="computeroutput"><span class="identifier">CALLABLE</span></code>
with <code class="computeroutput"><span class="identifier">FUNCTION_ARITY</span></code> arguments.
The return type is specified by <code class="computeroutput"><span class="identifier">CALLABLE</span></code>
conforming to the <a href="http://www.boost.org/doc/libs/release/libs/utility/utility.htm#result_of" target="_top">Boost.Result
Of</a> protocol.
</p>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.h3"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.header"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.header">Header</a>
</h6>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">function</span><span class="special">/</span><span class="identifier">adapt_callable</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<h6>
<a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.h4"></a>
<span><a name="phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.example"></a></span><a class="link" href="adapting_functions.html#phoenix.modules.function.adapting_functions.boost_phoenix_adapt_callable.example">Example</a>
</h6>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">demo</span>
<span class="special">{</span>
<span class="keyword">struct</span> <span class="identifier">plus</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Sig</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">result</span><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">This</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">This</span><span class="special">(</span><span class="identifier">A0</span><span class="special">,</span> <span class="identifier">A1</span><span class="special">)&gt;</span>
<span class="special">:</span> <span class="identifier">remove_reference</span><span class="special">&lt;</span><span class="identifier">A0</span><span class="special">&gt;</span>
<span class="special">{};</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">This</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A2</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">This</span><span class="special">(</span><span class="identifier">A0</span><span class="special">,</span> <span class="identifier">A1</span><span class="special">,</span> <span class="identifier">A2</span><span class="special">)&gt;</span>
<span class="special">:</span> <span class="identifier">remove_reference</span><span class="special">&lt;</span><span class="identifier">A0</span><span class="special">&gt;</span>
<span class="special">{};</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span><span class="special">&gt;</span>
<span class="identifier">A0</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">A0</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">a0</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">a1</span><span class="special">)</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">a0</span> <span class="special">+</span> <span class="identifier">a1</span><span class="special">;</span>
<span class="special">}</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">A2</span><span class="special">&gt;</span>
<span class="identifier">A0</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">A0</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">a0</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">a1</span><span class="special">,</span> <span class="identifier">A2</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">a2</span><span class="special">)</span> <span class="keyword">const</span>
<span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">a0</span> <span class="special">+</span> <span class="identifier">a1</span> <span class="special">+</span> <span class="identifier">a2</span><span class="special">;</span>
<span class="special">}</span>
<span class="special">};</span>
<span class="special">}</span>
<span class="identifier">BOOST_PHOENIX_ADAPT_CALLABLE</span><span class="special">(</span><span class="identifier">plus</span><span class="special">,</span> <span class="identifier">demo</span><span class="special">::</span><span class="identifier">plus</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span>
<span class="identifier">BOOST_PHOENIX_ADAPT_CALLABLE</span><span class="special">(</span><span class="identifier">plus</span><span class="special">,</span> <span class="identifier">demo</span><span class="special">::</span><span class="identifier">plus</span><span class="special">,</span> <span class="number">3</span><span class="special">)</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">arg_names</span><span class="special">::</span><span class="identifier">arg1</span><span class="special">;</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">arg_names</span><span class="special">::</span><span class="identifier">arg2</span><span class="special">;</span>
<span class="keyword">int</span> <span class="identifier">a</span> <span class="special">=</span> <span class="number">123</span><span class="special">;</span>
<span class="keyword">int</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">256</span><span class="special">;</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">plus</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">)(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">plus</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">,</span> <span class="number">3</span><span class="special">)(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span><span class="special">+</span><span class="number">3</span><span class="special">);</span>
<span class="special">}</span>
</pre>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../function.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../function.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../operator.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,56 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Object</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../modules.html" title="Modules">
<link rel="prev" href="statement/throw_.html" title="throw_">
<link rel="next" href="object/construction.html" title="Construction">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="statement/throw_.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../modules.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="object/construction.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="phoenix.modules.object"></a><a class="link" href="object.html" title="Object">Object</a>
</h3></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="object/construction.html">Construction</a></span></dt>
<dt><span class="section"><a href="object/new.html">New</a></span></dt>
<dt><span class="section"><a href="object/delete.html">Delete</a></span></dt>
<dt><span class="section"><a href="object/casts.html">Casts</a></span></dt>
</dl></div>
<p>
The Object module deals with object construction, destruction and conversion.
The module provides <span class="emphasis"><em>"lazy"</em></span> versions of C++'s
object constructor, <code class="computeroutput"><span class="keyword">new</span></code>, <code class="computeroutput"><span class="keyword">delete</span></code>, <code class="computeroutput"><span class="keyword">static_cast</span></code>,
<code class="computeroutput"><span class="keyword">dynamic_cast</span></code>, <code class="computeroutput"><span class="keyword">const_cast</span></code> and <code class="computeroutput"><span class="keyword">reinterpret_cast</span></code>.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="statement/throw_.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../modules.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="object/construction.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,72 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Casts</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../object.html" title="Object">
<link rel="prev" href="delete.html" title="Delete">
<link rel="next" href="../scope.html" title="Scope">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="delete.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../object.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../scope.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.modules.object.casts"></a><a class="link" href="casts.html" title="Casts">Casts</a>
</h4></div></div></div>
<p>
<span class="bold"><strong><span class="emphasis"><em>Lazy casts...</em></span></strong></span>
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">object</span><span class="special">/</span><span class="keyword">static_cast</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">object</span><span class="special">/</span><span class="keyword">dynamic_cast</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">object</span><span class="special">/</span><span class="keyword">const_cast</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">object</span><span class="special">/</span><span class="keyword">reinterpret_cast</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<p>
The set of lazy C++ cast template functions provide a way of lazily casting
an object of a certain type to another type. The syntax resembles the well
known C++ casts. Take note however that the lazy versions have a trailing
underscore.
</p>
<pre class="programlisting"><span class="identifier">static_cast_</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="identifier">lambda_expression</span><span class="special">)</span>
<span class="identifier">dynamic_cast_</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="identifier">lambda_expression</span><span class="special">)</span>
<span class="identifier">const_cast_</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="identifier">lambda_expression</span><span class="special">)</span>
<span class="identifier">reinterpret_cast_</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="identifier">lambda_expression</span><span class="special">)</span>
</pre>
<p>
Example:
</p>
<pre class="programlisting"><span class="identifier">static_cast_</span><span class="special">&lt;</span><span class="identifier">Base</span><span class="special">*&gt;(&amp;</span><span class="identifier">arg1</span><span class="special">)</span>
</pre>
<p>
Static-casts the address of <code class="computeroutput"><span class="identifier">arg1</span></code>
to a <code class="computeroutput"><span class="identifier">Base</span><span class="special">*</span></code>.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="delete.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../object.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../scope.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

View File

@@ -0,0 +1,81 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Construction</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
<link rel="up" href="../object.html" title="Object">
<link rel="prev" href="../object.html" title="Object">
<link rel="next" href="new.html" title="New">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../object.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../object.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="new.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="phoenix.modules.object.construction"></a><a class="link" href="construction.html" title="Construction">Construction</a>
</h4></div></div></div>
<p>
<span class="bold"><strong><span class="emphasis"><em>Lazy constructors...</em></span></strong></span>
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">object</span><span class="special">/</span><span class="identifier">construct</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<p>
Lazily construct an object from an arbitrary set of arguments:
</p>
<pre class="programlisting"><span class="identifier">construct</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="identifier">ctor_arg1</span><span class="special">,</span> <span class="identifier">ctor_arg2</span><span class="special">,</span> <span class="special">...,</span> <span class="identifier">ctor_argN</span><span class="special">);</span>
</pre>
<p>
where the given parameters are the parameters to the constructor of the
object of type T (This implies, that type T is expected to have a constructor
with a corresponding set of parameter types.).
</p>
<p>
Example:
</p>
<pre class="programlisting"><span class="identifier">construct</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&gt;(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">)</span>
</pre>
<p>
Constructs a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code> from <code class="computeroutput"><span class="identifier">arg1</span></code>
and <code class="computeroutput"><span class="identifier">arg2</span></code>.
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
The maximum number of actual parameters is limited by the preprocessor
constant BOOST_PHOENIX_COMPOSITE_LIMIT. Note though, that this limit
should not be greater than BOOST_PHOENIX_LIMIT. By default, <code class="computeroutput"><span class="identifier">BOOST_PHOENIX_COMPOSITE_LIMIT</span></code> is set
to <code class="computeroutput"><span class="identifier">BOOST_PHOENIX_LIMIT</span></code>
(See <a class="link" href="../../actor.html" title="Actor">Actor</a>).
</p></td></tr>
</table></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
Heller, John Fletcher<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../object.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../object.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="new.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More