小编mat*_*atb的帖子

C++模板部分特化由指针函数/ const指针函数没有不同?

我们考虑以下代码:

template <typename T>
class Foo
{};

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

template <typename T, typename U>
class Foo<T(*)(U*)>
{};
Run Code Online (Sandbox Code Playgroud)

当我尝试编译它(ideone)时,它无法告诉我两个模板特化是相同的.这通常是令人惊讶的,U*并且U* const是不同的东西(第二个是const指针).这有什么不对?

c++ templates const function-pointers

4
推荐指数
1
解决办法
150
查看次数

标签 统计

c++ ×1

const ×1

function-pointers ×1

templates ×1