TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24524 24
POC of custom conditional warnings exploiting C++26's expansion statements and deprecated attribute for compile-time debugging

I came up with this hacky trick for custom compiler warnings (not errors) that are conditional on a compile-time known bool. I know it is not the prettiest error message but it at least has all the relevant information to be useful for compile-time (print) debugging. Thought it would be cool to share here and please let me know if there is a better way to achieve this or if it can be achieved in C++23 or prior. Check it out here: https://godbolt.org/z/br6vGdvex

https://redd.it/1pr7dpm
@r_cpp
godbolt.org Compiler Explorer - C++ (x86-64 gcc (C++26 reflection)) template <bool flag, class Callable> struct CTWarning; template <class Callable> struct CTWarning<false, Callable> { static constexpr std::array<Callable, 0> arr{}; }; template <class Callable> struct CTWarning<true, Callable> { static constexpr…
More from @r_cpp
  1. Oct 9, 2026std::variant, operator== and pattern matching I was thinking, wouldn't adding equality com…
  2. Oct 8, 2026Profiles for simplicity and guarantees - Bjarne Stroustrup - CppCon 2026 https://youtu.be/…
  3. Oct 8, 2026How to Fix autoconf-style Configuration Probing https://build2.org/blog/fix-autoconf.xhtml…
  4. Oct 8, 2026owl – a header-only C++23 HTTP framework where route patterns and handler extractors are c…
  5. Oct 8, 2026Removed by Reddit Removed by Reddit on account of violating the [content policy. ] https:/…
  6. Oct 8, 2026Is there a way to search across all P and N papers throughout standardization history? It…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →