how std::thread constructor detects rvalue reference?

后端 未结 3 1541
栀梦
栀梦 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:57

    It is common problem of the perfect forwarding. If you want to restore information about rvalue in the function, you have to use std::forward std::forward . If you are interested in the value type detection you may read this value_category . From the description you can find the information how the compiler recognizes rvalue, xvalue, lvalue, prvalue, gvalue on compile time.

提交回复
热议问题