osrm-backend/test/our_variant_hello_world.cpp
Patrick Niklaus 62e8601919 Squashed 'third_party/variant/' content from commit b585021
git-subtree-dir: third_party/variant
git-subtree-split: b5850212f16efeb409a112edb1e719d5f5edb604
2016-03-24 21:32:27 +01:00

21 lines
366 B
C++

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