Код: Выделить всё
std::enable_if::type*=nullptr
Код: Выделить всё
std::enable_if::type* =nullptr
Разница — это просто пустое место. Рассматривается ли *= как оператор?
Вот фрагмент кода:
Код: Выделить всё
#include
#include
template
class is_allowed_type:public std::false_type{};
template
class is_allowed_type:public std::true_type{};
template
class is_allowed_type:public std::true_type{};
template
typename std::enable_if::type foo(T val){}
template
void goo(T val){}
template
void koo(T val, typename std::enable_if::type*=nullptr){}
template
void hoo(T val, typename std::enable_if::type* = nullptr){}
int main() {
unsigned char val{'0'};
uint16_t num{0};
foo(val); //works;
foo(num); //works;
//foo(6); //not compile as expected
//foo(3.14); //not compile as expected
return 0;
}
Код: Выделить всё
:20:73: error: expected ')'
20 | void koo(T val, typename std::enable_if::type*=nullptr){}
| ^
:20:9: note: to match this '('
20 | void koo(T val, typename std::enable_if::type*=nullptr){}
| ^
1 error generated.
Код: Выделить всё
void foo1(int*=nullptr){}
void foo2(int* =nullptr){}
int main() {
return 0;
}
Подробнее здесь: https://stackoverflow.com/questions/784 ... tvaluetype