Partial specialization of C ++ template using pointer function / const pointer function not different?

Consider the following code:

template <typename T>
class Foo
{};

template <typename T, typename U>
class Foo<T(*)(U* const)>
{};

template <typename T, typename U>
class Foo<T(*)(U*)>
{};

When I try to compile it (ideone) , it does not tell me that the two sample specializations are identical. This is surprising, since usually U*both U* constare different things (the second is a const pointer). What is wrong here?

+4
source share
2 answers

When determining the type of function (well-known signatures), the highest qualifiers of top-level cv are discarded.

§8.3.5/5... .... cv-, , ....

, .

+6

:

template <typename T, typename U>
class Foo<T(*)(const U* )>
{};
0

Source: https://habr.com/ru/post/1619867/


All Articles