テンプレート引数控除
-
29-10-2019 - |
質問
私は現在、自分自身を解決することができなかった問題に直面しています。基本的に私がやろうとしていることは、C ++にLinqのような動作を実装することです。
ヘッダーのコードから始めます。
template<typename T, template<class = T> class A,
template<class = T, template<class=T> class = A> class C>
class queryable
{
public:
typedef T value_type;
typedef A<value_type> allocator_type;
typedef C<value_type, allocator_type> container_type; // (1)
typedef queryable<T, A, C> type;
queryable(container_type const &) { }
template<typename _Out> queryable<_Out, A, C> select(/* some delegate */);
// more methods etc
}
そして、これが私がそれをインスタンス化したい方法です:
std::vector<int> my_vec;
queryable<std::vector<int> > q(my_vec);
言うまでもなく、これはうまくいかない(私はここにいないだろう:))
今、さらに見知らぬ部分は、これでさえうまくいかないように見えるということです:
std::vector<int> my_vec;
queryable<int, std::allocator, std::vector> q(my_vec);
あなたが見ることができるように(選択関数を見ることによって)、私にとっては、このようなものを使用するだけではありません。
template<typename T> class queryable;
これを解決する方法についての提案はありますか?そして、これは可能ですか?
どんな助けも感謝します!
編集:私が取得しているエラー:
../entry.cpp:19:58: error: type/value mismatch at argument 3 in template parameter list for ‘template<class T, template<class> class A, template<class, template<class> class<template-parameter-2-2> > class C> class failproof::collections::queryable’
../entry.cpp:19:58: error: expected a template of type ‘template<class, template<class> class<template-parameter-2-2> > class C’, got ‘template<class _Tp, class _Alloc> class std::vector’
../entry.cpp:19:61: error: invalid type in declaration before ‘;’ token
編集2:
私が理解している限り、コンパイラは、Cが2つのクラスの引数を取得していないのではなく、1つのクラスの引数と1つのテンプレートクラスの引数(1)について不平を言っています。この問題を解決する方法はありますか?
正しい解決策はありません
所属していません StackOverflow