vendredi 19 avril 2019

How to check function signature using C++11 traits?

//test.cpp
#include <type_traits>

double* func() {}

static_assert(std::is_same<double*(*)(), decltype(func)>::value, "");

int main() {}

Compile command:

g++ -std=c++11 -c test.cpp

Output:

test4.cpp:6:1: error: static assertion failed:
static_assert(std::is_same<double*(*)(), decltype(func)>::value, "");
^

What's wrong in the code above? How can I fix it?

Aucun commentaire:

Enregistrer un commentaire