|
Boost Users : |
Subject: Re: [Boost-users] [Boost.Assign] list_of::range without an initial (single) element?
From: Michael McNeil Forbes (michael.forbes_at_[hidden])
Date: 2010-06-17 17:54:53
Thorsten Ottosen wrote:
>> In that case, I'm confused about why list_of<int>() inserts a
>> default value.
>
> It was a consistency issue. Consider
>
> list_of<int>()(42); // 0, 42
> list_of<int>(42)(); // 42, 0
> list_of(42)(); // 42, 0
>
> would you expect that to be any different?
I suppose the only consistent interpretation would be for either () to
be a no-op (no default's)
Proposal 1:
list_of<int>()(42); // 42
list_of<int>(42)(); // 42
list_of(42)(); // 42
or the slightly more complex rule that the default constructor always
returns an empty list and () only inserts after the list has been
created:
Proposal 2:
list_of<int>(42); // 42
list_of<int>()(42); // 42
list_of<int>(42)(); // 42, 0
list_of(42); // 42
list_of()(42); // 42
list_of(42)(); // 42, 0
list_of<int>()(); // 0
list_of()(); // 0
Michael.
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