CreateFromOptions.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include "Utilities/TMPL.hpp"
7 #include "Utilities/TaggedTuple.hpp"
8 #include "Utilities/TypeTraits.hpp"
9 
10 namespace Parallel {
11 namespace detail {
12 template <typename Metavariables, typename Tag, typename... OptionTags,
14 typename Tag::type create_initialization_item_from_options(
15  const tuples::TaggedTuple<OptionTags...>& options) noexcept {
16  return tuples::apply<typename Tag::template option_tags<Metavariables>>(
17  [](const auto&... option) noexcept {
18  return Tag::template create_from_options<Metavariables>(option...);
19  },
20  options);
21 }
22 
23 template <typename Metavariables, typename Tag, typename... OptionTags,
25 typename Tag::type create_initialization_item_from_options(
26  const tuples::TaggedTuple<OptionTags...>& options) noexcept {
27  return tuples::apply<typename Tag::option_tags>(
28  [](const auto&... option) noexcept {
29  return Tag::create_from_options(option...);
30  },
31  options);
32 }
33 } // namespace detail
34 
35 /// \ingroup ParallelGroup
36 /// \brief Given a list of tags and a tagged tuple containing items
37 /// created from input options, return a tagged tuple of items constructed
38 /// by calls to create_from_options for each tag in the list.
39 template <typename Metavariables, typename... Tags, typename... OptionTags>
42  tmpl::list<Tags...> /*meta*/) noexcept {
43  return {detail::create_initialization_item_from_options<Metavariables, Tags>(
44  options)...};
45 }
46 } // namespace Parallel
Parallel::create_from_options
tuples::TaggedTuple< Tags... > create_from_options(const tuples::TaggedTuple< OptionTags... > &options, tmpl::list< Tags... >) noexcept
Given a list of tags and a tagged tuple containing items created from input options,...
Definition: CreateFromOptions.hpp:40
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Requires
typename Requires_detail::requires_impl< B >::template_error_type_failed_to_meet_requirements_on_template_parameters Requires
Express requirements on the template parameters of a function or class, replaces std::enable_if_t
Definition: Requires.hpp:67
Parallel
Contains functions that forward to Charm++ parallel functions.
Definition: ElementReceiveInterpPoints.hpp:14
TMPL.hpp