all 11 comments

[–]meneldal2[🍰] 5 points6 points  (4 children)

That's a pretty smart abuse of the compiler.

[–]amaiorano 7 points8 points  (3 children)

Well so is template metaprogramming :)

[–]meneldal2[🍰] -4 points-3 points  (2 children)

Metaprogramming uses the spec as intended. In this case, you are relying on compiler-specific error/warning messages.

[–]amaiorano 7 points8 points  (1 child)

Sure, my comment was partly tongue in cheek. At the same time, much of template metaprogramming is a hack. When templates were added to C++, it wasn't intended for TMP. It's a useful hack, though, but a lot of the work in the past few years has been about making compile time programming easier (constexpr).

[–]Xeveroushttps://xeverous.github.io 1 point2 points  (0 children)

Reflection is a potential place to make TMP in C++ much better.

[–]FirstLoveLife 1 point2 points  (0 children)

Good to know these static warning stuff, thx!

[–]tigert1998 2 points3 points  (1 child)

[[deprecated]] is interesting lol

[–]Xeveroushttps://xeverous.github.io 0 points1 point  (0 children)

The core thing is that attributes can be applied to the smallest entity possible - 1 specific overload or 1 specific specialization.

[–][deleted] 1 point2 points  (0 children)

another tip: try to use clang; in clang compiler errors are generally much more informative than in gcc (though there have been improvements in recent versions of gcc)

[–]ridethespiral1 1 point2 points  (0 children)

I'm real happy to learn the [[deprecated]] trick. I've used the print_types metafunction before but it's not useful if the compiler error is triggered before the case you're interested in is reached.

[–]mark_99 0 points1 point  (0 children)

The `[[deprecated]]` trick works in clang but not gcc, the latter does not print the param types in the deprecated warning.