The compiler (g++-7
) emits an error when compiling the following code:
#include <vector>
template<typename MetricType, typename DataType>
class Label {
public:
using metric_type = Label<MetricType, int>;
template<typename LabelDataType> using label_type = Label<MetricType, LabelDataType>;
// ...
};
template<typename LabelType>
class Raptor {
public:
std::vector<typename LabelType::metric_type> works;
std::vector<typename LabelType::label_type<int> > throws_an_error;
};
int main() {
Raptor<Label<int, int> > raptor;
return 0;
}
The error message is
main.cpp:17:53: error: template argument 1 is invalid
std::vector<typename LabelType::label_type<int> > throws_an_error;
^
main.cpp:17:53: error: template argument 2 is invalid
make[2]: *** [CMakeFiles/bin.dir/build.make:63: CMakeFiles/bin.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/bin.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
I tried giving the std::vector
an empty struct as the second template argument, but the error message stays the same.
I have no idea what this error message means and how to make this code compile.
Especially I'm confused, because the field works
does not produce any errors, also when commenting the errorneous field out, but the types metric_type
and label_type<int>
are equal.