Separate definition and declaration of template member function using enable_if whose template parameter also includes a constexpr member function

前端 未结 1 1556
说谎
说谎 2021-01-21 05:14

The following doesn\'t compile under g++ 8.1.0 on CentOS 7:

hey.h

#pragma once
#include 
#include 

c         


        
相关标签:
1条回答
  • 2021-01-21 05:41

    The matching of expressions in template declarations is based on equivalence, a concept based on the one-definition rule. For two expressions to be considered equivalent, they must be at least token-by-token identical modulo the renaming of template parameters.

    The expressions is_valid<T>() and Hey::is_valid<T>() are not equivalent (the second has two tokens the first doesn't have), and so the compiler is not required to match them.

    Hey::EnableType<T> is a type, and is not subject to the strict equivalence rules for expressions.

    0 讨论(0)
提交回复
热议问题