git-subtree-dir: third_party/variant git-subtree-split: b5850212f16efeb409a112edb1e719d5f5edb604
		
			
				
	
	
		
			21 lines
		
	
	
		
			384 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			384 B
		
	
	
	
		
			C++
		
	
	
	
	
	
#include <boost/variant.hpp>
 | 
						|
 | 
						|
#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;
 | 
						|
}
 |