Boost logo

Boost Users :

From: Emil Dotchevski (emil_at_[hidden])
Date: 2008-08-19 19:24:12


On Tue, Aug 19, 2008 at 3:59 PM, Daryle Walker <darylew_at_[hidden]> wrote:
> On Aug 19, 2008, at 2:59 AM, Zeljko Vrba wrote:
>
>> On Mon, Aug 18, 2008 at 07:05:10PM -0400, Daryle Walker wrote:
>[snip]

I think you guys are making this discussion way too complicated. This
is not about designing graph interface, it's about using an integer
identifier of type that's different from std::vector::size_type, and
avoiding the warnings it leads to.

I'd use something like:

typedef int id_type;

template <class T>
class registry: private std::vector<T>
{
public:

  id_type add( T const & x )
  {
    size_type i=size();
    assert( i<=size_type(std::numeric_limits<id_type>::max()) );
    push_back(x);
    return id_type(i);
  }

  //etc. etc. other operations in addition to "add",
  //instead of using "naked" std::vector.
};

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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