-2

次のコードでは、push_back()astd::refへの a のstd::vector<reference_wrapper<Type>>割り当てはうまくいきますが、 astd::refへの a の割り当てはreference_wrapper<Type>機能しません。なんで?

#include <iostream>
#include <vector>
#include <functional>
using namespace std;

struct Type {};

int main()
{
    Type t1;

    vector<reference_wrapper<Type>> t2;
    t2.push_back( ref(t1) ); // OK

    //reference_wrapper<Type> t3; // error: no matching function for call to std::reference_wrapper<Type>::reference_wrapper()’
    //t3 = ref(t1);

    return 0;
}
4

2 に答える 2