Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
13
Task/Constrained-genericity/C++/constrained-genericity-1.cpp
Normal file
13
Task/Constrained-genericity/C++/constrained-genericity-1.cpp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
template<typename T> concept Eatable = requires(T t) { t.eat(); };
|
||||
|
||||
struct Potato { void eat(); };
|
||||
|
||||
struct Brick {};
|
||||
|
||||
template<Eatable T> class FoodBox {};
|
||||
|
||||
int main() {
|
||||
FoodBox<Potato> lunch{};
|
||||
// Following leads to compile-time error
|
||||
//FoodBox<Brick> practical_joke{};
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
template<typename T> //Detection helper struct
|
||||
struct can_eat //Detects presence of non-const member function void eat()
|
||||
template<typename T> // Detection helper struct
|
||||
struct can_eat // Detects presence of non-const member function void eat()
|
||||
{
|
||||
private:
|
||||
template<typename U, void (U::*)()> struct SFINAE {};
|
||||
Loading…
Add table
Add a link
Reference in a new issue