JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
Loading...
Searching...
No Matches
jh::meta::check_all Concept Reference

Compile-time predicate applied to all alternatives in a variant. More...

#include <jh/metax/variant_adt.h>

Concept definition

template<template<typename...> typename Check, typename Variant, typename... Args>
concept check_all = detail::check_all_impl<Check, Variant, Args...>()
Compile-time predicate applied to all alternatives in a variant.
Definition variant_adt.h:308

Detailed Description

Compile-time predicate applied to all alternatives in a variant.

This concept verifies that a user-defined metafunction Check succeeds for every alternative type contained in Variant. Two evaluation modes are supported:

  • Narrow form: Check<T>::value
  • Wide form: Check<T, Variant, Args...>::value

In the wide form, the second template parameter is always the full Variant type. This design ensures that Check can inspect the entire variant structure without requiring users to redundantly pass it. The mechanism short-circuits: if any alternative fails, the overall result is false.

Usage Example

This is how you define your own check concept:

template <typename Inner, typename Variant, typename... Args>
struct your_wide_check
{
// avoid unused parameter warning if your concept doesn't use Variant
using _unused [[maybe_unused]] = Variant;
static constexpr bool value = your_concept_1<typename Inner, ... >;
// add Variant and Args as needed
};
template <typename Inner>
struct your_narrow_check
{
static constexpr bool value = your_concept_2<typename Inner>;
};
Template Parameters
CheckA metafunction template that exposes a boolean value.
VariantThe std::variant whose alternatives are checked.
ArgsAdditional parameters forwarded to wide-form checks.
Note
If Check does not define value, or if value is not convertible to bool, the result is false.