blob: a1f8862debbe201f6c54fd1bb6ae0d901facd304 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <forward_list>
11
12// template <class T, class Allocator = allocator<T>>
13// class forward_list
14// {
15// public:
16// typedef T value_type;
17// typedef Allocator allocator_type;
Howard Hinnant6046ace2010-08-22 00:15:28 +000018//
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000019// typedef value_type& reference;
20// typedef const value_type& const_reference;
21// typedef typename allocator_traits<allocator_type>::pointer pointer;
22// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
23// typedef typename allocator_traits<allocator_type>::size_type size_type;
24// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
25// ...
26// };
27
28#include <forward_list>
29#include <type_traits>
30
Marshall Clow061d0cc2013-11-26 20:58:02 +000031#include "min_allocator.h"
Howard Hinnant81381a92013-06-24 17:17:28 +000032
Marshall Clowa1bca662015-01-26 20:06:52 +000033struct A { std::forward_list<A> v; }; // incomplete type support
34
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000035int main()
36{
Marshall Clow51349532014-07-08 15:19:40 +000037 {
38 typedef std::forward_list<char> C;
39 static_assert((std::is_same<C::value_type, char>::value), "");
40 static_assert((std::is_same<C::allocator_type, std::allocator<char> >::value), "");
41 static_assert((std::is_same<C::reference, char&>::value), "");
42 static_assert((std::is_same<C::const_reference, const char&>::value), "");
43 static_assert((std::is_same<C::pointer, char*>::value), "");
44 static_assert((std::is_same<C::const_pointer, const char*>::value), "");
45 static_assert((std::is_same<C::size_type, std::size_t>::value), "");
46 static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
47 }
Howard Hinnant81381a92013-06-24 17:17:28 +000048#if __cplusplus >= 201103L
Marshall Clow51349532014-07-08 15:19:40 +000049 {
50 typedef std::forward_list<char, min_allocator<char>> C;
51 static_assert((std::is_same<C::value_type, char>::value), "");
52 static_assert((std::is_same<C::allocator_type, min_allocator<char> >::value), "");
53 static_assert((std::is_same<C::reference, char&>::value), "");
54 static_assert((std::is_same<C::const_reference, const char&>::value), "");
55 static_assert((std::is_same<C::pointer, min_pointer<char>>::value), "");
56 static_assert((std::is_same<C::const_pointer, min_pointer<const char>>::value), "");
57// min_allocator doesn't have a size_type, so one gets synthesized
58 static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
59 static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
60 }
Howard Hinnant81381a92013-06-24 17:17:28 +000061#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000062}