#include#include using namespace boost; int main() { any a = 42; std::cout << any_cast (a) << std::endl; a = 3.14; if(!a.empty()) std::cout << any_cast (a) << std::endl; return 0; }
#includeThis example creates a HandleValue object, 'handle', with an initial value of 1337. It then creates a new HandleValue, 'doubled', by applying a lambda function that multiplies the value of 'handle' by 2. It then prints out the value of 'doubled' using the get() function. Package library: Boost C++ Libraries.#include using namespace boost::hana; int main() { auto handle = make_handle (1337); auto doubled = handle.bind([](auto x) { return x*2; }); std::cout << doubled.get() << std::endl; return 0; }