如何获得指向受概念限制的函数的函数指针?

How do I get the function pointer to a function restricted by a concept?

我有一个函数模板和一个概念重载:

template<typename T> void f() {std::cout<< "general" << std::endl;}
template<std::integral T> void f() {std::cout<< "integral" << std::endl;}

现在我想获得一个函数指针,指向该概念的函数。当我使用辅助结构时它工作正常:

typedef void (*tF)();

template<typename T> struct H
{
   static void g() {f<T>();}
};

tF fHd = &H<double>::g;
tF fHi = &H<int>::g;

当我在没有辅助结构的情况下直接执行时,比如

tF fd = &f<double>;
tF fi = &f<int>;

GCC 10 给出错误信息:

error: converting overloaded function ‘f’ to type ‘tF’ {aka ‘void (*)()’} is ambiguous

tF fi = &f<int>;
note: candidates are: ‘void f() [with T = int]’
  template<typename T> void f() {std::cout<< "general" << std::endl;}
note:                 ‘void f() [with T = int]’
   template<std::integral T> void f() {std::cout<< "integral" << std::endl;}

这是 GCC 中的错误还是标准要求的?

现在看来这可能是一个错误,要绕过它,您可以执行类似...

#include <type_traits>
#include <iostream>

template<typename T> void f() requires (!std::integral<T>) {std::cout<< "general" << std::endl;}
template<std::integral T> void f() {std::cout<< "integral" << std::endl;}

typedef void (*tF)();

int main() {
    tF fd = &f<double>;
    tF fi = &f<int>;
}

甚至

template<typename T> concept nonIntegral = !std::integral<T>;

template<nonIntegral T> void f() {std::cout<< "general" << std::endl;}
template<std::integral T> void f() {std::cout<< "integral" << std::endl;}

那应该没问题。