brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 01aac94 Raw
83 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// <memory>10 11// template <class Alloc>12// struct allocator_traits13// {14//     template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;15//     ...16// };17 18#include <memory>19#include <type_traits>20 21#include "test_macros.h"22 23template <class T>24struct ReboundA {};25 26template <class T>27struct A28{29    typedef T value_type;30 31    template <class U> struct rebind {typedef ReboundA<U> other;};32};33 34template <class T, class U>35struct ReboundB {};36 37template <class T, class U>38struct B39{40    typedef T value_type;41 42    template <class V> struct rebind {typedef ReboundB<V, U> other;};43};44 45template <class T>46struct C47{48    typedef T value_type;49};50 51template <class T, class U>52struct D53{54    typedef T value_type;55};56 57template <class T>58struct E59{60    typedef T value_type;61 62    template <class U> struct rebind {typedef ReboundA<U> otter;};63};64 65int main(int, char**)66{67#if TEST_STD_VER >= 1168    static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>, std::allocator_traits<ReboundA<double> > >::value), "");69    static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>, std::allocator_traits<ReboundB<double, char> > >::value), "");70    static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>, std::allocator_traits<C<double> > >::value), "");71    static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>, std::allocator_traits<D<double, char> > >::value), "");72    static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>, std::allocator_traits<E<double> > >::value), "");73#else74    static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>::other, std::allocator_traits<ReboundA<double> > >::value), "");75    static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>::other, std::allocator_traits<ReboundB<double, char> > >::value), "");76    static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>::other, std::allocator_traits<C<double> > >::value), "");77    static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>::other, std::allocator_traits<D<double, char> > >::value), "");78    static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>::other, std::allocator_traits<E<double> > >::value), "");79#endif80 81  return 0;82}83