-
-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add template keyword to fix dependent name errors
Clang and GCC complained about this, and it's indeed needed (see e.g. https://eigen.tuxfamily.org/dox/TopicTemplateKeyword.html). MSVC accepts it without template keyword, but it's non-standard C++. Basically, the object that we call the templated function on (head<>() or cast<>()) is itself a templated type. Because we don't know at compile time what that first templated type is, the compiler can't know what the function is that we call on it (i.e. it could be a type or operator<()). So we need the "template" keyword to tell the compiler that it's a templated function. One way to avoid this would be to declare a template at namespace scope, like std::tuple: It has an associated get function template that is declared in the std namespace instead of being a class member, so we can do std::get<i>(t) instead of t.template get<i>(). However, that's not really a good solution here I think. There's also nothing wrong with using `template` here, it just makes the code a bit more difficult to read.
1 parent
b4f89ce
commit e5f8a6b
Showing
2 changed files
with
21 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters