[llvm-bugs] [Bug 31406] New: CRTP with inhered template member function is not included in overload resolution
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Dec 16 04:34:56 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=31406
Bug ID: 31406
Summary: CRTP with inhered template member function is not
included in overload resolution
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: pedro.ferreira at imgtec.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
The following C++ source file compiles fine:
=======
#include <type_traits>
#include <cstdint>
template<typename Base, typename A>
class EnumAlias
{
public:
template<typename E, typename std::enable_if<std::is_enum<E>::value>::type*
= nullptr>
void operator()(E& e)
{
Base& base = *static_cast<Base*>(this);
A& a = (A&)(e);
base(a);
}
};
class Base;
typedef EnumAlias<Base, uint32_t> EnumAliasU32;
class Base : public EnumAliasU32
{
public:
using EnumAliasU32::operator();
template<typename T, typename
std::enable_if<std::is_fundamental<T>::value>::type* = nullptr>
void operator()(const T& e)
{
//something, whatever
}
};
enum SomeEnumTy {};
void Use()
{
SomeEnumTy e;
Base b;
b(e);
}
========
However, if one is to remove "const" from Base::operator(), clang fails with
=======
CRTP.cpp:39:2: error: no matching function for call to object of type 'Base'
b(e);
^
CRTP.cpp:25:47: note: candidate template ignored: disabled by 'enable_if' [with
T = SomeEnumTy]
template<typename T, typename
std::enable_if<std::is_fundamental<T>::value>::type* = nullptr>
^
1 error generated.
=======
G++ accepts the code. Is the input source incorrect?
It seems on the second, the inherited function does not participate in overload
resolution (even though it does when "const" is specified).
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161216/03e0e0f2/attachment.html>
More information about the llvm-bugs
mailing list