> On March 4, 2015, 4:13 a.m., Michael Park wrote: > > I think there's value in keeping `JSON::Array` to have the symmetric > > interface as `std::vector`. > > > > Currently, > > > > ```cpp > > JSON::Array array(N); > > // array.values.size() == 0 > > ``` > > > > The equivalent-looking pattern is deceiving: > > > > ```cpp > > std::vector v(N); > > // v.size() == N > > ``` > > > > I think it would be less confusing for especially for people who are > > familiar with the standard library to keep: > > > > ```cpp > > JSON::Array array; > > array.reserve(N); > > // array.values.size() == N > > ``` > > > > ```cpp > > std::vector v; > > v.reserve(N); > > // v.size() == N > > ``` > > Michael Park wrote: > Oops, the second pair of examples should read: > > ```cpp > JSON::Array array; > array.reserve(N); > // array.values.size() == 0 > ``` > > ```cpp > std::vector v; > v.reserve(N); > // v.size() == 0 > ```
Vector and `JSON::Array` are rather different in a way they are used. There is not much sense to create a `JSON::Array` populated with variants. From the other side, reserving capacity seems like a required feature, and having such a c-tor will save us lines of code. Therefore I don't see much value in maintaining the symmetry with `std::vector`. - Alexander ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/31699/#review75147 ----------------------------------------------------------- On March 3, 2015, 8:11 p.m., Alexander Rukletsov wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/31699/ > ----------------------------------------------------------- > > (Updated March 3, 2015, 8:11 p.m.) > > > Review request for mesos and Ben Mahler. > > > Bugs: MESOS-2353 > https://issues.apache.org/jira/browse/MESOS-2353 > > > Repository: mesos > > > Description > ------- > > See summary. > > > Diffs > ----- > > 3rdparty/libprocess/3rdparty/stout/include/stout/json.hpp > 334c898906018be6e663f53815abbe047806b95c > > Diff: https://reviews.apache.org/r/31699/diff/ > > > Testing > ------- > > make check (OS X 10.9.5, Ubuntu 14.04) > > > Thanks, > > Alexander Rukletsov > >
