Loading [MathJax]/extensions/TeX/AMSsymbols.js
Automatic Differentiation
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches

◆ make_holder_tuple()

template<typename... Types>
constexpr auto stan::math::make_holder_tuple ( Types &&...  args)
inlineconstexpr

Holds ownership of rvalues and forwards lvalues into a tuple.

Constructs a tuple from the provided arguments such that:

  • If an argument is an xvalue (an rvalue), the tuple element will be a decayed value.
  • If an argument is an lvalue (or const lvalue), the tuple element will maintain its reference type.

This behavior ensures that temporaries are stored by value in the tuple while lvalues are preserved as references. It is similar in intent to the Holder class in behavior, but for tuples instead of Eigen types. It is the opposite of std::forward_as_tuple, with the difference in handling rvalues. std::forward_as_tuple does not extend object lifetimes, so when an rvalue is passed to std::forward_as_tuple, the resulting tuple element will be a reference to a temporary that is destroyed at the end of the statement. This function ensures that rvalues are stored by value in the tuple, extending their lifetimes.

Template Parameters
TypesParameter pack representing the types of the arguments.
Parameters
argsThe arguments to forward into the tuple.
Returns
A tuple containing the forwarded arguments with types deduced via deduce_cvr_t.
Note
The function is declared constexpr. It is noexcept when, for each input type, the type value coming in is either an lvalue reference or an rvalue type whose move constructor is nothrow

Definition at line 66 of file make_holder_tuple.hpp.