prfn(3) | prfn(3) |
prfn - function prvalue adaptor
#include <cfl/functions/prfn.hpp>
#include <cfl/tuple/tuple.hpp>
#include <cfl/access/atK.hpp>
int i {0};
decltype ( tuple (i)) == tuple_c <int &>;
decltype (prfn (tuple) (i)) == tuple_c <int >;
decltype ( atN <0> (tuple (i))) == int &);
decltype (prfn (atN <0>) (tuple (i))) == int );
prfn
is short for pure rvalue function, and adapts a function to return by
the pure rvalue category (as described by the C++ specification in
[basic.lval]), instead of using standard CFL storage (as described in
conventions). Such adaption is normally supported by
all CFL functions.
Normally, this is applicable when accessing or creating an inner value of a
container. A maybe familiar example from std
of such a distinction is
make_tuple
and forward_as_tuple
.
prfn
is primarily used to avoid storing references in containers, such as when
returning from a scope.
prfn
is a shallow operation, and does not recursively descend into
containers like prvalue
and noxvalue
.
Another function adapted to use prvalues instead of standard CFL storage. When
the argument function does not support such adaption, prfn
is a no-op and the
argument is returned unchanged.
prfn
is not a container function.
conventions(5), glfn(3), prvalue(3)