/// @file dpf/eval_target.hpp /// @brief Eval channel tags for the unified DPF / iDPF / DCF surface. /// @copyright Copyright (c) 2019-2026 Ryan Henry and [others](@ref authors) /// @license Released under a GNU General Public v2.0 (GPLv2) license. #ifndef LIBDPF_INCLUDE_DPF_EVAL_TARGET_HPP__ #define LIBDPF_INCLUDE_DPF_EVAL_TARGET_HPP__ #include #include #include #include "hedley/hedley.h" namespace dpf { /// @brief Sentinel: deduce point-slot prefix from the key (`meta[I].prefix`). inline constexpr std::size_t prefix_deduce = std::numeric_limits::max(); /// @brief Point-output channel: slot `I`, optional prefix check `N`. /// @tparam I output index /// @tparam N prefix length, or `prefix_deduce` template struct out_t { static constexpr std::size_t index = I; static constexpr std::size_t prefix = N; static constexpr bool prefix_fixed = (N != prefix_deduce); }; template inline constexpr out_t out{}; /// @brief Comparison (DCF) channel. struct cmp_t { }; inline constexpr cmp_t cmp{}; /// @brief Prefix of an `idcf` comparison. `L` is the number of leading bits. /// @tparam L number of leading bits template struct cmp_prefix_t { static constexpr std::size_t length = L; }; template inline constexpr cmp_prefix_t cmp_prefix{}; template struct is_out : std::false_type { }; template struct is_out> : std::true_type { }; template inline constexpr bool is_out_v = is_out>::value; template struct is_cmp_target : std::bool_constant, cmp_t>> { }; template inline constexpr bool is_cmp_target_v = is_cmp_target::value; template struct is_cmp_prefix_target : std::false_type { }; template struct is_cmp_prefix_target> : std::true_type { }; template inline constexpr bool is_cmp_prefix_target_v = is_cmp_prefix_target>::value; /// @brief True for channel tags that must not bind as the key in classic eval_*. template inline constexpr bool is_eval_channel_tag_v = is_out_v || is_cmp_target_v || is_cmp_prefix_target_v; template struct looks_like_dpf_key : std::false_type { }; HEDLEY_PRAGMA(GCC diagnostic push) HEDLEY_PRAGMA(GCC diagnostic ignored "-Wignored-attributes") template struct looks_like_dpf_key> : std::true_type { }; HEDLEY_PRAGMA(GCC diagnostic pop) template inline constexpr bool looks_like_dpf_key_v = looks_like_dpf_key>::value; template struct is_incremental_dpf_key : std::false_type { }; template struct is_incremental_dpf_key> : std::true_type { }; template inline constexpr bool is_incremental_dpf_key_v = is_incremental_dpf_key>::value; /// @brief True only for keys that must use the slot-aware (multi-level / comparison) /// eval path. Every key now carries a `slot_meta` table (so /// `is_incremental_dpf_key_v` is true for all keys), but classic single-level /// equal-width keys keep using the classic `eval_*` fast paths; they set /// `is_multilevel == false`. Multi-level (`at`) and comparison keys set it /// to true. /// @tparam T value type template struct is_multilevel_key : std::false_type { }; template struct is_multilevel_key> : std::bool_constant { }; template inline constexpr bool is_multilevel_key_v = is_multilevel_key>::value; /// @brief True when `T` stores its DPF key in a public member named `dpf_key` /// and is not itself a DPF key. /// @details Wrappers (`ic_key`, `vdpf_plus_key`, `dpf3_cmp_key`, `dpf3_ic_key`, /// and the distributed `opened_*` envelopes) use that member name. /// `party_key` inherits the DPF key, so it is not a wrapper. template struct has_embedded_dpf_key : std::false_type { }; template struct has_embedded_dpf_key().dpf_key)>> : std::bool_constant> { }; template inline constexpr bool has_embedded_dpf_key_v = has_embedded_dpf_key>::value; /// @brief The DPF key `T` evaluates as: `T` itself, or `T::dpf_key` peeled /// until the result looks like a DPF key. template struct bare_dpf_key { using type = std::decay_t; }; template struct bare_dpf_key>>> : bare_dpf_key &>().dpf_key)>> { }; template using bare_dpf_key_t = typename bare_dpf_key>::type; /// @brief Key-first protocol evals (`dpf3`, `dpf3_cmp`, `dpf3_ic`) keep their /// own overloads. Peel does not replace those. template struct flag_is_dpf3 : std::false_type {}; template struct flag_is_dpf3> : std::bool_constant {}; template struct flag_is_dpf3_cmp : std::false_type {}; template struct flag_is_dpf3_cmp> : std::bool_constant {}; template struct flag_is_dpf3_ic : std::false_type {}; template struct flag_is_dpf3_ic> : std::bool_constant {}; template inline constexpr bool owns_protocol_eval_v = flag_is_dpf3>::value || flag_is_dpf3_cmp>::value || flag_is_dpf3_ic>::value; } // namespace dpf #endif // LIBDPF_INCLUDE_DPF_EVAL_TARGET_HPP__