[LLVMbugs] [Bug 15461] New: Assert on invalid "Not an array type!" with alias template which doesn't provide a deduced value

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Mar 6 15:10:30 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=15461

            Bug ID: 15461
           Summary: Assert on invalid "Not an array type!" with alias
                    template which doesn't provide a deduced value
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

#include <type_traits>
#include <utility>
#include <memory>

template <class T, class ...Args>
typename std::enable_if
<
    !std::is_array<T>::value,
    std::unique_ptr<T>
>::type
make_unique(Args&& ...args)
{
    return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}

template <class A, class B> using First = A;

template <class T, class ...X>
typename std::enable_if
<
    std::is_array<T>::value,
    std::unique_ptr<T>
>::type
make_unique(std::size_t n, First<T, X> ...inits)
{
    typedef typename std::remove_extent<T>::type RT;
    return std::unique_ptr<T>(new RT[n]{inits...});
}

int main()
{
    auto p1 = make_unique<int>(3);
    auto p2 = make_unique<int[]>(3);
}

-- 
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/20130306/406b708c/attachment.html>


More information about the llvm-bugs mailing list