-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathdecay1.cpp
More file actions
51 lines (30 loc) · 765 Bytes
/
decay1.cpp
File metadata and controls
51 lines (30 loc) · 765 Bytes
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
/*
* HOME : ecourse.co.kr
* EMAIL : smkang @ codenuri.co.kr
* COURSENAME : C++ Template Programming
* MODULE : decay1.cpp
* Copyright (C) 2017 CODENURI Inc. All rights reserved.
*/
#include <iostream>
#include <type_traits>
using namespace std;
// argument decay
template<typename T> void foo(T arg) // int arg[3] = x;
{
// T : int*
cout << typeid(T).name() << endl; // int*
}
template<typename T> void goo(T& arg) // T : int[3] goo(int (&arg)[3])
{
// T : int[3]
cout << typeid(T).name() << endl; // int[3]
}
int main()
{
int x[3] = { 1,2,3 }; //int[3]
foo(x); //
goo(x);
// int y[3] = x; // error
// int* p = x; // ¹è¿ÀÇ ¿ä¼ÒÀÇ ÁÖ¼Ò..
// int(&r)[3] = x; // ok..
}