read to read an integer from stdin in the code below: |
|
114 514 |
628 |
read read different types of integers (int, long long, etc.). Therefore, I write another piece of code using template: |
|
main.cpp: In function ‘int main()’:
main.cpp:24:14: error: no matching function for call to ‘read()’
24 | a = read();
| ^
main.cpp:4:3: note: candidate: ‘template<class T> T read()’
4 | T read()
| ^~~~
main.cpp:4:3: note: template argument deduction/substitution failed:
main.cpp:24:14: note: couldn’t deduce template parameter ‘T’
24 | a = read();
| ^
main.cpp:25:14: error: no matching function for call to ‘read()’
25 | b = read();
| ^
main.cpp:4:3: note: candidate: ‘template<class T> T read()’
4 | T read()
| ^~~~
main.cpp:4:3: note: template argument deduction/substitution failed:
main.cpp:25:14: note: couldn’t deduce template parameter ‘T’
25 | b = read();
| ^
|
a = read<int>(); to read an integer.| I use the function read to read an integer from stdin |
|
|
|
|
|
|
<concepts> library by specifying a core language concept.auto max(std::integral auto x) { ... }