0
構造体MyParam
を作成し、任意の数のパラメータ(この場合はint
およびbool
)を使用してインスタンス化できるようにしました。カプセル化の理由から、MyParams
には独自のpromise
が含まれていますので、何かやった時点で報告することができます。しかし、構造体に文を追加すると失敗します。しかし、グローバルとして、それは正常に動作します。メンバーとしてstd :: promiseが含まれていると、構造体のmake_uniqueが失敗するのはなぜですか?
#include <tuple>
#include <memory>
#include <future>
//std::promise<bool> donePromise; // OK: if at global level, then make_unique error goes away
template< typename... ArgsT >
struct MyParams
{
MyParams(ArgsT... args) : rvalRefs { std::forward_as_tuple(args...) } {}
std::tuple<ArgsT...> rvalRefs;
std::promise<bool> donePromise; // causes make_unique to fail when donePromise is a member of MyParams
};
int main()
{
int num { 33 };
bool tf { false };
MyParams< int, bool > myParams(num, tf); // OK
auto myParamsUniquePtr = std::make_unique< MyParams< int, bool > >(myParams);
std::future<bool> doneFuture = myParams.donePromise.get_future(); // OK: when donePromise is a global
return 0;
}
error C2280: 'MyParams<int,bool>::MyParams(const MyParams<int,bool> &)': attempting to reference a deleted function
私がメンバーとしてpromise
声明に関して何をしないのです。ここでは、コードのですか?