### Start Metashell with Boost.Metaparse Example Path Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap This command initiates the Metashell environment, ensuring that the Boost libraries and the `getting_started` example from Metaparse are accessible in the include path. ```bash $ metashell -I$BOOST_ROOT -I$BOOST_ROOT/libs/metaparse/example/getting_started ``` -------------------------------- ### Evaluate Binary Operations with eval_binary_op Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Examples demonstrating the usage of the `eval_binary_op` metafunction for addition and subtraction. ```cpp eval_binary_op, '+', boost::mpl::int_<2>>::type mpl_::integral_c eval_binary_op, '-', boost::mpl::int_<2>>::type mpl_::integral_c ``` -------------------------------- ### Example Usage of eval_plus Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Demonstrates the usage of the `eval_plus` metafunction with a sample vector, showing the evaluation of `11 + 2`. ```cpp eval_plus< \ boost::mpl::vector< \ mpl_::integral_c, \ mpl_::char_<'+'>, \ mpl_::integral_c \ >>::type ``` -------------------------------- ### Build a basic integer parser with Boost.Metaparse Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Demonstrates the creation of a simple parser for integers using `build_parser` and `int_` from Boost.Metaparse. This serves as a foundational example for parser construction. ```cpp #include using namespace boost::metaparse; using exp_parser1 = build_parser; ``` -------------------------------- ### Build Parser with int_ Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Demonstrates building a basic parser for integers using `boost::metaparse::int_`. This is a foundational example for creating parsers. ```cpp #include #include using namespace boost::metaparse; using exp_parser1 = build_parser; ``` -------------------------------- ### Initial Parser Definition Example Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap This snippet shows an initial parser definition using `foldl_start_with_parser` with sequence, one_of, plus_token, minus_token, and mult_exp6. ```cpp foldl_start_with_parser< sequence, mult_exp6>, mult_exp6, boost::mpl::quote2 > {}; ``` -------------------------------- ### Install Boost Distribution Source: https://www.boost.org/doc/libs/1_89_0/doc/html/mpi/getting_started Command to install the entire Boost distribution after it has been built, typically executed from the root Boost directory. ```Shell $cd $./b2 install ``` -------------------------------- ### Parser Alias Example Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap This defines an alias `exp_parser20` for a parser built using `build_parser` and `plus_exp3`. ```cpp using exp_parser20 = build_parser; ``` -------------------------------- ### Example of sum_items with an integral constant and a vector Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Provides an example of using the `sum_items` template with an initial integral constant and a Boost.MPL vector containing a character and an integral constant. ```cpp sum_items< mpl_::integral_c, boost::mpl::vector, mpl_::integral_c> >::type ``` -------------------------------- ### Build Parser for Integer Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Demonstrates building a basic parser for integers using `boost::metaparse::int_`. ```cpp #include ; ``` -------------------------------- ### Sum Nested Vector Item Example Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Provides an example of using the `sum_items` metafunction with a specific nested vector structure, demonstrating the addition of an integer from the inner vector to an initial sum. ```cpp sum_items< \ ...> mpl_::integral_c, \ ...> boost::mpl::vector, mpl_::integral_c> \ ...> >::type ``` -------------------------------- ### Example usage of eval_plus with Boost.MPL vector Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Provides an example of how to use the `eval_plus` struct with a Boost.MPL vector containing integral constants, showcasing a typical metaprogramming calculation. ```cpp eval_plus< boost::mpl::vector< mpl_::integral_c, mpl_::char_<'+'>, mpl_::integral_c >>::type ``` -------------------------------- ### Build Parser with Foldl_start_with_parser Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Demonstrates `boost::metaparse::foldl_start_with_parser` for parsing sequences where the initial value is obtained by a separate parser. This example parses an integer as the starting point and then repeatedly applies "+ " sequences. ```cpp #include using exp_parser11 = build_parser< foldl_start_with_parser< sequence, /* apply this parser repeatedly */ int_token, /* use this parser to get the initial value */ boost::mpl::quote2 /* use this function to add a new value to the summary */ > >; ``` -------------------------------- ### Parse arithmetic expressions with foldl_start_with_parser using Boost.Metaparse Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap This example demonstrates using `foldl_start_with_parser` from Boost.Metaparse to parse arithmetic expressions, providing an initial value from a parser. ```cpp #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace boost::metaparse; using int_token = token; using plus_token = token>; template struct sum_items : boost::mpl::plus< Sum, typename boost::mpl::at_c::type > {}; using exp_parser11 = build_parser< foldl_start_with_parser< sequence, /* apply this parser repeatedly */ int_token, /* use this parser to get the initial value */ boost::mpl::quote2 /* use this function to add a new value to the summary */ > >; ``` -------------------------------- ### Build Parser with Sequence and Quote Transformation Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Demonstrates building a parser using a sequence of tokens and applying a transformation with `boost::mpl::quote1`. This example parses an integer, a plus token, and another integer, then uses `eval_plus` to evaluate the expression. ```cpp #include using exp_parser6 = build_parser< transform< sequence, boost::mpl::quote1 > >; ``` -------------------------------- ### Build a parser using foldl_start_with_parser Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Shows how to build a parser using `foldl_start_with_parser` for repeated sequences of '+ number', starting with an initial integer token and using `sum_items` for accumulation. ```cpp using exp_parser11 = build_parser< foldl_start_with_parser< sequence, /* apply this parser repeatedly */ int_token, /* use this parser to get the initial value */ boost::mpl::quote2 /* use this function to add a new value to the summary */ > >; ``` -------------------------------- ### Include Boost.Metaparse Header Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Includes the necessary header file for using Boost.Metaparse functionalities, specifically for general parsing utilities. ```cpp #include ``` -------------------------------- ### Include Boost.Metaparse Transform Header Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Includes the necessary header file for using the transform functionality in Boost.Metaparse. ```cpp #include ``` -------------------------------- ### C++: Include foldr_start_with_parser header Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Includes the necessary header file for using the `foldr_start_with_parser` combinator from the Boost.Metaparse library. ```cpp #include ``` -------------------------------- ### Apply binary_op in Expression Parsing Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Demonstrates using the `binary_op` metafunction within `foldl_start_with_parser` to build a parser for arithmetic expressions. ```cpp using exp_parser13 = \ build_parser< \ foldl_start_with_parser< \ sequence, int_token>, \ int_token, \ boost::mpl::quote2 \ > \ >; exp_parser13::apply::type mpl_::integral_c ``` -------------------------------- ### Build Parser with Foldl_start_with_parser Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Demonstrates `boost::metaparse::foldl_start_with_parser` for parsing sequences where the initial value is obtained by a separate parser. ```cpp #include struct sum_items : boost::mpl::plus< Sum, typename boost::mpl::at_c::type /* Accessing the number from sequence */ > {}; using exp_parser11 = build_parser< foldl_start_with_parser< sequence, /* apply this parser repeatedly */ int_token, /* use this parser to get the initial value */ boost::mpl::quote2 /* use this function to add a new value to the summary */ > >; ``` -------------------------------- ### Build parser using foldl_start_with_parser Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Demonstrates using foldl_start_with_parser to build an expression parser. It repeatedly applies a sequence of plus-token and int-token, starting with an initial int-token, and uses sum_items for aggregation. ```cpp #include #include #include #include #include #include #include #include #include #include #include // Helper struct to sum items in a sequence parsed by repeated template struct sum_items : boost::mpl::plus< Sum, typename boost::mpl::at_c::type > {}; using namespace boost::metaparse; using int_token = token; using plus_token = token>; using exp_parser11 = build_parser< foldl_start_with_parser< sequence, /* apply this parser repeatedly */ int_token, /* use this parser to get the initial value */ boost::mpl::quote2 /* use this function to add a new value to the summary */ > >; ``` -------------------------------- ### Reject Incomplete Starts in Foldl Parser Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Introduces `foldl_reject_incomplete_start_with_parser` in `plus_exp5`. This variant of `foldl` ensures that the parsing process is rejected if the starting sequence is incomplete, leading to stricter parsing. ```cpp #include struct plus_exp5 : foldl_reject_incomplete_start_with_parser< sequence, mult_exp6>, mult_exp6, boost::mpl::quote2 > {}; using exp_parser22 = build_parser; ``` -------------------------------- ### Parser with Foldl Start With Parser Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Constructs a parser using 'foldl_start_with_parser'. It parses an initial integer and then repeatedly applies a '+ integer' parser, accumulating the result using a summation function. ```C++ #include using exp_parser11 = build_parser< foldl_start_with_parser< sequence, /* apply this parser repeatedly */ int_token, /* use this parser to get the initial value */ boost::mpl::quote2 /* use this function to add a new value to the summary */ > >; ``` -------------------------------- ### Expression Parsing with Binary Operations Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Parses and evaluates expressions with addition and subtraction using `foldl_start_with_parser` and the `binary_op` metafunction. ```cpp using exp_parser13 = build_parser< foldl_start_with_parser< sequence, int_token>, int_token, boost::mpl::quote2 > >; ``` -------------------------------- ### Retrieve MPI Compiler Information Source: https://www.boost.org/doc/libs/1_89_0/doc/html/mpi/getting_started Demonstrates how to use the MPI wrapper's `--show` or `--showme` options to retrieve compiler and linker flags. This information can be used to manually configure build systems or understand the underlying compilation process. ```Shell $ mpiicc -show icc -I/softs/.../include ... -L/softs/.../lib ... -Xlinker -rpath -Xlinker /softs/.../lib .... -lmpi -ldl -lrt -lpthread ``` ```Shell $ mpicc --showme icc -I/opt/.../include -pthread -L/opt/.../lib -lmpi -ldl -lm -lnuma -Wl,--export-dynamic -lrt -lnsl -lutil -lm -ldl ``` ```Shell $ mpicc --showme:compile -I/opt/mpi/bullxmpi/1.2.8.3/include -pthread ``` ```Shell $ mpicc --showme:link -pthread -L/opt/.../lib -lmpi -ldl -lm -lnuma -Wl,--export-dynamic -lrt -lnsl -lutil -lm -ldl ``` -------------------------------- ### Build Boost Distribution Source: https://www.boost.org/doc/libs/1_89_0/doc/html/mpi/getting_started Commands to build the entire Boost distribution or specifically the Boost.MPI library and its dependencies from the command line using the b2 build tool. ```Shell $cd $./b2 ``` ```Shell $cd /lib/mpi/build $../../../b2 ``` -------------------------------- ### Link Boost.MPI Applications Source: https://www.boost.org/doc/libs/1_89_0/doc/html/mpi/getting_started Example of how to compile and link a C++ application using Boost.MPI, including necessary include paths and linking against the Boost.MPI and Boost.Serialization libraries. ```C++ mpic++ -I/path/to/boost/mpi my_application.cpp -Llibdir \ -lboost_mpi -lboost_serialization ``` -------------------------------- ### Grammar Creation Best Practices Source: https://www.boost.org/doc/libs/1_89_0/doc/html/xpressive/user_s_guide Guidelines for creating regex grammars efficiently and safely, emphasizing single-threaded creation. ```APIDOC ## Concepts: Grammar Creation ### Description Explains how to create regex grammars by nesting regexes and the implications for static regexes. It highlights the importance of building regex grammars from a single thread to avoid issues with global regex objects. ### Method N/A (Conceptual explanation) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Build Parser with Foldl_start_with_parser for +/- Expressions Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Extends `foldl_start_with_parser` to handle both addition and subtraction operations in a sequence of numbers. ```cpp #include struct sum_items : boost::mpl::plus< Sum, typename boost::mpl::at_c::type /* Accessing the number from sequence */ > {}; using minus_token = token>; using exp_parser12 = build_parser< foldl_start_with_parser< sequence, int_token>, int_token, boost::mpl::quote2 > >; ``` -------------------------------- ### Parse sequences with initial value using foldl_start_with_parser Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Constructs a parser that starts with an initial value (an integer) and then repeatedly applies a sequence parser (`+ number`), accumulating the result using `boost::metaparse::foldl_start_with_parser`. ```cpp #include using exp_parser11 = build_parser< foldl_start_with_parser< sequence, int_token, boost::mpl::quote2 > >; ``` -------------------------------- ### Parse expression with foldl_start_with_parser in Boost Metaparse Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap This example uses `foldl_start_with_parser` to parse a sequence starting with an integer (`int_token`) and then repeatedly applying a '+ ' parser. The `sum_items` struct aggregates the results. ```cpp #include #include #include #include #include #include #include #include #include /* Assume sum_items, int_token, plus_token are defined as above */ using exp_parser11 = build_parser< foldl_start_with_parser< sequence, /* apply this parser repeatedly */ int_token, /* use this parser to get the initial value */ boost::mpl::quote2 /* use this function to add a new value to the summary */ > >; ``` -------------------------------- ### Boost.MPI: Project-Config.jam Configuration (Jam) Source: https://www.boost.org/doc/libs/1_89_0/doc/html/mpi/getting_started Configuration directive for Boost.Build to enable MPI support. Add 'using mpi ;' to your 'project-config.jam' file to inform the build system about your MPI installation. This is a simplified configuration. ```jam using mpi ; ``` -------------------------------- ### Parse multiplication expressions with Boost.Metaparse Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap This example extends the parsing capabilities to include multiplication using Boost.Metaparse and Boost.MPL's times. ```cpp #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace boost::metaparse; using int_token = token; using plus_token = token>; using minus_token = token>; template struct eval_binary_op; template struct eval_binary_op : boost::mpl::plus::type {}; template struct eval_binary_op : boost::mpl::minus::type {}; template struct eval_binary_op : boost::mpl::times::type {}; using times_token = token>; using exp_parser14 = build_parser< foldl_start_with_parser< ``` -------------------------------- ### Boost.Proto Hello World: Expression Template and Evaluation Source: https://www.boost.org/doc/libs/1_89_0/doc/html/proto/users_guide A basic example demonstrating how to construct and evaluate an expression template using Boost.Proto. It includes necessary headers and a simple `main` function to showcase the evaluation. ```cpp // // Copyright 2008 Eric Niebler. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include #include #include // This #include is only needed for compilers that use typeof emulation: #include namespace proto = boost::proto; proto::terminal< std::ostream & >::type cout_ = {std::cout}; template< typename Expr > void evaluate( Expr const & expr ) { proto::default_context ctx; proto::eval(expr, ctx); } int main() { evaluate( cout_ << "hello" << ',' << " world" ); return 0; } ``` -------------------------------- ### Sum arithmetic expressions using foldl with Boost.Metaparse Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap This example utilizes Boost.Metaparse's `foldl` combinator to parse and sum arithmetic expressions. It simplifies the summation logic compared to the previous `fold` example. ```cpp #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace boost::metaparse; using int_token = token; using plus_token = token>; template struct sum_items : boost::mpl::plus< Sum, typename boost::mpl::at_c::type > {}; using exp_parser10 = build_parser< transform< sequence< int_token, foldl< sequence, boost::mpl::int_<0>, boost::mpl::quote2 > >, boost::mpl::quote1> >; ``` -------------------------------- ### Configure MPI Compiler and Linker Options Source: https://www.boost.org/doc/libs/1_89_0/doc/html/mpi/getting_started Provides detailed compilation and linking options for specific MPI implementations when the wrapper is eccentric or non-existent. This includes library paths, include paths, and shared library names. ```Jam using mpi : mpiicc : /softs/intel/impi/5.0.1.035/intel64/lib /softs/intel/impi/5.0.1.035/intel64/lib/release_mt /softs/intel/impi/5.0.1.035/intel64/include mpifort mpi_mt mpigi dl rt ; ``` -------------------------------- ### Run Boost.MPI Regression Tests Source: https://www.boost.org/doc/libs/1_89_0/doc/html/mpi/getting_started Command to navigate to the Boost.MPI test directory and execute the regression tests using the b2 build tool. ```Shell $cd /lib/mpi/test $../../../b2 ``` -------------------------------- ### Parse expressions with mixed operators using Boost.Metaparse Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap This example shows how to parse arithmetic expressions involving both addition and subtraction, using `one_of` and `foldl_start_with_parser`. ```cpp #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace boost::metaparse; using int_token = token; using plus_token = token>; using minus_token = token>; template struct eval_binary_op; template struct eval_binary_op : boost::mpl::plus::type {}; template struct eval_binary_op : boost::mpl::minus::type {}; template struct binary_op : eval_binary_op< S, boost::mpl::at_c::type::value, typename boost::mpl::at_c::type > {}; using exp_parser12 = build_parser< foldl_start_with_parser< sequence, int_token>, int_token, boost::mpl::quote2 > >; using exp_parser13 = build_parser< foldl_start_with_parser< sequence, int_token>, int_token, boost::mpl::quote2 > >; ``` -------------------------------- ### Build a parser for +,- expressions using foldl_start_with_parser and binary_op Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Constructs a parser for expressions with addition and subtraction using `build_parser`, `foldl_start_with_parser`, `sequence`, `one_of`, `int_token`, and the `binary_op` helper. ```cpp using exp_parser13 = build_parser< foldl_start_with_parser< sequence, int_token>, int_token, boost::mpl::quote2 > >; ``` -------------------------------- ### Parse expressions with addition/subtraction using foldl_start_with_parser Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Extends the previous example to handle both addition and subtraction operators. It uses `boost::metaparse::one_of` to select between `+` and `-` tokens. ```cpp using minus_token = token>; #include using exp_parser12 = build_parser< foldl_start_with_parser< sequence, int_token>, int_token, boost::mpl::quote2 > >; ``` -------------------------------- ### Main Function - Runtime Plugin Load Example (C++) Source: https://www.boost.org/doc/libs/1_89_0/doc/html/boost_dll/tutorial Demonstrates how to load a plugin at runtime using the `get_plugin` function. It specifies the plugin path and creator function name, then prints the plugin's name and location, showcasing the reference counting mechanism. ```cpp #include #include "refcounting_api.hpp" int main(int argc, char* argv[]) { std::shared_ptr plugin = get_plugin( boost::dll::fs::path(argv[1]) / "refcounting_plugin", "create_refc_plugin" ); std::cout << "Plugin name: " << plugin->name() << ", \nlocation: " << plugin->location() << std::endl; } ``` -------------------------------- ### Parse repeated sequences with Boost.Metaparse Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap This example shows how to parse a sequence that can repeat, such as an integer followed by multiple instances of '+ '. It uses Boost.Metaparse's repeated combinator. ```cpp #include #include #include #include #include #include #include #include using namespace boost::metaparse; using int_token = token; using plus_token = token>; using exp_parser7 = build_parser< sequence< int_token, /* The first */ repeated> /* The "+ " elements */ > >; ``` -------------------------------- ### Boost.Proto Hello World Example Source: https://www.boost.org/doc/libs/1_89_0/doc/html/proto/users_guide A simple C++ program using Boost.Proto to build an expression template for printing 'hello, world' to the console. It demonstrates the basic usage of Proto for operator overloading and lazy evaluation. ```cpp #include #include #include using namespace boost; proto::terminal< std::ostream & >::type cout_ = { std::cout }; template< typename Expr > void evaluate( Expr const & expr ) { proto::default_context ctx; proto::eval(expr, ctx); } int main() { evaluate( cout_ << "hello" << ',' << " world" ); return 0; } ``` -------------------------------- ### Build parser for integer with Boost.Metaparse Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap This example demonstrates how to build a parser for integers using Boost.Metaparse's int_ parser. It defines a parser that expects an entire input to be an integer. ```cpp #include #include #include using namespace boost::metaparse; using exp_parser1 = build_parser; using exp_parser2 = build_parser>; using exp_parser3 = build_parser>>; ``` -------------------------------- ### Fold Left with Optional Operators and Summation Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Extends the previous example to handle both '+' and '-' operators. It uses `one_of` to select between the operator tokens and `foldl_start_with_parser` to accumulate the result. ```cpp #include #include #include #include #include #include #include #include // Assuming sum_items is defined elsewhere to sum two MPL integers // For example: // template struct sum_items : boost::mpl::plus {}; using plus_token = token>; using minus_token = token>; using int_token = token; using exp_parser12 = build_parser< foldl_start_with_parser< sequence, int_token>, int_token, boost::mpl::quote2 > >; ``` -------------------------------- ### Build Parser for Entire Input Integers Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap This snippet demonstrates building a parser that consumes the entire input as an integer. It extends the previous example by incorporating `entire_input` for strict input matching. ```c++ #include #include #include using namespace boost::metaparse; using exp_parser1 = build_parser; #include using exp_parser2 = build_parser>; ``` -------------------------------- ### Build Parser with FoldlStartWithParser Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Shows how to construct a parser using `boost::metaparse::foldl_start_with_parser`. This parser takes an initial integer token and then repeatedly applies a sequence of a plus token and an integer token, summing the results. ```cpp #include using exp_parser11 = build_parser< foldl_start_with_parser< sequence, /* apply this parser repeatedly */ int_token, /* use this parser to get the initial value */ boost::mpl::quote2 /* use this function to add a new value to the summary */ > >; ``` -------------------------------- ### Apply exp_parser11 to String Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Demonstrates applying the `exp_parser11` to a string literal using `BOOST_METAPARSE_STRING`. This example shows how the parser evaluates an arithmetic expression involving addition, resulting in an integral constant. ```c++ exp_parser11::apply::type ``` -------------------------------- ### Boost.MPI: Advanced Project-Config.jam Configuration (Jam) Source: https://www.boost.org/doc/libs/1_89_0/doc/html/mpi/getting_started An advanced configuration for Boost.Build's MPI support in 'project-config.jam'. This format allows specifying the MPI compiler wrapper, compilation/link options, and the MPI runner. Ensure proper spacing around ':' and before ';'. ```jam using mpi : [] : [] : [] ; ``` -------------------------------- ### Build Parser for Binary Operations with Foldl_start_with_parser Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Implements a parser for arithmetic expressions with addition and subtraction using `foldl_start_with_parser` and a custom `binary_op` metafunction. ```cpp #include struct binary_op : eval_binary_op< S, boost::mpl::at_c::type::value, /* The operator character */ typename boost::mpl::at_c::type /* The right-hand operand */ > {}; /* Helper metafunctions for eval_binary_op */ template struct eval_binary_op; template struct eval_binary_op : boost::mpl::plus::type {}; template struct eval_binary_op : boost::mpl::minus::type {}; using exp_parser13 = build_parser< foldl_start_with_parser< sequence, int_token>, int_token, boost::mpl::quote2 > >; ``` -------------------------------- ### Simplify Folding with `foldl` and Transform using Boost Metaparse Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Introduces `boost::metaparse::foldl` as a more direct way to perform left folds within a sequence parser. This example combines `foldl` with `transform` to achieve a similar summation as previous examples but with a more concise folding mechanism. ```cpp #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace boost::metaparse; using int_token = token; using plus_token = token>; /* Helper metafunction for summing items */ template struct sum_items : boost::mpl::plus< Sum, typename boost::mpl::at_c::type > {}; using exp_parser10 = build_parser< transform< sequence< int_token, foldl< sequence, boost::mpl::int_<0>, boost::mpl::quote2 > >, boost::mpl::quote1> >; ``` -------------------------------- ### Build parser for sequence of tokens with Boost.Metaparse Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap This example shows how to build a parser for a sequence of tokens, specifically two integers separated by a plus sign. It utilizes Boost.Metaparse's sequence and token combinators. ```cpp #include #include #include #include #include #include #include using namespace boost::metaparse; using int_token = token; using plus_token = token>; using exp_parser4 = build_parser, token>, token>>; using exp_parser5 = build_parser>; ``` -------------------------------- ### Build Sequence Parser with Defined Tokens (Boost.Metaparse) Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Shows building a parser for a sequence of custom-defined tokens (int_token, plus_token) using Boost.Metaparse. This is similar to the previous example but uses pre-defined token types. ```cpp #include using int_token = token; using plus_token = token>; using exp_parser5 = build_parser>; ``` -------------------------------- ### Loading a Shared Library with Boost.DLL Source: https://www.boost.org/doc/libs/1_89_0/doc/html/boost_dll/getting_started Demonstrates how to load a shared library using the `boost::dll::shared_library` class by providing the path to the library file. The imported symbols are only valid as long as the `shared_library` instance exists. ```cpp boost::dll::shared_library lib("/test/boost/application/libtest_library.so"); ``` -------------------------------- ### Capture Stacktrace from Exceptions Source: https://www.boost.org/doc/libs/1_89_0/doc/html/stacktrace/getting_started Shows how to capture a stack trace at the point an exception is thrown, allowing for detailed error analysis without a debugger. Requires linking with boost_stacktrace_from_exception. ```cpp #include #include #include #include void foo(std::string_view key); void bar(std::string_view key); int main() { try { foo("test1"); bar("test2"); } catch (const std::exception& exc) { boost::stacktrace::stacktrace trace = boost::stacktrace::stacktrace::from_current_exception(); // <--- std::cerr << "Caught exception: " << exc.what() << ", trace:\n" << trace; } } ``` -------------------------------- ### Build Sequence Parser with Literal Tokens (Boost.Metaparse) Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Demonstrates building a parser for a sequence of tokens, including literal characters, using Boost.Metaparse's sequence and lit_c. This example parses 'int_token + int_token'. ```cpp #include #include using exp_parser4 = build_parser, token>, token>>; ``` -------------------------------- ### Build parser for general binary operations Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Constructs a parser that handles sequences of binary operations (e.g., '1 + 2 - 3'). It leverages `foldl_start_with_parser` and the `binary_op` struct for evaluation. ```cpp #include struct eval_binary_op; template struct eval_binary_op : boost::mpl::plus::type {}; template struct eval_binary_op : boost::mpl::minus::type {}; template struct binary_op : eval_binary_op< S, boost::mpl::at_c::type::value, typename boost::mpl::at_c::type > {}; using exp_parser13 = build_parser< foldl_start_with_parser< sequence, int_token>, token, boost::mpl::quote2 > >; ``` -------------------------------- ### Build Expression Parser with Nested Structures Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Constructs a complete expression parser `exp_parser20` by defining unary, multiplication, and addition/subtraction parsers (`unary_exp3`, `mult_exp6`, `plus_exp3`). This example shows a more complex, nested grammar. ```cpp using unary_exp3 = foldr_start_with_parser< minus_token, primary_exp3, boost::mpl::lambda>::type >; using mult_exp6 = foldl_start_with_parser< sequence, unary_exp3>, unary_exp3, boost::mpl::quote2 >; struct plus_exp3 : foldl_start_with_parser< sequence, mult_exp6>, mult_exp6, boost::mpl::quote2 > {}; using exp_parser20 = build_parser; ``` -------------------------------- ### Apply exp_parser12 to String Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Demonstrates applying the `exp_parser12` to a string containing both addition and subtraction. This example highlights a potential issue where the aggregation function `sum_items` might not correctly handle different operators if not designed to do so. ```c++ exp_parser12::apply::type ``` -------------------------------- ### Include Metaparse Headers and Namespace Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Includes necessary Boost.Metaparse headers for string and integer parsing, and declares the use of the boost::metaparse namespace. ```c++ #include #include using namespace boost::metaparse; ``` -------------------------------- ### Build a parser for +,-,* expressions Source: https://www.boost.org/doc/libs/1_89_0/doc/html/metaparse/getting_started_with_boost_metap Shows how to build a parser that handles addition, subtraction, and multiplication using `build_parser`, `foldl_start_with_parser`, `sequence`, `one_of`, and the extended `binary_op`. ```cpp using exp_parser14 = build_parser< foldl_start_with_parser< sequence, int_token>, int_token, boost::mpl::quote2 > >; ```