Boost logo

Boost Users :

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


AMDG

On 03/25/2014 10:04 AM, Samuel Christie wrote:
> Maybe we could do something like your previous example that did some
> conversion and checking in the concept interface?

The code I posted at the end is somewhat similar
to the code for handling the arguments, I suppose.
You only need the conversion, not the checks, since
the return value automatically has the correct type,
modulo any bugs in the concept definition.

> I really only need to
> know whether or not it was already in the collection. I don't actually need
> the iterator for the matching item.
>

Since you don't need the iterator, why don't
you just return bool?

template<class C, class T>
struct has_insert {
  static bool apply(C& c, const T& t)
  {
    return c.insert(t).second;
  }
};

// basic concept_interface

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net