boost-variant

    2

    1답변

    Value이라는 내 클래스에서 문자열을 생성하려고하는데 boost::spirit::karma을 사용했지만이 문제가 발생했습니다. 내 문제를 간단한 예제로 추출하려고했습니다. int main() { using karma::bool_; using karma::double_; using karma::rule; using ka

    3

    1답변

    며칠 전 부스트 라이브러리를 사용하기 시작 했으므로 제 질문은 사소한 것일 수 있습니다. 두 개의 동일한 유형 변형을 static_visitor와 비교하려고합니다. 다음을 시도했지만 컴파일하고 싶지 않습니다. struct compare:public boost::static_visitor<bool> { bool operator()(int& a, i

    4

    1답변

    에서 변형 기본 유형 I은 S-expression이 모델 재귀 변형이있다. 그러나, 나는 push_back() 방문자의 구현과 붙어있어. struct push_back_visitor: public boost::static_visitor<void> { push_back_visitor(const sexpr &arg): arg_(arg) {}

    14

    2답변

    나는 string, bool 및 int의 세 가지 유형을 허용하는 boost::variant을 선언했습니다. 다음 코드는 내 변형이 const char*을 허용하고 bool으로 변환한다는 것을 보여줍니다. boost::variant이 목록에없는 형식을 수락하고 변환하는 것이 정상적인 동작입니까? #include <iostream> #include "boo

    1

    1답변

    boost.variant를 배우려고합니다. 그러나 책에서 복사 한 코드는 컴파일을 통과하지 못합니다. class var_print : public boost::static_visitor<void> { public: template<typename T> void operator()(T &i) { i *= 2; c

    1

    1답변

    boost::variant 내의 특정 유형을 식별하고 클래스 객체 내 구성원 함수 인수로 전달하여 다음 문제를 혼동스럽게합니다. 다음 코드를 고려하십시오. typedef boost::variant<int, string, double> Variant; class test{ void func1 (Variant V); void func2

    2

    1답변

    예기치 않은 동작을했을 때 boost::variant<int,std::string,bool> 및 그 방문자와 함께 작업하고있었습니다. 문자열과 bool 값이 비슷했습니다. 나도 몰라, 왜 이런 식으로 일하는거야,하지만 난 재미있는 찾았다. 내 유일한 생각은 bool 값을 가진 variant가 char로 해석된다는 것입니까? 누군가 나에게 설명해 줄 수 있니

    1

    3답변

    다음과 같은 boost :: variant 메서드를 사용하고 있습니다. 나는 T 타입에 기초하여 값을 얻으려고 노력한다. boost::get<T>이 실패하면 T가 int 또는 unsigned int 인 경우이를 특수한 방식으로 처리하려고합니다. T이 int인지 unsigned int인지 알 수있는 방법이 있습니까? 이 경우 템플릿 전문화를 사용할 수 있다고

    2

    1답변

    나는 무슨 일이 일어나고 있는지 정말로 이해하지 못합니다. 내가 MSVC 2012을 사용하고 있는데,이 코드는 잘 작동 할 것으로 예상된다 (51)을 밀어하지만 컴파일되지 않습니다 #include "stdafx.h" #include <string> #include <boost/variant/recursive_variant.hpp> namespace

    9

    1답변

    typedef boost::variant<int, double> Type; class Append: public boost::static_visitor<> { public: void operator()(int) {} void operator()(double) {} }; Type type(1.2); Visi