forked from codenuri/TEMPLATE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconcept3.cpp
56 lines (48 loc) · 867 Bytes
/
concept3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* HOME : ecourse.co.kr
* EMAIL : smkang @ codenuri.co.kr
* COURSENAME : C++ Template Programming
* MODULE : concept3.cpp
* Copyright (C) 2017 CODENURI Inc. All rights reserved.
*/
#include <iostream>
using namespace std;
struct Point
{
int x, y;
bool operator<(const Point& p)
{
return x < p.x;
}
};
template<typename T>
concept bool LessThanComparable = requires(T a, T b)
{
{ a < b } -> bool;
};
/*
// ¹æ¹ý 1.
template<typename T> requires LessThanComparable<T>
T Min(T x, T y)
{
return (y < x) ? y : x;
}
*/
/*
// ¹æ¹ý 2.
template<typename T>
T Min(T x, T y) requires LessThanComparable<T>
{
return (y < x) ? y : x;
}
*/
// Ãà¾àÇü.
LessThanComparable Min(LessThanComparable x, LessThanComparable y)
{
return (y < x) ? y : x;
}
int main()
{
Point p1, p2;
Min(p1, p2);
}