Marcel Mueller <
news.5...@spamgourmet.org> wrote:
> Am 20.06.19 um 11:35 schrieb Juha Nieminen:
>> Marcel Mueller <
news.5...@spamgourmet.org> wrote:
>>> Am 19.06.19 um 12:40 schrieb Juha Nieminen:
>>>> class AClass
>>>> {
>>>> public:
>>>> using Inner = ANamespace::Data;
>>>> };
>>>>
>>>> // This compiles???
>>>> bool AClass::Inner::operator<(const Data& rhs) const
>>>> {
>>>> return mValue < rhs.mValue;
>>>> }
>>>
>>> Why should it fail?
>>
>> Because Data is not an inner class of AClass?
>
> Ah, you refer to the 'const Data&'.
No. operator<() is not a member function of AClass::Inner, because
AClass::Inner isn't a class at all. operator<() a member function of
ANamespace::Data. It thus feels extremely counter-intuitive to
define it as a member function of AClass::Inner, which is not a
class of any kind.
Incidentally, this won't compile:
bool AClass::Inner::operator<(const Inner& rhs) const
but this does:
bool AClass::Inner::operator<(const AClass::Inner& rhs) const