Date: Sun, 29 Nov 2026 11:14:39 -0800
On Sunday, 29 November 2026 10:12:34 Pacific Standard Time Aleksandr Povaliaev
wrote:
> [[[[[Below]]]]]....
Please use a good email client for mailing lists.
> [[[[[Alex]]]]] You should probably use the following code construction:
>
> namespace PlainPODs {
>
> #include <PlainPODs.h>
>
> operator == (const POD& left, const POD & right) { ... }
>
> template<>
> std::hash<POD>(...) { ...}
>
> }
No, you shouldn't. That will get automatically rejected in any project I have
ever been a part of, for putting an #include inside a namespace declaration.
It works, but it's uncommon and very fragile - what happens if somewhere else
you don't do it?
More importantly, what if this isn't the C Standard Library, but some other
project that might suddenly decide to offer C++ API? And if they do that, they
may provide the operator==.
In any case, unless you want to make the above mandatory -- which you won't
and which would be rejected even faster than the std::unordered_set change
we're discussing-not-proposing -- then your other idea won't be acceptable
either.
> > > AGAIN: I already wrote this example, but would like to repeat it. Please
> > > consider the case when you're importing a dynamic and static library
> > > where
> > > a class is declared but its internal comparison == (POD) operator
> > > implementation is hidden. So, the class does have a comparison operator
> > > declared, but you don't see its implementation.
> >
> > And how should one use such a class?
>
> [[[[Alex]]]] See code snippet above - the same approach
Rejected. My opinion is the one that matters.
Plus, it's an ODR violation to declare the operator again, even if you
couldn't see the declaration this other library's declaration.
Ground rule: you must not declare operators and std::hash for types you don't
own. So how do you use those types in a hash, map, or set?
> [[[[[Alex]]]]] Almost all use-cases discussed are the result of not using
> default operator == and std::hash<>.
> So, a compile time warning just informs the user about possible
> consequences.
And I'm pretty sure they already knew that before the warning. What value is
the warning then?
> > Second, as I said above: if you meant for this equivalence to exist, then
> > you
> > must accept the replacement or non-replacement of equivalent but not
> > identical
> > keys. If you don't, then yes this is an error in the program. You're
> > assuming
> > that all such cases are errors and therefore any comparators that are not
> > the
> > type's operator== are wrong. That assumption is incorrect.
>
> [[[[[Alex]]]]] Nop. In case of std::string you should use
> using eng_string = std::basic_string<eng_traits>;
> using fre_string = std::basic_string<fre_traits>;
> using ger_string = std::basic_string<ger_traits>;
That will never be accepted in any project. First of all, there are no traits
for translation. At best what you could do is set up a wrapper around the same
char_traits that do exactly the same thing, but are a different type. I don't
think that's a good design: what's the purpose of different types that do
exactly the same?
Second, strings are meant to be interchangeable, despite the language. How
would you print / format / display different languages' strings? Are you going
to require that a font-formatting code be templated and inline so that it can
take any basic_string specialisation?
Third, language selection is a runtime decision. Please stop and think about
how you'd write code that supports all current 350 languages in the CLDR
database (plus any regional and script variants) that the user may select.
You've come up with this idea to support your argument, but you have not
thought it through. That probably means you don't have a good idea of your
problem in the first place.
Fourth, this boat also sailed 25 years ago. Unless this is very dangerous
content (such as std::auto_ptr was), it's not going to change. And it's not.
> and every trait will implement a different case-insensitive comparison
> mechanism.
std::char_traits has no case-insensitive comparison function.
> So, you won't needed:
> (1) to specify CompPred each time, you're going to use STL associative
> container;
> (2) to store somewhere a flag specifying what particular language does a
> string belongs to (int eng_flag = {English, French, German};
(2) is pure nonsense; see above.
wrote:
> [[[[[Below]]]]]....
Please use a good email client for mailing lists.
> [[[[[Alex]]]]] You should probably use the following code construction:
>
> namespace PlainPODs {
>
> #include <PlainPODs.h>
>
> operator == (const POD& left, const POD & right) { ... }
>
> template<>
> std::hash<POD>(...) { ...}
>
> }
No, you shouldn't. That will get automatically rejected in any project I have
ever been a part of, for putting an #include inside a namespace declaration.
It works, but it's uncommon and very fragile - what happens if somewhere else
you don't do it?
More importantly, what if this isn't the C Standard Library, but some other
project that might suddenly decide to offer C++ API? And if they do that, they
may provide the operator==.
In any case, unless you want to make the above mandatory -- which you won't
and which would be rejected even faster than the std::unordered_set change
we're discussing-not-proposing -- then your other idea won't be acceptable
either.
> > > AGAIN: I already wrote this example, but would like to repeat it. Please
> > > consider the case when you're importing a dynamic and static library
> > > where
> > > a class is declared but its internal comparison == (POD) operator
> > > implementation is hidden. So, the class does have a comparison operator
> > > declared, but you don't see its implementation.
> >
> > And how should one use such a class?
>
> [[[[Alex]]]] See code snippet above - the same approach
Rejected. My opinion is the one that matters.
Plus, it's an ODR violation to declare the operator again, even if you
couldn't see the declaration this other library's declaration.
Ground rule: you must not declare operators and std::hash for types you don't
own. So how do you use those types in a hash, map, or set?
> [[[[[Alex]]]]] Almost all use-cases discussed are the result of not using
> default operator == and std::hash<>.
> So, a compile time warning just informs the user about possible
> consequences.
And I'm pretty sure they already knew that before the warning. What value is
the warning then?
> > Second, as I said above: if you meant for this equivalence to exist, then
> > you
> > must accept the replacement or non-replacement of equivalent but not
> > identical
> > keys. If you don't, then yes this is an error in the program. You're
> > assuming
> > that all such cases are errors and therefore any comparators that are not
> > the
> > type's operator== are wrong. That assumption is incorrect.
>
> [[[[[Alex]]]]] Nop. In case of std::string you should use
> using eng_string = std::basic_string<eng_traits>;
> using fre_string = std::basic_string<fre_traits>;
> using ger_string = std::basic_string<ger_traits>;
That will never be accepted in any project. First of all, there are no traits
for translation. At best what you could do is set up a wrapper around the same
char_traits that do exactly the same thing, but are a different type. I don't
think that's a good design: what's the purpose of different types that do
exactly the same?
Second, strings are meant to be interchangeable, despite the language. How
would you print / format / display different languages' strings? Are you going
to require that a font-formatting code be templated and inline so that it can
take any basic_string specialisation?
Third, language selection is a runtime decision. Please stop and think about
how you'd write code that supports all current 350 languages in the CLDR
database (plus any regional and script variants) that the user may select.
You've come up with this idea to support your argument, but you have not
thought it through. That probably means you don't have a good idea of your
problem in the first place.
Fourth, this boat also sailed 25 years ago. Unless this is very dangerous
content (such as std::auto_ptr was), it's not going to change. And it's not.
> and every trait will implement a different case-insensitive comparison
> mechanism.
std::char_traits has no case-insensitive comparison function.
> So, you won't needed:
> (1) to specify CompPred each time, you're going to use STL associative
> container;
> (2) to store somewhere a flag specifying what particular language does a
> string belongs to (int eng_flag = {English, French, German};
(2) is pure nonsense; see above.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Received on 2026-11-29 19:14:58
