История изменений
Исправление dissident, (текущая версия) :
template<> class Timer<uint16_t> : public detail_::Timer<uint16_t> {};
Дошло. Наследнитки Timer<uint16_t> и Timer<uint32_t> явно объявлены без бреда и используются в коде, поэтому их код генерируется из их шаблонов. Внутри же template class Timer какая-то бодяга.
А нет. Не работает:
#include <cstdint>
using namespace std;
template <class T> class Timer {
какой-то бред
void F();
};
template <class T> class Timer;
template<> class Timer<uint16_t> : Timer<uint16_t> {};
template<> class Timer<uint32_t> : Timer<uint32_t> {};
int main(int argc, char *argv[]) {
Timer timer<uint16_t> t16; // compiles
Timer timer<uint32_t> t32; // compiles
// Timer timer<char> t8; // does not compile
}
Не собирается.
~/tmp >>> g++ tmpl.cpp
tmpl.cpp:5:5: error: ‘какой’ does not name a type
5 | какой-то бред
| ^~~~~
tmpl.cpp:10:36: error: invalid use of incomplete type ‘class Timer<short unsigned int>’
10 | template<> class Timer<uint16_t> : Timer<uint16_t> {};
| ^~~~~~~~~~~~~~~
tmpl.cpp:10:18: note: declaration of ‘class Timer<short unsigned int>’
10 | template<> class Timer<uint16_t> : Timer<uint16_t> {};
| ^~~~~~~~~~~~~~~
tmpl.cpp:11:36: error: invalid use of incomplete type ‘class Timer<unsigned int>’
11 | template<> class Timer<uint32_t> : Timer<uint32_t> {};
| ^~~~~~~~~~~~~~~
tmpl.cpp:11:18: note: declaration of ‘class Timer<unsigned int>’
11 | template<> class Timer<uint32_t> : Timer<uint32_t> {};
| ^~~~~~~~~~~~~~~
tmpl.cpp: In function ‘int main(int, char**)’:
tmpl.cpp:14:11: error: missing template arguments before ‘timer’
14 | Timer timer<uint16_t> t16; // compiles
| ^~~~~
tmpl.cpp:15:11: error: missing template arguments before ‘timer’
15 | Timer timer<uint32_t> t32; // compiles
Исправление dissident, :
template<> class Timer<uint16_t> : public detail_::Timer<uint16_t> {};
Дошло. Наследнитки Timer<uint16_t> и Timer<uint32_t> явно объявлены без бреда и используются в коде, поэтому их код генерируется из их шаблонов. Внутри же template class Timer какая-то бодяга.
А нет. Не работает:
template <class T> class Timer {
какой-то бред
void F();
};
template <class T> class Timer;
template<> class Timer<uint16_t> : Timer<uint16_t> {};
template<> class Timer<uint32_t> : Timer<uint32_t> {};
int main(int argc, char *argv[]) {
Timer timer<uint16_t> t16; // compiles
Timer timer<uint32_t> t32; // compiles
// Timer timer<char> t8; // does not compile
}
Не собирается.
tmpl.cpp:2:5: error: ‘какой’ does not name a type
2 | какой-то бред
| ^~~~~
tmpl.cpp:7:24: error: ‘uint16_t’ was not declared in this scope
7 | template<> class Timer<uint16_t> : Timer<uint16_t> {};
| ^~~~~~~~
tmpl.cpp:7:32: error: template argument 1 is invalid
7 | template<> class Timer<uint16_t> : Timer<uint16_t> {};
| ^
tmpl.cpp:7:42: error: ‘uint16_t’ was not declared in this scope
7 | template<> class Timer<uint16_t> : Timer<uint16_t> {};
| ^~~~~~~~
tmpl.cpp:7:50: error: template argument 1 is invalid
7 | template<> class Timer<uint16_t> : Timer<uint16_t> {};
| ^
tmpl.cpp:8:24: error: ‘uint32_t’ was not declared in this scope
8 | template<> class Timer<uint32_t> : Timer<uint32_t> {};
| ^~~~~~~~
tmpl.cpp:8:32: error: template argument 1 is invalid
8 | template<> class Timer<uint32_t> : Timer<uint32_t> {};
| ^
tmpl.cpp:8:42: error: ‘uint32_t’ was not declared in this scope
8 | template<> class Timer<uint32_t> : Timer<uint32_t> {};
| ^~~~~~~~
tmpl.cpp:8:50: error: template argument 1 is invalid
8 | template<> class Timer<uint32_t> : Timer<uint32_t> {};
| ^
tmpl.cpp: In function ‘int main(int, char**)’:
tmpl.cpp:11:11: error: missing template arguments before ‘timer’
11 | Timer timer<uint16_t> t16; // compiles
| ^~~~~
tmpl.cpp:12:11: error: missing template arguments before ‘timer’
12 | Timer timer<uint32_t> t16; // compiles
Исправление dissident, :
template<> class Timer<uint16_t> : public detail_::Timer<uint16_t> {};
Дошло. Наследнитки Timer<uint16_t> и Timer<uint32_t> явно объявлены без бреда и используются в коде, поэтому их код генерируется из их шаблонов. Внутри же template class Timer какая-то бодяга.
А нет. Не работает:
template <class T> class Timer {
какой-то бред
void F();
};
template <class T> class Timer;
template<> class Timer<uint16_t> : Timer<uint16_t> {};
template<> class Timer<uint32_t> : Timer<uint32_t> {};
int main(int argc, char *argv[]) {
Timer timer<uint16_t> t16; // compiles
Timer timer<uint32_t> t16; // compiles
// Timer timer<char> t16; // does not compile
}
Не собирается.
tmpl.cpp:2:5: error: ‘какой’ does not name a type
2 | какой-то бред
| ^~~~~
tmpl.cpp:7:24: error: ‘uint16_t’ was not declared in this scope
7 | template<> class Timer<uint16_t> : Timer<uint16_t> {};
| ^~~~~~~~
tmpl.cpp:7:32: error: template argument 1 is invalid
7 | template<> class Timer<uint16_t> : Timer<uint16_t> {};
| ^
tmpl.cpp:7:42: error: ‘uint16_t’ was not declared in this scope
7 | template<> class Timer<uint16_t> : Timer<uint16_t> {};
| ^~~~~~~~
tmpl.cpp:7:50: error: template argument 1 is invalid
7 | template<> class Timer<uint16_t> : Timer<uint16_t> {};
| ^
tmpl.cpp:8:24: error: ‘uint32_t’ was not declared in this scope
8 | template<> class Timer<uint32_t> : Timer<uint32_t> {};
| ^~~~~~~~
tmpl.cpp:8:32: error: template argument 1 is invalid
8 | template<> class Timer<uint32_t> : Timer<uint32_t> {};
| ^
tmpl.cpp:8:42: error: ‘uint32_t’ was not declared in this scope
8 | template<> class Timer<uint32_t> : Timer<uint32_t> {};
| ^~~~~~~~
tmpl.cpp:8:50: error: template argument 1 is invalid
8 | template<> class Timer<uint32_t> : Timer<uint32_t> {};
| ^
tmpl.cpp: In function ‘int main(int, char**)’:
tmpl.cpp:11:11: error: missing template arguments before ‘timer’
11 | Timer timer<uint16_t> t16; // compiles
| ^~~~~
tmpl.cpp:12:11: error: missing template arguments before ‘timer’
12 | Timer timer<uint32_t> t16; // compiles
Исправление dissident, :
template<> class Timer<uint16_t> : public detail_::Timer<uint16_t> {};
Дошло. Наследнитки Timer<uint16_t> и Timer<uint32_t> явно объявлены без бреда и используются в коде, поэтому их код генерируется из их шаблонов. Внутри же template class Timer какая-то бодяга.
А нет. Не работает:
template <class T> class Timer {
какой-то бред
void F();
};
template <class T> class Timer;
template<> class Timer<uint16_t> : public detail_::Timer<uint16_t> {};
template<> class Timer<uint32_t> : public detail_::Timer<uint32_t> {};
int main(int argc, char *argv[]) {
Timer timer<uint16_t> t16; // compiles
Timer timer<uint32_t> t16; // compiles
// Timer timer<char> t16; // does not compile
}
Не собирается.
~/tmp >>> g++ tmpl.cpp
tmpl.cpp:2:5: error: ‘какой’ does not name a type
2 | какой-то бред
| ^~~~~
tmpl.cpp:7:24: error: ‘uint16_t’ was not declared in this scope
7 | template<> class Timer<uint16_t> : public detail_::Timer<uint16_t> {};
| ^~~~~~~~
tmpl.cpp:7:32: error: template argument 1 is invalid
7 | template<> class Timer<uint16_t> : public detail_::Timer<uint16_t> {};
| ^
tmpl.cpp:7:43: error: ‘detail_’ has not been declared
7 | template<> class Timer<uint16_t> : public detail_::Timer<uint16_t> {};
| ^~~~~~~
tmpl.cpp:8:24: error: ‘uint32_t’ was not declared in this scope
8 | template<> class Timer<uint32_t> : public detail_::Timer<uint32_t> {};
| ^~~~~~~~
tmpl.cpp:8:32: error: template argument 1 is invalid
8 | template<> class Timer<uint32_t> : public detail_::Timer<uint32_t> {};
| ^
tmpl.cpp:8:43: error: ‘detail_’ has not been declared
8 | template<> class Timer<uint32_t> : public detail_::Timer<uint32_t> {};
| ^~~~~~~
tmpl.cpp: In function ‘int main(int, char**)’:
tmpl.cpp:11:11: error: missing template arguments before ‘timer’
11 | Timer timer<uint16_t> t16; // compiles
| ^~~~~
tmpl.cpp:12:11: error: missing template arguments before ‘timer’
12 | Timer timer<uint32_t> t16; // compiles
Исходная версия dissident, :
template<> class Timer<uint16_t> : public detail_::Timer<uint16_t> {};
Дошло. Наследнитки Timer<uint16_t> и Timer<uint32_t> явно объявлены без бреда и используются в коде, поэтому их код генерируется из их шаблонов. Внутри же template class Timer какая-то бодяга.
А нет. Не работает:
namespace detail_ {
template <class T> class Timer {
какой-то бред
void F();
};
}
template <class T> class Timer;
template<> class Timer<uint16_t> : public detail_::Timer<uint16_t> {};
template<> class Timer<uint32_t> : public detail_::Timer<uint32_t> {};
int main(int argc, char *argv[]) {
Timer timer<uint16_t> t16; // compiles
Timer timer<uint32_t> t16; // compiles
// Timer timer<char> t16; // does not compile
}
Не собирается.
~/tmp >>> g++ tmpl.cpp
tmpl.cpp:3:5: error: ‘какой’ does not name a type
3 | какой-то бред
| ^~~~~
tmpl.cpp:9:24: error: ‘uint16_t’ was not declared in this scope
9 | template<> class Timer<uint16_t> : public detail_::Timer<uint16_t> {};
| ^~~~~~~~
tmpl.cpp:9:32: error: template argument 1 is invalid
9 | template<> class Timer<uint16_t> : public detail_::Timer<uint16_t> {};
| ^
tmpl.cpp:9:58: error: ‘uint16_t’ was not declared in this scope
9 | template<> class Timer<uint16_t> : public detail_::Timer<uint16_t> {};
| ^~~~~~~~
tmpl.cpp:9:66: error: template argument 1 is invalid
9 | template<> class Timer<uint16_t> : public detail_::Timer<uint16_t> {};
| ^
tmpl.cpp:10:24: error: ‘uint32_t’ was not declared in this scope
10 | template<> class Timer<uint32_t> : public detail_::Timer<uint32_t> {};
| ^~~~~~~~
tmpl.cpp:10:32: error: template argument 1 is invalid
10 | template<> class Timer<uint32_t> : public detail_::Timer<uint32_t> {};
| ^
tmpl.cpp:10:58: error: ‘uint32_t’ was not declared in this scope
10 | template<> class Timer<uint32_t> : public detail_::Timer<uint32_t> {};
| ^~~~~~~~
tmpl.cpp:10:66: error: template argument 1 is invalid
10 | template<> class Timer<uint32_t> : public detail_::Timer<uint32_t> {};
| ^
tmpl.cpp: In function ‘int main(int, char**)’:
tmpl.cpp:13:11: error: missing template arguments before ‘timer’
13 | Timer timer<uint16_t> t16; // compiles
| ^~~~~
tmpl.cpp:14:11: error: missing template arguments before ‘timer’
14 | Timer timer<uint32_t> t16; // compiles
| ^~~~~