Questions related to use of C++ compiler-generated functions, generated implicitly, or explicitly by use of = default.
Questions tagged [defaulted-functions]
19 questions
1
vote
2 answers
What are the pros and cons of always declaring defaulted constructors?
What are the pro and cons of declaring always defaulted constructors for each non user-defined constructor?
Consider a class with a user-defined constuctor which does not need other user-defined constructors, it would be:
class Foo
{
public:
…

Moia
- 2,216
- 1
- 12
- 34
1
vote
3 answers
Efficiently creating C++11 move and copy aware structs
I am trying to put together an efficient C++1x struct that can take advantage efficient std::move/copy construct/and assignment operations. These structs fall into 2 basic categories, POD structs and non-POD structs. I have gotten into the habit…

johnco3
- 2,401
- 4
- 35
- 67
0
votes
0 answers
error: use of deleted function operator=(&&) with std::optional
I got myself an error sprouting from std::optional. Now when trying to reconstruct it, there seems to be something going on with defaulted ctors that I don't yet understand. Consider the following abstracted example:
I'm assigning a config struct…

glades
- 3,778
- 1
- 12
- 34
0
votes
1 answer
Declaration of operator has a different exception specifier
I am trying to "=default" my friend functions but keep getting the following error:
a4.cpp:180:17: error: declaration of ‘bool operator==(const playing_card&, const playing_card&) noexcept’ has a different exception specifier
180 | friend…

mariacat
- 25
- 2