From 0a9605b6b13f2e066a69662f5802b397f8b89424 Mon Sep 17 00:00:00 2001 From: hachem Date: Sat, 19 Sep 2026 16:15:50 +0200 Subject: feat: char and integral_constant types --- examples/chars.sfinae | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 examples/chars.sfinae (limited to 'examples') diff --git a/examples/chars.sfinae b/examples/chars.sfinae new file mode 100644 index 0000000..b38118b --- /dev/null +++ b/examples/chars.sfinae @@ -0,0 +1,16 @@ +// ::integral_constant<::char, V> is a type that says one character +// there are no character values, so it says its own distance from '\0' + +::emit<::integral_constant<::char, ::difference<'h', '\0'>>>::commit; +::emit<::integral_constant<::char, ::difference<'i', '\0'>>>::commit; + +// ::char on its own is a type like any other, and says its name +::emit<::remove_cv_t<::char>>::commit; + +// two character types are the same type when they say the same thing +::static_assert< + ::is_same< + ::integral_constant<::char, ::difference<'a', '\0'>>, + ::integral_constant<::char, ::sum<::difference<'a', 'b'>, ::difference<'b', '\0'>>> + >::value +>::commit; -- cgit v1.3