`back_emplacer` implementation: default operator= vs universal reference version?

前端 未结 2 1753
悲&欢浪女
悲&欢浪女 2021-01-22 18:18

In the context of this question, here is an implementation of a C++11 back_emplacer that uses emplace_back instead of how std::back_inserter

2条回答
  •  半阙折子戏
    2021-01-22 19:08

    Just as for copy-constructors, copy-assignment operators are not templates (12.8/17):

    A user-declared copy assignment operator X::operator= is a non-static non-template member function of class X...

    You still get the implicitly-declared copy-assignment and move-assignment operators, and they are im­pli­cit­ly-defined if odr-used, and they participate in overload resolution (so if your arguments match X const & or X && precisely, those will be preferred over the templated operator=).

提交回复
热议问题