hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/examples/chars.sfinae
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-09-19 16:15:50 +0200
committerhachem <im@hachem.wtf>2026-09-19 16:15:50 +0200
commit0a9605b6b13f2e066a69662f5802b397f8b89424 (patch)
treefe063a37fb8de67f3e176ec99cc4a1cc1cadf21d /examples/chars.sfinae
parentbe43ea893018090044cd411bc5b50787b99087b8 (diff)
feat: char and integral_constant types
Diffstat (limited to 'examples/chars.sfinae')
-rw-r--r--examples/chars.sfinae16
1 files changed, 16 insertions, 0 deletions
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;