Re: [webkit-dev] How we enable template functions

2017-08-23 Thread Keith Miller
> On Aug 23, 2017, at 12:21 PM, Konstantin Tokarev wrote: > > > > 23.08.2017, 21:15, "Keith Miller" >: >> You can totally have the enable_if in the template list: >> >> #define ENABLE_TEMPLATE_IF(condition)

Re: [webkit-dev] How we enable template functions

2017-08-23 Thread Keith Miller
You can totally have the enable_if in the template list: #define ENABLE_TEMPLATE_IF(condition) typename = typename std::enable_if::type template::value))> int foo() { return 0; } template::value))> double foo() { return 0; } int myFunction() { return foo(); } Compiles fine for me.

Re: [webkit-dev] How we enable template functions

2017-08-23 Thread Mark Lam
One application of enable_if I’ve needed in the past is where I want specialization of a template function with the same argument signatures, but returning a different type. The only way I know to make that happen is to use enable_if in the return type, e.g.

Re: [webkit-dev] How we enable template functions

2017-08-23 Thread Keith Miller
> On Aug 22, 2017, at 9:17 PM, JF Bastien wrote: > > I'd suggest considering what it'll look like when we're migrating to concepts > in C++20. > > Here's an example for our bitwise_cast: > https://github.com/jfbastien/bit_cast/blob/master/bit_cast.h#L10 >

Re: [webkit-dev] How we enable template functions

2017-08-22 Thread JF Bastien
I'd suggest considering what it'll look like when we're migrating to concepts in C++20. Here's an example for our bitwise_cast: https://github.com/jfbastien/bit_cast/blob/master/bit_cast.h#L10 Notice the 3 ways to enable. There's also the option of using enable_if on the return value, or as a

Re: [webkit-dev] How we enable template functions

2017-08-22 Thread Chris Dumez
I personally prefer std::enable_if<>. For e.g. template::value> Class Foo { } I don’t like that something inside the body of a class / function would cause a template to be enabled or not. --  Chris Dumez > On Aug 22, 2017, at 8:34 PM, Keith Miller wrote: > >

[webkit-dev] How we enable template functions

2017-08-22 Thread Keith Miller
Hello fellow WebKittens, I’ve noticed over time that we don’t have standard way that we enable versions of template functions/classes (flasses?). For the most part it seems that people use std::enable_if, although, it seems like it is attached to every possible place in the function/class. I