1
2
3
4
5
6
7
8
9
10
11
12
int main(int argc, char* argv[]) {
    typename ::std::result_of<decltype(&normal_function)(int)>::type d1;    // ok
    typename ::std::result_of<decltype( normal_function)(int)>::type d2;    // compile error
 
    auto test1 = &normal_function;    // int (*test1)(int)
    auto test2 =  normal_function;    // int (*test2)(int)
 
    constexpr int test3 = ::std::is_same<int(*)(int), decltype(&normal_function)>::value;
    constexpr int test4 = ::std::is_same<int(*)(int), decltype( normal_function)>::value;
 
    return(0);
}
cs


함수 앞에 & 붙이는 건 무슨 의미인가요?


test3 = 1 이고 test4 = 0 입니다.

auto 에 추론된 타입보니까 둘다 int(*)(int) 이던데 왜 test3 test4 둘 다 1 이 아닌지 이해가 안 가네요;

그리고 왜 ::std::result_of<decltype(normal_function)(int)>::type 가 아닌 ::std::result_of<decltype(&normal_function)(int)>::type 으로 해야 type 이 정의되는 지도 알려주시면 정말 감사하겠습니다 ㅠㅠ