apply-visitor

    7熱度

    1回答

    爲什麼下面的打印出來"A boolean!"?我意識到有一些奇怪的轉換正在進行,因爲如果我明確地構造一個std :: string我會得到正確的行爲。但爲什麼在以下情況下超載分辨率選擇visitor::operator()(bool)? #include <boost/variant.hpp> #include <string> typedef boost::variant<bool, st

    1熱度

    2回答

    我需要使用訪客類,例如class Visitor : public boost::static_visitor<> with boost :: variant? 如果不是,有沒有理由不使用訪客?是否有理由選擇訪客課程? 我問這個問題,因爲一個訪問者類似乎是使用boost :: variant的一個冗餘方面。

    3熱度

    1回答

    在以下代碼中,我將延遲apply_visitor的結果存儲在auto變量中。我可以使用什麼類型而不是auto?是否可以使用std::function? #include "boost/variant/variant.hpp" #include "boost/variant/apply_visitor.hpp" using namespace std; using namespace boo

    0熱度

    2回答

    有人能告訴我爲什麼我在下面代碼的最後一行出現編譯器錯誤? 注:如果我刪除以下行,我的代碼被沒有錯誤編譯: appliedEqualityVisitor(compareValue); 下面是代碼: #include "boost/variant/variant.hpp" #include "boost/variant/apply_visitor.hpp" using namespace s

    2熱度

    1回答

    我得到以下編譯器錯誤工作: /usr/include/boost/variant/variant.hpp:832:32: error: no match for call to ‘(const StartsWith) (bool&)’ 以下代碼。有人知道爲什麼嗎? #include "boost/variant/variant.hpp" #include "boost/variant/apply

    3熱度

    1回答

    以下代碼正確地將值999和「test」分配給控制檯,但我該如何返回這些值?像評論界線這樣的東西是我的最終目標;返回值然後我可以分配給一個自動變量(因爲我不知道我將處理的類型)。我打算使用boost::lexical_cast將此值轉換爲std::string以將其插入到數據庫的字段中。 我已經嘗試過其他示例中訪問者的各種變體,但沒有成功,包括從基類派生DataMap,以便我可以將變量存儲爲成員。我

    1熱度

    1回答

    我試圖問我的問題之前,但我認爲我問我的問題的方式是不正確的。所以我想在這裏再次:(我仍然不知道是什麼主題將是合適的) 第一,我定義 typedef boost::variant<point, Line, Vertex> vec_variant; typedef std::vector<vec_variant> vec; 在我寫我的功能,使得依賴於它返回點,線的情況下, 頂點或甚至它們的組合。

    4熱度

    1回答

    升壓::變種,並促進這個簡單的例子代碼:: apply_visitor的:使用Boost版本 g++-mp-4.8 -MMD -DBOOST_ALL_DYN_LINK -DBOOST_SPIRIT_USE_PHOENIX_V3 -Wall -std=c++11 -Os -O3 -g -I/o\ pt/local/include -I./ -c tools/t6.cpp -o tools/buil

    3熱度

    1回答

    #include <string> #include "boost/variant/variant.hpp" #include "boost/variant/apply_visitor.hpp" using namespace std; class Base { public: Base(){} ~Base(){} void AddField(int

    0熱度

    1回答

    我面臨着以下問題冗餘代碼: 我有升壓一些遊客::變種,它們都在做同樣的特定類型,這裏FOO,因此該方法 void operator()(const foo& ast) { //allways the same } 在每個訪客中都是一樣的。 由於我不想在所有訪問者中編寫這種冗餘方法,我儘量避免爲所有訪問者添加一個實現此方法的通用基類。 問題的方法調用訪問者本身recursivly,