0

the code of the ::template example, but I don't know exactly what it means. I know that the use of ::template in this example is completely optional, whatever it means, but I'm really wondering what its meaning is

#include <iostream>

void bar() {
    std::cout << 1;
}

struct S {
    template <auto Fn>
    static auto foo() {
        return Fn();
    }
};

template <typename T>
void foobar(T f) {
    f();
}

int main() {
    foobar(S::template foo<bar>);
    return 0;
}
  • 1
    TL;DR of the dupe: the `template` is there to tell the compiler that the name `foo` is a template, and `` is the parameter list, not some broken comparison. – NathanOliver Mar 01 '22 at 20:54
  • What you're looking for is described under "template dependent names". An example article explaining this topic is here https://www.modernescpp.com/index.php/dependent-types – tomdol Mar 01 '22 at 21:06

0 Answers0