object_threadsafe icon indicating copy to clipboard operation
object_threadsafe copied to clipboard

Corrections constructor

Open sv-91 opened this issue 4 years ago • 2 comments

2 correction:

  1. std::forward
  2. make_safe instead constructor

sv-91 avatar Oct 11 '19 06:10 sv-91

A few words why is it better to use make_safe instead constructor?

AlexeyAB avatar Oct 11 '19 13:10 AlexeyAB

Template parameter in the constructor sometimes causes a compilation error. Since the compiler cannot distinguish 2 constructors.

template<class B> A(B &&)

and

A(const A&)

https://mpark.github.io/programming/2014/06/07/beware-of-perfect-forwarding-constructors/

Instead of this method, you can try sfinae

sv-91 avatar Oct 11 '19 13:10 sv-91