Consider the following program:
#include<functional>
template<typename T>
T f() { return T{}; }
template<typename T>
auto g() { return T{}; }
int main() {
std::function<int()> a = f<int>; // ok, clang and gcc
std::function<int()> b = g<int>; // ok, clang, error gcc
}
The error in gcc is
error: conversion from '<unresolved overloaded function type>' to non-scalar type 'std::function<int()>' requested
Here's the code to experiment with.
I don't understand why the program compiles only if the return type is T, and fails on gcc when the return type is deduced.
Edit: The comments suggest this is a gcc bug, but could I get a confirmation that the program is indeed well formed?