Created
July 11, 2018 07:24
-
-
Save bolry/ceb63d59cb06b93f86e6b99a15605080 to your computer and use it in GitHub Desktop.
Tricky C++ question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class T, int ... X> | |
T pi(T(X...)); | |
#include <iostream> | |
void foo() { std::cout << __LINE__ << '\n'; } | |
void foo(int) { std::cout << __LINE__ << '\n'; } | |
template<typename T> void foo(T) { std::cout << __LINE__ << '\n'; } | |
template<> void foo(int) { std::cout << __LINE__ << '\n'; } | |
template<typename T>void foo(T *) { std::cout << __LINE__ << '\n'; } | |
struct S {}; | |
void foo(S) { std::cout << __LINE__ << '\n'; } | |
struct ConvertibleToInt { ConvertibleToInt(int); }; | |
void foo(ConvertibleToInt) { std::cout << __LINE__ << '\n'; } | |
namespace N { | |
namespace M { void foo(char) { std::cout << __LINE__ << '\n'; }} | |
void foo(double) { std::cout << __LINE__ << '\n'; } | |
} | |
int main() { | |
foo(1); | |
using namespace N::M; | |
foo(1); | |
return pi<int, 42>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment