variadic-templates

    1熱度

    1回答

    我的問題可能與this one有關,但我認爲我沒有「部分專用的非類型參數表達式」,或者不理解關係。 下面的代碼產生具有MSVC14編譯器(CPP11)一個內部錯誤: template<typename T, T... Elmts> struct NonTyped { }; template<typename T> struct is_NonTyped_of_type {

    1熱度

    1回答

    說我有一組模板template<int N> A{}和template<int N> B{}等與模板C,D ....他們都有一個靜態成員函數init()。 我想寫一個元函數生成A<0>,B<1>,C<2>等等。讓我們命名這個可變元函數SeqInst。而且這個元功能還有一個靜態成員函數init(),後者又調用所有的A<0>::init(),B<1>::init()等。 我試着寫SeqInst爲var

    9熱度

    2回答

    我需要構建n個類型的元組。這n個類型是n個其他類型的值類型。考慮這個片斷: #include <boost/hana.hpp> namespace hana = boost::hana; template<class... Types> class CartesianProduct { public: CartesianProduct(Types... args) : se

    2熱度

    3回答

    下面是兩個大部分相同的模板PgmArray和PgmArrayF。第一個適用於左值參考模板參數,第二個適用於整型參數。我喜歡將這兩個合併爲一個: #include <stdint.h> #include <type_traits> #include <array> #include <iostream> template<typename T, const T&... Ts> struc

    0熱度

    2回答

    template <typename T, template <typename T, typename... Targs> class C> void print_(const C<T,Targs>& arg, std::stringstream& ss) { std::for_each(arg.begin(), arg.end(), [&ss](const T& var) { s

    1熱度

    1回答

    給出一個簡單的variadoc模板 template<typename... T> class A {}; 以及兩個或多個概念C1和C2像 template<typename T> concept bool C1() { ... }; 如何申請的C1和C2連詞在A參數包的所有元素上,如: template<typename... T> requires C1<T>... || C2<

    1熱度

    1回答

    我搜索了很多,可以找到許多類似的問題,但他們都沒有解決這個特定的問題AFAIK。 我想通過類型(而不是索引)來替換元組中的類型。我試過這樣的: template <class Tuple, class ToRemove, class ToReplace> struct ReplaceType { using type = Tuple; }; template <class ToR

    0熱度

    3回答

    我想用一個函數傳遞參數給不同的類,所以我用類模板專業化和可變參數函數模板,波紋管是代碼: #include <iostream> using namespace std; template <typename T0, typename T1> class Package { T0 Data0; T1 Data1; public: Package(T0 da

    0熱度

    2回答

    我想在C++ 11中使用vadiadic模板來定義一個IntList類,但是我在語法上遇到困難,我不知道如何初始化班級領域。 我的最新版本如下: template <int...> struct IntList; template<> struct IntList<>{ constexpr static bool empty = true; constexpr stat

    2熱度

    2回答

    基地問題 基礎問題我試圖解決推斷「自動」是這樣的: 我有一個模板參數包ArgTypes,我需要做一個元組每個類型都包裝在std :: optional中。例如:make_optional_tuple<int, double, std::string>應該返回一個元組元組的元組元組,其元素元組的初始值爲std::nullopt。 我的工作至今 我使用附帶GCC 7.1 g++。我一直在與C++類型系