> On Sept. 1, 2015, 4:46 p.m., Joseph Wu wrote: > > 3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp, lines 553-555 > > <https://reviews.apache.org/r/37826/diff/3/?file=1061137#file1061137line553> > > > > Can you explain why this is a struct rather than a function? > > Alexander Rukletsov wrote: > It's because we cannot partially specialize function templates and > overload won't work since we take the same argument. Do you think a comment > should be expanded? > > Alexander Rukletsov wrote: > http://www.gotw.ca/publications/mill17.htm > > Joseph Wu wrote: > Yes, I think a comment would be good regardless of how it ends up. > > What about using some C++11 type traits? (But I'm not sure if this will > work.) > Something like: > ``` > // Specialization for non-repeated fields. > template <typename T> > Try<T> parse(const JSON::Value& value, > typename std::enable_if<std::is_base_of<T, > google::protobuf::Message>, int>::type = 0) {...} > ``` > > Note: This file uses some similar Boost type traits further up.
I'm not sure how we can use type traits here. IIUC type traits facilitate compile-time checks, and not compile-time dispatch. If we want to keep the same function signature, we should rely on partial specialization. However, we can still add these checks into `Parse<>::operator()` methods. - Alexander ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/37826/#review97302 ----------------------------------------------------------- On Sept. 1, 2015, 2:20 p.m., Alexander Rukletsov wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/37826/ > ----------------------------------------------------------- > > (Updated Sept. 1, 2015, 2:20 p.m.) > > > Review request for mesos, Joseph Wu and Michael Park. > > > Bugs: MESOS-3312 > https://issues.apache.org/jira/browse/MESOS-3312 > > > Repository: mesos > > > Description > ------- > > See summary. > > > Diffs > ----- > > 3rdparty/libprocess/3rdparty/stout/include/stout/protobuf.hpp > 57d5fdf45273c620655b44b5f5572290cffa4bf6 > > Diff: https://reviews.apache.org/r/37826/diff/ > > > Testing > ------- > > make check (Mac OS 10.10.4) > > > Thanks, > > Alexander Rukletsov > >
