From: Daniel Krügler on
On 8 Apr., 16:06, Mathias Gaunard <loufo...(a)gmail.com> wrote:
> On Apr 8, 12:37 am, Daniel Kr�gler <daniel.krueg...(a)googlemail.com>
> wrote:
>
> > struct CharArrayHashEqual : std::unary_function<const char*,
> > std::size_t>
> > {
> > [...]
> > bool operator(const char* s1, const char* s2) const
>
> What is that supposed to declare?

Good question ;-)

I tried to be lazy and to provide a predicate and a hash function
in one class and that brought me two corrections from mine and
one from you - probably one of the worst code-quality signs ever
given the amount of code.

Anyway, ignoring the missing () after keyword operator for a moment,
but instead focusing on the unary_function base class compared to
the obvious binary predicate existence we could simply remove
the base class at all (to prevent the reader from frowning about that),
because it is not needed to make unordered_map work, or to add
another base class std::binary_function<const char*, const char*, bool>
for completeness.

Nevertheless, I should have provided two separate functors in the
first place to prevent this chaos.

With Greetings from Bremen,

Daniel Kr�gler


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Daniel Krügler on
On 8 Apr., 16:06, Mathias Gaunard <loufo...(a)gmail.com> wrote:
> On Apr 8, 12:37 am, Daniel Kr�gler <daniel.krueg...(a)googlemail.com>
> wrote:
>
> > struct CharArrayHashEqual : std::unary_function<const char*,
> > std::size_t>
> > {
> > [...]
> > bool operator(const char* s1, const char* s2) const
>
> What is that supposed to declare?

Good question ;-)
I tried to be lazy (packing two predicates into one) which brought
me two corrections of mine and an additional one from you.

Except the missing () after the operator keyword we could fix that
by inheriting from both unary_function as well as from
binary_function,
although both base classes are not required to make the predicate
work, because unordered_map (at least the upcoming one from
std does not need the typedefs provided by the std::*_function
base classes.

This was definitely not a good code example and I would have
shown some courage, if I had provided two separate ones in the
first place.

I hope that all this did not cause too much harm,

Daniel Kr�gler


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]