examples.qbk

来自「Boost provides free peer-reviewed portab」· QBK 代码 · 共 193 行

QBK
193
字号
[/ / Copyright (c) 2008 Eric Niebler / / Distributed under the Boost Software License, Version 1.0. (See accompanying / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) /][import ../example/hello.cpp][import ../example/calc1.cpp][import ../example/calc2.cpp][import ../example/calc3.cpp][import ../example/lazy_vector.cpp][import ../example/mixed.cpp][import ../example/rgb.cpp][import ../example/tarray.cpp][import ../example/vec3.cpp][import ../example/vector.cpp][import ../example/map_assign.cpp][import ../example/futures.cpp][import ../example/lambda.cpp][/===============][section Examples][/===============]A code example is worth a thousand words ...[/=================================================================================][section:hello_world Hello World: Building An Expression Template and Evaluating It][/=================================================================================]A trivial example which builds and expression templateand evaluates it.[HelloWorld][endsect][/==================================================][section:calc1 Calc1: Defining An Evaluation Context][/==================================================]A simple example which builds a miniature domain-specific embedded language for lazy arithmetic expressions, withTR1 bind-style argument placeholders.[Calc1][endsect][/============================================================][section:calc2 Calc2: Adding Members Using [^proto::extends<>]][/============================================================]An extension of the Calc1 example that uses _extends_ tomake calculator expressions valid function objects thatcan be used with STL algorithms.[Calc2][endsect][/===============================================][section:calc3 Calc3: Defining A Simple Transform][/===============================================]An extension of the Calc2 example that uses a Proto transformto calculate the arity of a calculator expression and staticallyassert that the correct number of argument are passed.[Calc3][endsect][/==============================================================][section:lazy_vector Lazy Vector: Controlling Operator Overloads][/==============================================================]This example constructs a mini-library for linear algebra, usingexpression templates to eliminate the need for temporaries whenadding vectors of numbers.This example uses a domain with a grammar to prune the setof overloaded operators. Only those operators that producevalid lazy vector expressions are allowed.[LazyVector][endsect][/========================================================][section:rgb RGB: Type Manipulations With Proto Transforms][/========================================================]This is a simple example of doing arbitrary type manipulations with Prototransforms. It takes some expression involving primiary colors and combinesthe colors according to arbitrary rules. It is a port of the RGB examplefrom _PETE_.[RGB][endsect][/=====================================================][section:tarray TArray: A Simple Linear Algebra Library][/=====================================================]This example constructs a mini-library for linear algebra, usingexpression templates to eliminate the need for temporaries whenadding arrays of numbers. It duplicates the TArray example from_PETE_.[TArray][endsect][/========================================================][section:vec3 Vec3: Computing With Transforms And Contexts][/========================================================]This is a simple example using `proto::extends<>` to extend a terminal typewith additional behaviors, and using custom contexts and `proto::eval()` forevaluating expressions. It is a port of the Vec3 example from_PETE_.[Vec3][endsect][/========================================================][section:vector Vector: Adapting A Non-Proto Terminal Type][/========================================================]This is an example of using `BOOST_PROTO_DEFINE_OPERATORS()` to Proto-ifyexpressions using `std::vector<>`, a non-Proto type. It is a port of theVector example from _PETE_.[Vector][endsect][/=============================================================][section:mixed Mixed: Adapting Several Non-Proto Terminal Types][/=============================================================]This is an example of using `BOOST_PROTO_DEFINE_OPERATORS()` to Proto-ifyexpressions using `std::vector<>` and `std::list<>`, non-Proto types. It is aport of the Mixed example from _PETE_.[Mixed][endsect][/=======================================================][section:map_assign Map Assign: An Intermediate Transform][/=======================================================]A demonstration of how to implement `map_list_of()` from the Boost.Assignlibrary using Proto. `map_list_assign()` is used to conveniently initialize a`std::map<>`. By using Proto, we can avoid any dynamic allocation whilebuilding the intermediate representation.[MapAssign][endsect][/===========================================================][section:future_group Future Group: A More Advanced Transform][/===========================================================]An advanced example of a Proto transform that implementsHoward Hinnant's design for /future groups/ that blockfor all or some asynchronous operations to complete andreturns their results in a tuple of the appropriate type.[FutureGroup][endsect][/========================================================][section:lambda Lambda: A Simple Lambda Library with Proto][/========================================================]This is an advanced example that shows how to implement a simplelambda DSEL with Proto, like the Boost.Lambda_library. It usescontexts, transforms and expression extension.[Lambda][endsect][endsect]

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?