On Thu, 2008-10-16 at 11:20 -0400, Andrew Stitcher wrote: > On Tue, 2008-10-14 at 10:11 -0400, Alan Conway wrote: > > ... > > > I'd like to see a set of template <class T> get() functions to make the > > FT more accessible to templated code. That could be in addition to the > > plain functions for template-shy compilers/developers. It could be done > > in a separate FieldTableTraits class, but built-in members would be more > > convenient. > > > > +1 > > I was thinking of adding this as well, but wanted to go one step at a > time. > > I'm not clear in my own head at this point whether these would be > additional to or instead of the current > bool getXXX(const string& name, XXX& value); > member. >
> For clarity I'd be adding a member with signature: > template <typename T> > bool get(const string& name, T& value); > I've been using this pattern: template <class T> T* get(const string& name); returning 0 for not present. It's used in qpid::Url, AMQHeaderBody and the never-quite-finished amqp_0_10::Map I prefer it somewhat - it avoids copying the value and is more convenient in some uses - e.g. if you just want to test the type: if (ft->get<SomeType>()) I can live with either though.
