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::transparent_key Concept Reference

Concept checking whether key conversion through key_traits<K> is valid. More...

#include <jh/metax/lookup_map.h>

Concept definition

template<typename K, typename T>
concept transparent_key = requires(T t) {
}
Concept checking whether key conversion through key_traits<K> is valid.
Definition lookup_map.h:337
static constexpr canonical_type to_canonical(apparent_type &v) noexcept
Convert apparent value to canonical key.
Definition lookup_map.h:233

Detailed Description

Concept checking whether key conversion through key_traits<K> is valid.

Enables heterogeneous lookup by verifying that an input type T can be converted into the canonical key type K through key_traits<K>::to_canonical(). This supports efficient zero-overhead implicit transformation for lightweight or compile-time strings.

Primary motivations:

  • Lookup tables should not store heavyweight or runtime-managed content.
  • Converted keys must remain low-cost and lifetime-stable.
  • jh::pod::string_view is recommended for string keys, usually via "..."_psv.
  • Compile-time helpers can convert std::string_view (including "..."sv literals) into jh::pod::string_view safely.
  • Design philosophy mirrors switch-like behavior: stable lifetime, direct literal use, and lightweight POD representations.
Template Parameters
KCanonical key type of the lookup table.
TApparent input type to be checked for canonical conversion.
Note
This concept only checks convertibility; it does not validate semantics of the resulting canonical key.