IAP GITLAB

Commit 2b682639 authored by Hans Dembinski's avatar Hans Dembinski
Browse files

make deduction guide work

parent ff3395ba
Pipeline #933 failed with stages
in 2 minutes and 24 seconds
......@@ -27,19 +27,29 @@ namespace corsika::process {
public:
static constexpr bool is_boundary_crossing =
TSeq::is_boundary_crossing || USeq::is_boundary_crossing;
static constexpr bool is_continuous = TSeq::is_continuous || USeq::is_continuous;
static constexpr bool is_decay = TSeq::is_decay || USeq::is_decay;
static constexpr bool is_interaction = TSeq::is_interaction || USeq::is_interaction;
static constexpr bool is_secondaries = TSeq::is_secondaries || USeq::is_secondaries;
static constexpr bool is_stack = TSeq::is_stack || USeq::is_stack;
std::decay_t<true_seq_t>::is_boundary_crossing ||
std::decay_t<false_seq_t>::is_boundary_crossing;
static constexpr bool is_continuous = std::decay_t<true_seq_t>::is_continuous ||
std::decay_t<false_seq_t>::is_continuous;
static constexpr bool is_decay =
std::decay_t<true_seq_t>::is_decay || std::decay_t<false_seq_t>::is_decay;
static constexpr bool is_interaction = std::decay_t<true_seq_t>::is_interaction ||
std::decay_t<false_seq_t>::is_interaction;
static constexpr bool is_secondaries = std::decay_t<true_seq_t>::is_secondaries ||
std::decay_t<false_seq_t>::is_secondaries;
static constexpr bool is_stack =
std::decay_t<true_seq_t>::is_stack || std::decay_t<false_seq_t>::is_stack;
template <class TPredicate_, class TTrueSeq, class TFalseSeq>
ConditionalProcessSequence(TPredicate_&& pred, TTrueSeq&& true_seq,
TFalseSeq&& false_seq)
: pred_(std::forward<TPredicate_>(pred))
, true_seq_(std::forward<TTrueSeq>(true_seq))
, false_seq_(std::forward<TFalseSeq>(false_seq)) {}
, false_seq_(std::forward<TFalseSeq>(false_seq)) {
static_assert(
is_process_v<std::decay_t<TTrueSeq>> && is_process_v<std::decay_t<TFalseSeq>>,
"arguments must be processes");
}
template <typename TParticle, typename VTNType>
EProcessReturn DoBoundaryCrossing(TParticle& vP, VTNType const& vFrom,
......@@ -142,19 +152,14 @@ namespace corsika::process {
false_seq_t false_seq_;
};
// deduction guides
// deduction guide, see deduction guide of ProcessSequence
template <class P, class T, class U>
ConditionalProcessSequence(P&&, T&&, U &&)
->ConditionalProcessSequence<
P, boost::mp11::mp_rename<std::decay_t<T>, ProcessSequence>,
boost::mp11::mp_rename<std::decay_t<U>, ProcessSequence>>;
// template <class T, class U>
// ConditionalProcessSequence(corsika::units::si::HEPEnergyType, T&&, U &&)
// ->ConditionalProcessSequence<
// ByThreshold, boost::mp11::mp_rename<std::decay_t<T>, ProcessSequence>,
// boost::mp11::mp_rename<std::decay_t<U>, ProcessSequence>>;
P, boost::mp11::mp_if<std::is_rvalue_reference<T>, std::decay_t<T>, T>,
boost::mp11::mp_if<std::is_rvalue_reference<U>, std::decay_t<U>, U>>;
// predicate for deduction guide below
struct EnergyThreshold {
EnergyThreshold(corsika::units::si::HEPEnergyType x)
: value{x} {}
......@@ -167,11 +172,14 @@ namespace corsika::process {
corsika::units::si::HEPEnergyType value;
};
template <class... Ts, class... Us>
ConditionalProcessSequence(corsika::units::si::HEPEnergyType,
const ProcessSequence<Ts...>&, const ProcessSequence<Us...>&)
->ConditionalProcessSequence<EnergyThreshold, ProcessSequence<Ts...>,
ProcessSequence<Us...>>;
// convenience: generate ConditionalProcessSequence with energy threshold
// when first argument is energy unit type
template <class T, class U>
ConditionalProcessSequence(corsika::units::si::HEPEnergyType, T&&, U &&)
->ConditionalProcessSequence<
EnergyThreshold,
boost::mp11::mp_if<std::is_rvalue_reference<T>, std::decay_t<T>, T>,
boost::mp11::mp_if<std::is_rvalue_reference<U>, std::decay_t<U>, U>>;
} // namespace corsika::process
......
......@@ -65,10 +65,7 @@ TEST_CASE("ConditionalProcessSequence") {
DummyProcess<3> false_P;
DummyProcess<4> additional;
ConditionalProcessSequence<EnergyThreshold,
ProcessSequence<DummyProcess<1>&, DummyProcess<2>&>,
ProcessSequence<DummyProcess<3>&>>
cseq(1_TeV, ProcessSequence(true_A, true_B), false_P);
ConditionalProcessSequence cseq(1_TeV, ProcessSequence(true_A, true_B), false_P);
ProcessSequence seq(cseq, additional);
SECTION("low energy") {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment