> On Aug. 30, 2017, 5:14 p.m., Michael Park wrote:
> > 3rdparty/libprocess/include/process/future.hpp
> > Lines 1702-1703 (patched)
> > <https://reviews.apache.org/r/61987/diff/1/?file=1807590#file1807590line1702>
> >
> >     Let's stick to the `typename std::enable_if<condition, int>::type = 0` 
> > pattern for now.
> 
> Benjamin Hindman wrote:
>     How come? That's not what I've used other places ... what are the pros 
> and cons of each approach?

The current approach doesn't allow you to SFINAE over an overload set.

For example,
```cpp
template <typename T, typename = typename 
std::enable_if<std::is_integral<T>::value>::type>
void f(T) { std::cout << "integral\n"; }

template <typename T, typename = typename 
std::enable_if<!std::is_integral<T>::value>::type>
void f(T) { std::cout << "!integral\n"; }

f(42);  // doesn't work -- "redefining a default template parameter"
```

vs

```cpp
template <typename T, typename std::enable_if<std::is_integral<T>::value, 
int>::type = 0>
void f(T) { std::cout << "integral\n"; }

template <typename T, typename std::enable_if<!std::is_integral<T>::value, 
int>::type = 0>
void f(T) { std::cout << "!integral\n"; }

f(42);  // works
```

In other cases it doesn't make a difference, so I prefer to just use this
pattern rather than trying to identify / teach cases where this is necessary.


- Michael


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/61987/#review184221
-----------------------------------------------------------


On Aug. 30, 2017, 9:42 p.m., Benjamin Hindman wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/61987/
> -----------------------------------------------------------
> 
> (Updated Aug. 30, 2017, 9:42 p.m.)
> 
> 
> Review request for mesos, Benjamin Mahler, Gilbert Song, and Jie Yu.
> 
> 
> Bugs: MESOS-7926
>     https://issues.apache.org/jira/browse/MESOS-7926
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> This can be useful in circumstances where you don't want some
> asynchronous operation to be canceled.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/include/process/future.hpp 
> 2f5f0a20b5a39b04fd684b1cb44b6a33b647bbef 
>   3rdparty/libprocess/src/tests/future_tests.cpp 
> 0c8725b9a5e64aaac6e3979e450a11e84f9bd45e 
> 
> 
> Diff: https://reviews.apache.org/r/61987/diff/2/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Benjamin Hindman
> 
>

Reply via email to