A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://timsong-cpp.github.io/cppwp/n4140/dcl.fct.def.default below:

[dcl.fct.def.default]

8.4.2 Explicitly-defaulted functions [dcl.fct.def.default]

A function definition of the form:

attribute-specifier-seqopt decl-specifier-seqopt declarator virt-specifier-seqopt  = default ;

is called an explicitly-defaulted definition. A function that is explicitly defaulted shall

An explicitly-defaulted function may be declared constexpr only if it would have been implicitly declared as constexpr. If a function is explicitly defaulted on its first declaration,

If a function that is explicitly defaulted has an explicit exception-specification that is not compatible ([except.spec]) with the exception-specification on the implicit declaration, then

Example:

struct S {
  constexpr S() = default;                    S(int a = 0) = default;                     void operator=(const S&) = default;         ~S() throw(int) = default;                private:
  int i;
  S(S&);                                    };
S::S(S&) = default;                         

 — end example ]

Explicitly-defaulted functions and implicitly-declared functions are collectively called defaulted functions, and the implementation shall provide implicit definitions for them ([class.ctor] [class.dtor], [class.copy]), which might mean defining them as deleted. A function is user-provided if it is user-declared and not explicitly defaulted or deleted on its first declaration. A user-provided explicitly-defaulted function (i.e., explicitly defaulted after its first declaration) is defined at the point where it is explicitly defaulted; if such a function is implicitly defined as deleted, the program is ill-formed. [ Note: Declaring a function as defaulted after its first declaration can provide efficient execution and concise definition while enabling a stable binary interface to an evolving code base. — end note ]

Example:

struct trivial {
  trivial() = default;
  trivial(const trivial&) = default;
  trivial(trivial&&) = default;
  trivial& operator=(const trivial&) = default;
  trivial& operator=(trivial&&) = default;
  ~trivial() = default;
};

struct nontrivial1 {
  nontrivial1();
};
nontrivial1::nontrivial1() = default;           

 — end example ]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4