|
Boost : |
Subject: [boost] Formale Review: Callable Traits
From: Peter Dimov (lists_at_[hidden])
Date: 2017-04-10 18:48:33
I think that the Callable Traits library should be ACCEPTED.
The design of the library is sound, although I'm not fond of the ad-hoc
metaprogramming part in "parameter list features". This is no fault of the
author though, as without a modern type-metaprogramming library in Boost,
everyone has to solve this problem in some way. Still, I think that most of
these should be removed.
Getting the arguments as a tuple that includes the class type as a first
parameter raises the obvious question of
void(foo::*)(float, char, int) -> tuple<foo&, float, char, int>
void(foo::*)(float, char, int) & -> tuple<foo&, float, char, int>
I understand why that is, but it still makes args lossy and the original
can't be recreated from the tuple. Trailing varargs also have the same
problem, as (float) and (float, ...) map to the same tuple.
The obvious theoretically consistent approach here is
void(foo::*)(float, char, int) -> tuple<foo, float, char, int>
and
void(float, ...) -> tuple<float, ct::varargs_t>
which would be fully reversible but could possibly be less convenient in
practice.
I've a feeling that it might also be useful to provide an extractor that,
for member pointers, returns just the arguments without the class.
In "member qualifier features", I'm missing remove_member_cv_ref (obvious
semantics) and copy_member_cv_ref (copies cv+ref from one member pointer to
another.)
In "member pointer features" we have the same problem in
qualified_parent_class_of as in args,
void(foo::*)() -> foo&
void(foo::*)() & -> foo&
It makes more sense for the first to yield 'foo', although this again may
make the trait less convenient in practice.
It would also _probably_ make sense to provide
apply_qualified_member_pointer, which, given void(float) and foo const&,
would yield void (foo::*)(float) const&.
I did not look at the implementation.
I ran the test suite on Windows under Cygwin g++ 5 in 11/14/1z, Cygwin clang
3.9 11/14/1z, msvc-14.0, msvc-14.1. The tests passed. Took a look at the
tests themselves, the coverage looks excellent.
The reference documentation is very good, although as already noted, it uses
the terms of art "implementation defined" and "undefined behavior"
incorrectly, this must be fixed.
The non-reference portion is a bit thin. It would be improved considerably
by presenting a few real-world use cases.
All in all, a solid library that solves a real problem, even though the
problem remains somewhat of a mystery for the uninitiated. :-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk