c++ - SFINAE + sizeof = detect if expression compiles -


I just found out how operator was provided for one type is.

  template & lt; Square T & gt; T & amp; Lvalue_of_type (); Template & lt; Class T & gt; T rvalue_of_type (); Template & lt; Class T & gt; Struct is_printable {template & lt; Square U & gt; Fixed four tests (four (*) (size) (level_of_type  ()  ())]);); Template & lt; Square U & gt; Stable long exam (...); Enum {value = 1 == test size & lt; T & gt; (0)}; Typedef boost :: integral_constant & lt; Bool, value & gt; type; };  

Is this trick well known, or have I won the Metrophilizing Nobel Prize? ;)

Edit: I have two global function template announcements lvalue_of_type and rvalue_of_type .

has made the code easy to understand in order to optimize.

This is a well known technique, I'm scared: -)

use the function Call in the sizeof operator, declares the compiler to compile logic deduction and function, at compile-time. Also, with a template function, the compiler also instantiates a concrete function from a template. However, this expression function is not the reason of generating the call. It is well described in PDF.

Check the other.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -