What do designers with obvious default do?

Consider the following:

template <class T>
struct myclass
{
    using value_type = T;
    constexpr myclass() = default;
    constexpr myclass(const myclass& other) = default;
    constexpr myclass(const myclass&& other) = default;
    T value;
};
  • In which constructor bodies are these functions equivalent?
  • Does myclass<int> x;integer initialization in 0?
  • For myclass<std::vector<int>> x;what does the default move constructor do? Does it call the vector move constructor?
+4
source share
1 answer

They are not equivalent to any functions. Between the three cases there are small but significant differences: those = defaultthat allow implicit generation and the nearest equivalent function body.

The following links explain in more detail:

copy-constructor; , .


myclass<int> x; value 0.

move ( ) ( , , , ...)

+5

Source: https://habr.com/ru/post/1618026/


All Articles