Utility Rack
|
A utility to perfectly forward function template parameters in lambda captures. More...
#include <tuple>
#include <utility>
Go to the source code of this file.
Macros | |
#define | CHOPS_FWD(...) |
#define | CHOPS_FWD_CAPTURE(...) |
Functions | |
template<typename... Ts> | |
auto | chops::detail::fwd_capture (Ts &&... xs) |
template<typename T > | |
decltype(auto) | chops::access (T &&x) |
A utility to perfectly forward function template parameters in lambda captures.
This code is copied from Vittorio Romeo's blog at https://vittorioromeo.info/, specifically: https://vittorioromeo.info/index/blog/capturing_perfectly_forwarded_objects_in_lambdas.html.
It is not easy to perfectly forward function template parameters in a lambda capture. In particular, a function object passed through a forwarding reference should be passed as either an rvalue or lvalue reference, depending on what was passed in (which of course is what a forwarding reference is all about). Capturing and preserving the forwarding reference in a lambda is complicated (more so than it should be). This utility provides a wrapper class, which (as in so many software design problems) solves the problem with a layer of indirection.
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define CHOPS_FWD | ( | ... | ) |
#define CHOPS_FWD_CAPTURE | ( | ... | ) |