Boost logo

Boost Users :

Subject: Re: [Boost-users] 'Hashable' concept for type erasure
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2014-03-22 19:48:56


On 03/22/2014 04:10 PM, Samuel Christie wrote:
> Next problem I'm having though is using it with an erasure that can be used
> to store anything implementing insert and count as in a std::unordered_set.
> I've tried the following simple test, but it seems to have trouble
> converting between 'int' and the '_value' placeholder type.

This is a bit tricky. I think, first you need to
be very clear about exactly what you want.

When you call history.count(1), the fact that
history holds an unordered_set<int> has been
lost. The library has no way to know at compile
time the value_type is int. So, what do you
want to happen if I write:

history.count("a string");

a) Just don't do that. (i.e. undefined behavior)
b) return 0; since history obviously doesn't
   contain any strings.
c) An exception saying that you tried to pass the
   wrong type.
d) Something else?

In Christ,
Steven Watanabe

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at