1 #ifndef fhiclcpp_types_OptionalTupleAs_h 2 #define fhiclcpp_types_OptionalTupleAs_h 21 template <
typename T,
typename... ARGS>
22 class OptionalTupleAs;
24 template <
typename T,
typename... ARGS>
31 std::function<
bool()> maybeUse);
36 if (
auto via = tupleObj_()) {
37 return make_optional(std::make_from_tuple(*via));
46 auto t = operator()();
56 return tupleObj_.hasValue();
65 std::string
const preface =
66 "N.B. The following sequence is converted to type:";
67 std::string
const name =
68 " '" + cet::demangle_symbol(
typeid(T).name()) +
"'";
69 std::string
const user_comment =
70 comment.
value.empty() ?
"" :
"\n\n" + comment.value;
72 std::ostringstream oss;
73 oss << preface <<
'\n' << name << user_comment;
75 return Comment{oss.str().c_str()};
82 template <
typename T,
typename... ARGS>
87 template <
typename T,
typename... ARGS>
89 : tupleObj_{std::move(name), conversion_comment(std::move(comment))}
92 template <
typename T,
typename... ARGS>
95 std::function<
bool()> maybeUse)
96 : tupleObj_{std::move(name),
97 conversion_comment(std::move(comment)),
Comment conversion_comment(Comment &&comment) const
bool operator()(T &result) const
OptionalTuple< ARGS... > tupleObj_
std::optional< T > operator()() const