私は可変長のテンプレートを使用して柔軟なポインタの単純なタプルを格納するオブジェクト 'S'を持っています。 store()とstore2()の2つのメソッドがあります。最初のもの(店舗)はうまく動作します。 std :: make_tupleがエラーで失敗したので、もう一つはコンパイルされません。C++でポインタのタプルを格納するのに問題があります
make_tuple「への呼び出しに該当する機能 『』
さらにから既知の会話がないことを追加します 『のB *』には、第1引数の 'B * & &'(このエラーはタプルライブラリヘッダーの深い部分です)。
コードはここにある:
#include <tuple>
#include <utility>
template<typename...Rs>
struct S
{
void store(std::tuple<Rs*...> rs)
{
rs_ = rs;
}
void store2(Rs*...rs)
{
rs_ = std::make_tuple<Rs*...>(rs...); // This is the guy that breaks
}
private:
std::tuple<Rs*...> rs_;
};
struct B
{};
struct A : S<B, B>
{};
int main()
{
auto *b1 = new B;
auto *b2 = new B;
auto *a1 = new A;
a1->store(std::make_tuple(b1, b2)); // This works
a1->store2(b1, b2); // How can I get this to work?
// (It causes an error in std::make_tuple of store2 above)
}
FWIW、 'std :: make_tuple(rs ...);'は私のために働きます。私はエラーの説明はありません。 –
ありがとう - これは私のためにも機能します。 – user5406764