Boost logo

Boost :

From: Robert Kawulak (kawulak_at_[hidden])
Date: 2005-09-28 15:59:07


Hi,

> Use
>
> void initialize(value_type & value_o);
>
> rather than
>
> value_type initialize();
>
> Thus, when passed the data member to initialize, it can
> initialize that object directly. Granted, (N)RVO can often avoid
> the copy, but this change will ensure you get the efficiency.

I don't think so, because your version of initialize couldn't be used to
initialize a value in constructor's initialization list. So first the value
would be default-constructed, and then assigned another value using
initialize.
In bounded policies I use
  passed_value_type initialize()
where passed_value_type is value_type for integral types and const
value_type & for other types. The second returns a reference to a static
object - that's the most efficient method I can think of, initialization
takes only one copy-construction (for details please look into the code).

> > Putting it simply, point of my library is to provide
> templates of classes of
> > objects having a value conforming to given constraints.
> constrained_type (or
> > whatever we'll call it) is a type (class template to be
> strict), how can a
> > type be named "something_value"? Now that's confusing to me... Maybe
> > constrained_values_type would be the most appropriate ;-)
>
> What you are suggesting is equivalent to suggesting that
> std::vector should be named "vector_type" because it is a class
> template.
>
> The purpose of the class template is to create objects through
> instantiating specializations. It is those objects that are
> actually used. Thus, the type name should be indicative of the
> purpose and use of those objects. Those objects are values. The
> class name should indicate the value nature of those objects.

Uhh, maybe you're right ;-) I don't know why, but it just "byte my eyes"
when I see a type named "something_value"... Nevermind, if people here
really resist that it should be called constrained_value instead of
constrained_type, then OK - I'll change it.

Best regards,
Robert


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk