std::cout with constexpr on templated function works. Why?

Viewed 40

I have this code:

#include <iostream>

template<class T>
constexpr void f(T) { std::cout << ""; } // compiles

constexpr void g(int) { std::cout << ""; } // does not compile

int main() {
    f(1);
}

Why f compiles and g does not?

Used GCC 9.1 and Clang 8.0

0 Answers
Related