Just recently embraced user-defined literals for my strongy-typed units of time (e.g. 10_ms, 100_us, 1_ns). My time types have always required explicit constructors to make call sites clear and this outcome is the best of all worlds. Except the extra function call, of course...
literals can be marked constexpr and if they are assigned to a constexpr value, they will be evaluated in constexpr just like any other function. This doesn't help when doing "MyFunction(10_us)". You'd have to hoist the 10_us up into a constexpr first. =(
-
-
I use hash literals (something like "someString"_hash), and it works in case statements and explicitly declared constexpr values. But what I often want is "FindAnimation("anim"_hash)" or something like that. Unfortunately doesn't even work in release on msvc. =(
Kiitos. Käytämme tätä aikajanasi parantamiseen. KumoaKumoa
-
-
-
-
oh, deary me...
Keskustelun loppu
Uusi keskustelu -
-
-
Yah, that's my use-case. Not great. Could be better. See consteval reference by
@jcelerie. Likely usable in my code-base by 2025 if my adoption speed is consistent.Kiitos. Käytämme tätä aikajanasi parantamiseen. KumoaKumoa
-
Lataaminen näyttää kestävän hetken.
Twitter saattaa olla ruuhkautunut tai ongelma on muuten hetkellinen. Yritä uudelleen tai käy Twitterin tilasivulla saadaksesi lisätietoja.