1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ITSOLV_WRAP_H
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ITSOLV_WRAP_H
11using VecRef = std::vector<std::reference_wrapper<A>>;
14using CVecRef = std::vector<std::reference_wrapper<const A>>;
19 using type = std::decay_t<T>;
23struct decay<std::reference_wrapper<T>> {
24 using type = std::decay_t<T>;
31template <
class ForwardIt>
32auto wrap(ForwardIt begin, ForwardIt end) {
35 for (
auto it = begin; it != end; ++it)
36 w.push_back(std::ref(*it));
41template <
class ForwardIt>
45 for (
auto it = begin; it != end; ++it)
46 w.push_back(std::ref(
const_cast<decay_t<T>&
>(it->get())));
51template <
class ForwardIt>
52auto cwrap(ForwardIt begin, ForwardIt end) {
55 for (
auto it = begin; it != end; ++it)
56 w.push_back(std::cref(*it));
67template <
class IterableContainer>
68auto wrap(
const IterableContainer& parameters) {
69 using T =
typename IterableContainer::value_type;
73 for (
auto it = begin(parameters); it != end(parameters); ++it)
74 w.emplace_back(std::cref(*it));
85template <
class IterableContainer>
86auto wrap(IterableContainer& parameters) {
87 using T =
typename IterableContainer::value_type;
91 for (
auto it = begin(parameters); it != end(parameters); ++it)
92 w.emplace_back(std::ref(*it));
102template <
class IterableContainer>
104 using T =
typename IterableContainer::value_type;
108 for (
auto it = begin(parameters); it != end(parameters); ++it)
109 w.emplace_back(std::ref(
const_cast<decay_t<T>&
>(it->get())));
120template <
class IterableContainer>
121auto cwrap(IterableContainer& parameters) {
122 using T =
typename IterableContainer::value_type;
126 for (
auto it = begin(parameters); it != end(parameters); ++it)
127 w.emplace_back(std::cref(*it));
134template <
typename T,
typename... S>
140 w.emplace_back(std::ref(arg));
141 (w.emplace_back(std::ref(args)), ...);
148template <
typename T,
typename... S>
154 w.emplace_back(std::cref(arg));
155 (w.emplace_back(std::cref(args)), ...);
4-parameter interpolation of a 1-dimensional function given two points for which function values and ...
Definition: helper.h:10
auto cwrap(ForwardIt begin, ForwardIt end)
Takes a begin and end iterators and returns a vector of references to each element.
Definition: wrap.h:52
auto wrap_arg(T &&arg, S &&... args) -> std::enable_if_t< std::conjunction_v< std::is_same< decay_t< T >, decay_t< S > >... >, VecRef< decay_t< T > > >
Constructs a vector of reference wrappers with provided arguments.
Definition: wrap.h:135
typename decay< T >::type decay_t
Definition: wrap.h:28
auto cwrap_arg(T &&arg, S &&... args) -> std::enable_if_t< std::conjunction_v< std::is_same< decay_t< T >, decay_t< S > >... >, CVecRef< decay_t< T > > >
Constructs a vector of const reference wrappers with provided arguments.
Definition: wrap.h:149
auto wrap(ForwardIt begin, ForwardIt end)
Takes a begin and end iterators and returns a vector of references to each element.
Definition: wrap.h:32
std::vector< std::reference_wrapper< const A > > CVecRef
Definition: wrap.h:14
auto const_cast_wrap(ForwardIt begin, ForwardIt end)
Takes a begin and end iterators and returns a vector of const-casted references to each element.
Definition: wrap.h:42
std::vector< std::reference_wrapper< A > > VecRef
Definition: wrap.h:11
std::decay_t< T > type
Definition: wrap.h:24
Decays CV and reference qualifiers same as std::decay, but also decays std::reference_wrapper to its ...
Definition: wrap.h:18
std::decay_t< T > type
Definition: wrap.h:19