Inside template , if you have a variable whose type is a function of your template parameters, or a type whose type is a function of your template parameters, this is called a dependent type.
In your case evaluator type T evaluator is of type dependent on the template parameters.
When working with a dependent type or variable of this type, you need to provide additional help to the compiler.
The compiler wants to be able to partially understand your code before it actually populates the template parameter there in the instance. By default, it is assumed that everything in the dependent type is a value.
So, evaluator is a dependent type, and evaluator.isGood is considered a value, therefore, evaluator.isGood<B uses operator< on evaluator.isGood and some unknown value B (which it cannot find: error), the return value of which then executes >(value) on. B not a value (but instead a type), so your code is wrong.
You must tell the compiler that isGood not a value, but rather a template when used in a dependent context.
evaluator.template isGood<B>(value) is the syntax. template tells the compiler, "although by default you assume a value will come, template will appear instead." There are similar rules that use typename inside a template (but typename was earlier, so it falls into the crappier spot) to indicate what would otherwise be considered a value, is actually a type.
In your method, main evaluator does not have a dependent type, so it does not need help.
source share