[LLVMbugs] [Bug 23014] New: static_assert's in the stl containers break SFINAE

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 24 18:32:51 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23014

            Bug ID: 23014
           Summary: static_assert's in the stl containers break SFINAE
           Product: libc++
           Version: 3.5
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tyler.m.kopf at gmail.com
                CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
    Classification: Unclassified

There's a static_assert in all of the STL containers verifying that:
std::allocator<int>::value_type == value_type

They appear to have been added in attempt to fix this bug report:
https://llvm.org/bugs/show_bug.cgi?id=15576

This means one cannot attempt to use SFINAE with such invalid types, as in the
following example code:
template<typename T, typename U, typename = void>
struct attempt_rebind {
    using type = T;
};

template<template<typename...> class Container, typename T, typename U,
typename... OtherArgs>
struct attempt_rebind<
    Container<T, OtherArgs...>,
    U,
    std::enable_if_t<
        std::is_constructible<
            Container<T, OtherArgs...>,
            Container<U, OtherArgs...>
        >::value
    >
>
{
    using type = Container<U, OtherArgs...>;
};

static_assert(
    std::is_same<
        std::vector<int, std::allocator<int>>,
        typename attempt_rebind<std::vector<int>, double>::type
    >::value,
    "This should pass!"
);

Compilation of this valid code is blocked by the static_assert in std::vector.

Thank you!

-- 
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/20150325/a7aa8477/attachment.html>


More information about the llvm-bugs mailing list