File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 64006400
64016401\pnum
64026402A defaulted comparison operator function\iref {over.binary }
6403- for some class \tcode {C}
64046403shall be a non-template function
6405- that is
6404+ that
64066405\begin {itemize }
64076406\item
6408- a non-static member or friend of \tcode {C} and
6407+ is a non-static member or friend of some class \tcode {C},
6408+
6409+ \item
6410+ is defined as defaulted in \tcode {C} or in
6411+ a context where \tcode {C} is complete, and
64096412
64106413\item
64116414either has
64146417where the implicit object parameter (if any) is considered to be
64156418the first parameter.
64166419\end {itemize }
6420+ Such a comparison operator function is termed
6421+ \indextext {operator!defaulted comparison operator function}%
6422+ a defaulted comparison operator function for class \tcode {C}.
64176423Name lookups in the implicit definition\iref {dcl.fct.def.default }
64186424of a comparison operator function
64196425are performed from a context equivalent to
64206426its \grammarterm {function-body}.
64216427A definition of a comparison operator as
64226428defaulted that appears in a class shall be the first declaration
64236429of that function.
6430+ \begin {example }
6431+ \begin {codeblock }
6432+ struct S;
6433+ bool operator==(S, S) = default; // error: \tcode {S} is not complete
6434+ struct S {
6435+ friend bool operator==(S, const S&) = default; // error: parameters of different types
6436+ };
6437+ enum E { };
6438+ bool operator==(E, E) = default; // error: not a member or friend of a class
6439+ \end {codeblock }
6440+ \end {example }
64246441
64256442\pnum
64266443A defaulted \tcode {<=>} or \tcode {==} operator function for class \tcode {C}
Original file line number Diff line number Diff line change 64036403is called an \defnx {explicitly-defaulted}{definition!function!explicitly-defaulted} definition.
64046404A function that is explicitly defaulted shall
64056405\begin {itemize }
6406- \item be a special member function or
6407- a comparison operator function\iref {over.binary }, and
6408- \item not have default arguments.
6406+ \item be a special member function\iref { special } or
6407+ a comparison operator function\iref {over.binary, class.compare.default }, and
6408+ \item not have default arguments\iref { dcl.fct.default } .
64096409\end {itemize }
64106410
64116411\pnum
You can’t perform that action at this time.
0 commit comments