samedi 9 septembre 2017

Why is constexpr part of the type?

why is constexpr part of the line ? I thought it was just like inline. What's the real type of f in g ?

This works:

void f()
{
  auto f = []() { return 42; };
  auto p = f;

  static_assert(std::is_same_v<decltype(f), decltype(p)>);
}

but this doesn't:

void g()
{
  constexpr auto f = []() { return 42; };
  auto p = f;

  static_assert(std::is_same_v<decltype(f), decltype(p)>);
}

http://ift.tt/2xlkDQh

Aucun commentaire:

Enregistrer un commentaire