#include "./example.hpp" #include #include #include #include #include void example::algorithm::strings_to_ints_simple() { //[algorithm_simple /*`For example, the following snippet converts an array of integers from their textual hexadecimal representation and assigns INT_MAX to those which fail to convert: */ boost::array strings = {{ "0XF", "0X10", "0X11", "0X12", "not an int" }}; std::vector integers; boost::cnv::cstringstream cnv; // stringstream-based char converter std::transform( strings.begin(), strings.end(), std::back_inserter(integers), boost::convert(cnv(std::hex)).value_or(INT_MAX)); BOOST_TEST(integers.size() == 5); BOOST_TEST(integers[0] == 15); BOOST_TEST(integers[1] == 16); BOOST_TEST(integers[2] == 17); BOOST_TEST(integers[3] == 18); BOOST_TEST(integers[4] == INT_MAX); // Failed conversion //] }