jeudi 25 mai 2017

Default constructor with std::reference_wrapper as member?

I have this struct:

struct MyStruct
{
    MyStruct(const Wrapper &wrapper, /*...*/) :
        wrapper(std::cref(wrapper)), /*...*/ {}

    std::reference_wrapper<Wrapper const> wrapper;
    /*...*/
};

However, now I want to use a tbb::concurrent_bounded_queue<MyStruct>, which is not possible since MyStruct doesn't have a default constructor. But I don't know how to define it since wrapper must be initialized somehow. Is there any solution for this (apart from using raw pointers)?

Aucun commentaire:

Enregistrer un commentaire