osrm-backend/test/boost_variant_hello_world.cpp
Dennis Luxen 884c998622 Squashed 'third_party/variant/' content from commit 24dcab2
git-subtree-dir: third_party/variant
git-subtree-split: 24dcab23c4f70e54838e4a32a228aba8045ae17b
2015-02-09 15:19:35 +01:00

20 lines
403 B
C++

#include <boost/variant.hpp>
#include <cstdint>
#include <stdexcept>
struct check : boost::static_visitor<>
{
template <typename T>
void operator() (T const& val) const
{
if (val != 0) throw std::runtime_error("invalid");
}
};
int main() {
typedef boost::variant<bool, int, double> variant_type;
variant_type v(0);
boost::apply_visitor(check(), v);
return 0;
}