Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

boost::variant

This module provides adapters for boost::variant. Including the module header makes boost::variant a fully conforming Forward Sequence. The variant acts as a sequence of the types that can be contained in the variant. Accessing types not currently stored int the variant will lead to the variant being populated with a default constructed value of that type.

Header

#include <boost/fusion/adapted/variant.hpp>
#include <boost/fusion/include/variant.hpp>

Model of

Example

boost::variant<int,std::string> example_variant = 101;
std::cout << example_variant << '\n';
*boost::fusion::find<std::string>(example_variant) = "hello";
std::cout << example_variant << '\n';

See also

Boost.Variant Library


PrevUpHomeNext