mercredi 27 janvier 2016

Forward declaring a constexpr function in a header [duplicate]

This question already has an answer here:

Say I have the following files. Is this invalid C++ (linker chokes, so yeah) or is it a mistake in my syntax? Must a forward declaration of a constexpr function be in the same file as its definition?

header.h

extern constexpr int fun(int);

source.cpp

constexpr int fun(int x) 
{
    return x * 2; 
}

Aucun commentaire:

Enregistrer un commentaire