Closed kokosxD closed 4 years ago
This is not an Arduino-specific problem, I think you're code is incorrect. Running this against normal g++
produces the same error. Using clang
provides a hint about the problem:
matthijs@grubby:~$ clang-10 -c testfoo.cpp
testfoo.cpp:19:58: error: exception specifications are not allowed in type aliases
using CompFunc = const bool(*)(const _Ty1&, const _Ty1&) noexcept;
^
testfoo.cpp:46:24: error: missing 'template' keyword prior to dependent template name 'FirstAreSame'
if(! (_first_object.FirstAreSame<CaseSensitive>(_str1[character], _str2[character]))){
^
testfoo.cpp:62:19: note: in instantiation of member function 'SecondClass<char>::SecondAreSame' requested here
if(second_object.SecondAreSame(first_object, str1, str2)){
^
(Here, testfoo.cpp.
is your code minus the references to Serial
and exit
)
So apparently you need to explicitly state to the compiler that FirstAreSame
is a template using the template
keyword. I'm not sure off-hand what the exact rules are here, but I think you can figure it out from here.
Anyway, not an Arduino bug, so I'm closing this.
So apparently you need to explicitly state to the compiler that
FirstAreSame
is atemplate
using the template keyword.
I added the template
keyword before the function name and it worked!
// It calls FirstClass<_Ty1>::FirstAreSame<>
if(! (_first_object.template FirstAreSame<CaseSensitive>(_str1[character], _str2[character]))){
return false;
}
Also, I forgot to initialize Serial
, so first I didn't get any output. Thank you so much!
When an function from template class
SecondClass
calls a template function which takes a function as it template argument from template classFirstClass
, the Arduino IDE treats the<>
as theoperator<
. Note that this is happening ONLY with template classes. If I remove the templates from the classes without removing the templates from their member functions, it compiles fine.Apart from the Arduino-specific code, it compiles without any errors or warnings in Visual Studio 2019.
How to reproduce
Error message
What I'm using