Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <stdint.h>
template <uint32_t* v>
uint32_t* f()
{
return v;
}
int main( void )
{
f< (uint32_t*) 1000 >();
return 0;
}
// $ clang++ test.cpp
// test.cpp:11:5: error: no matching function for call to 'f'
// f< (uint32_t*) 1000 >();
// ^~~~~~~~~~~~~~~~~~~~~
// test.cpp:4:11: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'v'
// uint32_t* f()
// ^
// 1 error generated.
// $ clang++ test.cpp -std=c++11
// $
// $ g++ test.cpp -std=c++11
// test.cpp: In function 'int main()':
// test.cpp:11:27: error: no matching function for call to 'f()'
// f< (uint32_t*) 1000 >();
// ^
// test.cpp:11:27: note: candidate is:
// test.cpp:4:11: note: template<uint32_t* v> uint32_t* f()
// uint32_t* f()
// ^
// test.cpp:4:11: note: template argument deduction/substitution failed:
// test.cpp:11:27: error: could not convert template argument '1000u' to 'uint32_t* {aka unsigned int*}'
// f< (uint32_t*) 1000 >();
// ^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment