I encount follow linker error
unresolved extrenal symbol "class std::basic_ostream > std::cout" (?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A)"
when trying to assign std::cout to static constexpr std::stream when using visual stidio 2017 and visual studio 2019. No problem, however, encounters when using gcc.
Following simple testing code could indicate this problem
#include <iostream>
int main()
{
static constexpr std::ostream* fp = &std::cout;
*fp << "Hello World!\n";
}
Both expression of
constexpr std::ostream* fp = &std::cout;
or
static std::ostream* fp = &std::cout;
are confirmed to be OK.
My question is:
Is
static constexpr std::ostream* fp = &std::cout;
a legitimate expression. If not, why?
Much thanks.