[LLVMbugs] [Bug 9908] New: alias templates, something is not quite right

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 12 18:43:14 PDT 2011


           Summary: alias templates, something is not quite right
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: hhinnant at apple.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

Apple clang version 3.0 (trunk 131228) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin10.7.0
Thread model: posix

template <class _Tp, class _Up>
struct __allocator_traits_rebind
    typedef typename _Tp::template rebind<_Up>::other type;

template <class Alloc>
struct allocator_traits
    typedef Alloc allocator_type;
    template <class T> using rebind_alloc = typename
__allocator_traits_rebind<allocator_type, T>::type;
    template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;

template <class T>
struct ReboundA {};

template <class T>
struct A
    typedef T value_type;

    template <class U> struct rebind {typedef ReboundA<U> other;};

int main()
    allocator_traits<A<char> >::rebind_traits<double> a;

test.cpp:242:33: error: no member named 'rebind_traits' in
'allocator_traits<A<char> >'
    allocator_traits<A<char> >::rebind_traits<double> a;
test.cpp:242:53: error: expected '(' for function-style cast or type
    allocator_traits<A<char> >::rebind_traits<double> a;
test.cpp:242:55: error: use of undeclared identifier 'a'
    allocator_traits<A<char> >::rebind_traits<double> a;
3 errors generated.

Expecting no error.

And the wild thing is the workaround:  Use the template parameter Alloc
directly, instead of the type allocator_type, in the definition of
rebind_alloc, and then rebind_traits behaves correctly.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list