how std::thread constructor detects rvalue reference?

后端 未结 3 1505
栀梦
栀梦 2021-01-14 11:16

Obviously it is possible to pass an rvalue reference to std::thread constructor. My problem is with definition of this constructor in cppreference. It says that

3条回答
  •  太阳男子
    2021-01-14 11:52

    auto s = std::decay_copy(std::string("hello"));
    

    Is equivalent to:

    template<>
    std::string std::decay_copy(std::string&& src) {
        return std::string(std::move(src));
    }
    
    std::string s = decay_copy(std::string("hello"));
    

提交回复
热议问题