나는 boost :: variant를 알게되었다. 나는이 예제가 효과가 있다고 생각한다.왜이 boost :: variant 예제가 작동하지 않습니까?
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/include/sequence.hpp>
#include <boost/variant/variant.hpp>
#include <string>
#include <vector>
#include <iostream>
#include <boost/variant/get.hpp>
boost::variant< bool,long,double,std::string,
std::vector<boost::variant<bool> > > v4;
void main()
{
std::vector<boost::variant<bool> > av (1);
v4= av;
try
{
bool b=
boost::get<bool> (v4[0]); // <--- this is line 20
std::cout << b;
}
catch (boost::bad_get v)
{
std::cout << "bad get" <<std::endl;
}
}
나는 컴파일 오류가 발생합니다 :
D : \ m \ UPP \ boosttest \ MAIN.CPP (20) : 오류 C2676 : 이진 '[': '부스트 :: 변형'할 ES 이것은 운영자 또는 [ T0_ = BOOL, T1 = 긴 T2 = 더블 T3 = 표준 : 문자열 T4 = 표준 : 벡터>와 미리 정의 된 연산자 으로 허용 가능한 형태로 전환을 정의하지 ]
을해야 하는가? 단일 유형 변형은 쓸모가 없습니다. – alexk7
사실, 방금 실험했습니다. – Aftershock