glfn(3) glfn(3)

NAME

glfn - function forward adaptor

SYNOPSIS

#include <cfl/functions/glfn.hpp>
#include <cfl/tuple/tuple.hpp>
#include <cfl/access/atK.hpp>

decltype (      tuple  (0)) == tuple_c <int   >;
decltype (glfn (tuple) (0)) == tuple_c <int &&>;

decltype (      getN <0>  (tuple (0))) == int   );
decltype (glfn (getN <0>) (tuple (0))) == int &&);

DESCRIPTION

glfn is short for generalized lvalue function, and adapts a function to return by the generalized lvalue 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 constructed from factories.

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.

glfn is primarily used to avoid constructing values and instead use references, when the caller can guarantee object lifetimes from the context.

glfn is a shallow operation, and does not recursively descend into container like prvalue and noxvalue.

RETURN VALUES

Another function adapted to use glvalues instead of standard CFL storage. When the argument function does not support such adaption, glfn is a no-op and the argument is returned unchanged.

NOTE

glfn is not a container function.

SEE ALSO

conventions(5), prfn(3), prvalue(3)