jeudi 7 juin 2018

How to declare a const reference to function type

    #include <iostream>
    #include <type_traits>

    void func()
    {

    }

    int main()
    {
      using T = const decltype(func) &;
      using T2 = void (&)();
      std::cout << std::boolalpha << std::is_same_v<T, T2> << std::endl;
    }

How do you declare a const reference to a function type? The statement above prints true so I'm assuming that the const in T is ignored somehow. Is it possible at all to declare a const reference to a function type?

Aucun commentaire:

Enregistrer un commentaire