OSDN Git Service

PR c++/26714
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / cpp0x / variadic98.C
1 // PR c++/42358
2 // { dg-do assemble }
3 // { dg-options -std=c++0x }
4
5 typedef __PTRDIFF_TYPE__ ptrdiff_t;
6 typedef __SIZE_TYPE__ size_t;
7 namespace std __attribute__ ((__visibility__ ("default"))) {
8     using ::size_t;
9 }
10 namespace std __attribute__ ((__visibility__ ("default"))) {
11     struct __sfinae_types   {
12         typedef char __one;
13         typedef struct {
14         } __two;
15     };
16     template<typename _Tp, _Tp __v>     struct integral_constant     {
17         static const _Tp value = __v;
18         typedef _Tp value_type;
19         typedef integral_constant<_Tp, __v> type;
20     };
21     typedef integral_constant<bool, false> false_type;
22     template<typename>     struct remove_cv;
23     template<typename>     struct __is_void_helper     : public false_type {
24     };
25     template<typename _Tp>     struct is_void     : public integral_constant<bool, (__is_void_helper<typename           remove_cv<_Tp>::type>::value)>     {
26     };
27     template<typename>     struct is_array     : public false_type {
28     };
29     template<typename>     struct is_function     : public false_type {
30     };
31     template<typename, unsigned _Uint = 0>     struct extent     : public integral_constant<std::size_t, 0> {
32     };
33     template<typename _Tp>     struct remove_const     {
34         typedef _Tp type;
35     };
36     template<typename _Tp>     struct remove_volatile     {
37         typedef _Tp type;
38     };
39     template<typename _Tp>     struct remove_cv     {
40         typedef typename       remove_const<typename remove_volatile<_Tp>::type>::type type;
41     };
42     template<typename>     struct is_lvalue_reference     : public false_type {
43     };
44     template<typename>     struct is_rvalue_reference     : public false_type {
45     };
46     template<typename _Tp>     struct is_reference     : public integral_constant<bool, (is_lvalue_reference<_Tp>::value           || is_rvalue_reference<_Tp>::value)>     {
47     };
48     template<typename _Tp>     struct remove_reference     {
49         typedef _Tp type;
50     };
51     template<typename _Tp,     bool = !is_reference<_Tp>::value && !is_void<_Tp>::value>     struct __add_rvalue_reference_helper     {
52         typedef _Tp type;
53     };
54     template<typename _Tp>     struct add_rvalue_reference     : public __add_rvalue_reference_helper<_Tp>     {
55     };
56     template<typename _Tp>     typename add_rvalue_reference<_Tp>::type declval();
57     template<typename _From, typename _To,     bool = (is_void<_From>::value || is_void<_To>::value      || is_function<_To>::value || is_array<_To>::value)>     struct __is_convertible_helper     {
58     };
59     template<typename _From, typename _To>     struct __is_convertible_helper<_From, _To, false>     : public __sfinae_types     {
60         static __one __test(_To);
61         static __two __test(...);
62         static const bool __value = sizeof(__test(declval<_From>())) == 1;
63     };
64     template<typename _From, typename _To>     struct is_convertible     : public integral_constant<bool,           __is_convertible_helper<_From, _To>::__value>     {
65     };
66     template<bool, typename _Tp = void>     struct enable_if     {
67     };
68     template<typename _Tp>     struct enable_if<true, _Tp>     {
69         typedef _Tp type;
70     };
71     template<typename _Tp>     struct identity     {
72         typedef _Tp type;
73     };
74     template<typename _Tp>     inline typename enable_if<!is_lvalue_reference<_Tp>::value, _Tp&&>::type     forward(typename std::identity<_Tp>::type& __t)     {
75     }
76     template<typename _Tp>     inline typename enable_if<is_lvalue_reference<_Tp>::value, _Tp>::type     forward(typename std::identity<_Tp>::type __t)     {
77     }
78     template<typename _Tp>     inline typename std::remove_reference<_Tp>::type&&     move(_Tp&& __t)     {
79     }
80     template<class _T1, class _T2>     struct pair     {
81         typedef _T1 first_type;
82         typedef _T2 second_type;
83         _T1 first;
84         _T2 second;
85         template<class _U1, class = typename         std::enable_if<std::is_convertible<_U1, _T1>::value>::type>         pair(_U1&& __x, const _T2& __y)  : first(std::forward<_U1>(__x)),    second(__y) {
86         }
87         template<class _U2, class = typename         std::enable_if<std::is_convertible<_U2, _T2>::value>::type>         pair(const _T1& __x, _U2&& __y)  : first(__x),    second(std::forward<_U2>(__y)) {
88         }
89         template<class _U1, class _U2, class = typename         std::enable_if<std::is_convertible<_U1, _T1>::value          && std::is_convertible<_U2, _T2>::value>::type>         pair(_U1&& __x, _U2&& __y)  : first(std::forward<_U1>(__x)),    second(std::forward<_U2>(__y)) {
90         }
91         template<class _U1, class _U2>         pair(pair<_U1, _U2>&& __p)  : first(std::move(__p.first)),    second(std::move(__p.second)) {
92         }
93         template<class _U1, class _U2>         pair&         operator=(pair<_U1, _U2>&& __p)  {
94         }
95     };
96     struct input_iterator_tag {
97     };
98     struct output_iterator_tag {
99     };
100     struct forward_iterator_tag : public input_iterator_tag {
101     };
102     struct bidirectional_iterator_tag : public forward_iterator_tag {
103     };
104     template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,            typename _Pointer = _Tp*, typename _Reference = _Tp&>     struct iterator     {
105         typedef _Category iterator_category;
106         typedef _Tp value_type;
107         typedef _Distance difference_type;
108         typedef _Pointer pointer;
109         typedef _Reference reference;
110     };
111     template<typename _Iterator>     struct iterator_traits     {
112         typedef typename _Iterator::iterator_category iterator_category;
113         typedef typename _Iterator::value_type value_type;
114         typedef typename _Iterator::difference_type difference_type;
115         typedef typename _Iterator::pointer pointer;
116         typedef typename _Iterator::reference reference;
117     };
118     template<typename _Iter>     inline typename iterator_traits<_Iter>::iterator_category     __iterator_category(const _Iter&)     {
119     }
120     template<typename _InputIterator>     inline typename iterator_traits<_InputIterator>::difference_type     __distance(_InputIterator __first, _InputIterator __last,                input_iterator_tag)     {
121     }
122     template<typename _InputIterator>     inline typename iterator_traits<_InputIterator>::difference_type     distance(_InputIterator __first, _InputIterator __last)     {
123         return std::__distance(__first, __last,         std::__iterator_category(__first));
124     }
125     template<typename _Iterator>     class reverse_iterator     : public iterator<typename iterator_traits<_Iterator>::iterator_category,         typename iterator_traits<_Iterator>::value_type,         typename iterator_traits<_Iterator>::difference_type,         typename iterator_traits<_Iterator>::pointer,                       typename iterator_traits<_Iterator>::reference>     {
126     };
127     template<typename _Container>     class back_insert_iterator     : public iterator<output_iterator_tag, void, void, void, void>     {
128     };
129 }
130 namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
131     template<typename _Tp>     class new_allocator     {
132     public:
133         typedef size_t size_type;
134         typedef ptrdiff_t difference_type;
135         typedef _Tp* pointer;
136         typedef const _Tp* const_pointer;
137         typedef _Tp& reference;
138         typedef const _Tp& const_reference;
139         typedef _Tp value_type;
140         new_allocator() throw() {
141         }
142         new_allocator(const new_allocator&) throw() {
143         }
144         template<typename _Tp1>         new_allocator(const new_allocator<_Tp1>&) throw() {
145         }
146         template<typename... _Args>         void         construct(pointer __p, _Args&&... __args)  {
147         }
148     };
149 }
150 namespace std __attribute__ ((__visibility__ ("default"))) {
151     template<typename _Tp>     class allocator: public __gnu_cxx::new_allocator<_Tp>     {
152     public:
153         typedef size_t size_type;
154         typedef ptrdiff_t difference_type;
155         typedef _Tp* pointer;
156         typedef const _Tp* const_pointer;
157         typedef _Tp& reference;
158         typedef const _Tp& const_reference;
159         typedef _Tp value_type;
160         template<typename _Tp1>         struct rebind         {
161             typedef allocator<_Tp1> other;
162         };
163         allocator() throw() {
164         }
165         template<typename _Tp1>         allocator(const allocator<_Tp1>&) throw() {
166         }
167     };
168     extern template class allocator<char>;
169     extern template class allocator<wchar_t>;
170     template<typename _Arg, typename _Result>     struct unary_function     {
171         typedef _Arg argument_type;
172         typedef _Result result_type;
173     };
174     template<typename _Arg1, typename _Arg2, typename _Result>     struct binary_function     {
175         typedef _Arg1 first_argument_type;
176         typedef _Arg2 second_argument_type;
177         typedef _Result result_type;
178     };
179     template<typename _Tp>     struct less : public binary_function<_Tp, _Tp, bool>     {
180         bool       operator()(const _Tp& __x, const _Tp& __y) const       {
181         }
182     };
183     template<typename _Pair>     struct _Select1st : public unary_function<_Pair,            typename _Pair::first_type>     {
184         const typename _Pair::first_type&       operator()(const _Pair& __x) const       {
185         }
186     };
187     struct _Rb_tree_node_base   {
188         typedef _Rb_tree_node_base* _Base_ptr;
189         typedef const _Rb_tree_node_base* _Const_Base_ptr;
190     };
191     template<typename _Val>     struct _Rb_tree_node : public _Rb_tree_node_base     {
192         typedef _Rb_tree_node<_Val>* _Link_type;
193         _Val _M_value_field;
194         template<typename... _Args>         _Rb_tree_node(_Args&&... __args)  : _Rb_tree_node_base(),    _M_value_field(std::forward<_Args>(__args)...) {
195         }
196     };
197     template<typename _Tp>     struct _Rb_tree_iterator     {
198         typedef _Tp value_type;
199         typedef _Tp& reference;
200         typedef _Tp* pointer;
201         typedef bidirectional_iterator_tag iterator_category;
202         typedef ptrdiff_t difference_type;
203         typedef _Rb_tree_iterator<_Tp> _Self;
204         typedef _Rb_tree_node_base::_Base_ptr _Base_ptr;
205         typedef _Rb_tree_node<_Tp>* _Link_type;
206         _Base_ptr _M_node;
207     };
208     template<typename _Tp>     struct _Rb_tree_const_iterator     {
209         typedef _Tp value_type;
210         typedef const _Tp& reference;
211         typedef const _Tp* pointer;
212         typedef _Rb_tree_iterator<_Tp> iterator;
213         typedef bidirectional_iterator_tag iterator_category;
214         typedef ptrdiff_t difference_type;
215         typedef _Rb_tree_const_iterator<_Tp> _Self;
216         typedef _Rb_tree_node_base::_Const_Base_ptr _Base_ptr;
217         typedef const _Rb_tree_node<_Tp>* _Link_type;
218         explicit       _Rb_tree_const_iterator(_Link_type __x)       : _M_node(__x) {
219         }
220         _Rb_tree_const_iterator(const iterator& __it)       : _M_node(__it._M_node) {
221         }
222         _Base_ptr _M_node;
223     };
224     template<typename _Key, typename _Val, typename _KeyOfValue,            typename _Compare, typename _Alloc = allocator<_Val> >     class _Rb_tree     {
225         typedef typename _Alloc::template rebind<_Rb_tree_node<_Val> >::other               _Node_allocator;
226         typedef _Rb_tree_node_base* _Base_ptr;
227         typedef const _Rb_tree_node_base* _Const_Base_ptr;
228     public:
229         typedef _Key key_type;
230         typedef _Val value_type;
231         typedef value_type* pointer;
232         typedef const value_type* const_pointer;
233         typedef value_type& reference;
234         typedef const value_type& const_reference;
235         typedef _Rb_tree_node<_Val>* _Link_type;
236         typedef const _Rb_tree_node<_Val>* _Const_Link_type;
237         typedef size_t size_type;
238         typedef ptrdiff_t difference_type;
239         typedef _Alloc allocator_type;
240         _Node_allocator&       _M_get_Node_allocator()       {
241         }
242         _Link_type       _M_get_node()       {
243         }
244         template<typename... _Args>         _Link_type         _M_create_node(_Args&&... __args)  {
245             _Link_type __tmp = _M_get_node();
246             try      {
247                 _M_get_Node_allocator().construct(__tmp,           std::forward<_Args>(__args)...);
248             }
249             catch(...)      {
250             }
251         }
252         template<typename _Key_compare,         bool _Is_pod_comparator = __is_pod(_Key_compare)>         struct _Rb_tree_impl : public _Node_allocator         {
253             _Key_compare _M_key_compare;
254             _Rb_tree_node_base _M_header;
255             size_type _M_node_count;
256             _Rb_tree_impl(const _Key_compare& __comp, const _Node_allocator& __a)    : _Node_allocator(__a), _M_key_compare(__comp), _M_header(),      _M_node_count(0)    {
257             }
258             void    _M_initialize()    {
259             }
260         };
261         _Rb_tree_impl<_Compare> _M_impl;
262         _Base_ptr&       _M_rightmost()       {
263         }
264         _Link_type       _M_begin()       {
265         }
266         _Link_type       _M_end()       {
267         }
268         _Const_Link_type       _M_end() const       {
269         }
270         static _Link_type       _S_right(_Base_ptr __x)       {
271         }
272         static const_reference       _S_value(_Const_Base_ptr __x)       {
273         }
274         static const _Key&       _S_key(_Const_Base_ptr __x)       {
275             return _KeyOfValue()(_S_value(__x));
276         }
277         typedef _Rb_tree_iterator<value_type> iterator;
278         typedef _Rb_tree_const_iterator<value_type> const_iterator;
279         typedef std::reverse_iterator<iterator> reverse_iterator;
280         typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
281         iterator       _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __y,    const value_type& __v);
282         iterator       _M_insert_lower(_Base_ptr __x, _Base_ptr __y, const value_type& __v);
283         iterator       _M_insert_equal_lower(const value_type& __x);
284         iterator       _M_lower_bound(_Link_type __x, _Link_type __y,        const _Key& __k);
285         iterator       _M_upper_bound(_Link_type __x, _Link_type __y,        const _Key& __k);
286         _Rb_tree(const _Compare& __comp,         const allocator_type& __a = allocator_type())       : _M_impl(__comp, __a) {
287         }
288         iterator       end()       {
289         }
290         iterator       _M_insert_equal_(const_iterator __position, const value_type& __x);
291         template<typename _InputIterator>         void         _M_insert_unique(_InputIterator __first, _InputIterator __last);
292         template<typename _InputIterator>         void         _M_insert_equal(_InputIterator __first, _InputIterator __last);
293         size_type       count(const key_type& __k) const;
294         pair<iterator, iterator>       equal_range(const key_type& __k);
295         pair<const_iterator, const_iterator>       equal_range(const key_type& __k) const;
296     };
297     template<typename _Key, typename _Val, typename _KeyOfValue,            typename _Compare, typename _Alloc>     typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator     _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::     _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __p, const _Val& __v)     {
298         _Link_type __z = _M_create_node(__v);
299     }
300     template<typename _Key, typename _Val, typename _KeyOfValue,            typename _Compare, typename _Alloc>     typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator     _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::     _M_insert_lower(_Base_ptr __x, _Base_ptr __p, const _Val& __v)     {
301         _Link_type __z = _M_create_node(__v);
302     }
303     template<typename _Key, typename _Val, typename _KeyOfValue,            typename _Compare, typename _Alloc>     typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator     _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::     _M_insert_equal_lower(const _Val& __v)     {
304         _Link_type __x = _M_begin();
305         _Link_type __y = _M_end();
306         return _M_insert_lower(__x, __y, __v);
307     }
308     template<typename _Key, typename _Val, typename _KeyOfValue,            typename _Compare, typename _Alloc>     pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,       _Compare, _Alloc>::iterator,   typename _Rb_tree<_Key, _Val, _KeyOfValue,       _Compare, _Alloc>::iterator>     _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::     equal_range(const _Key& __k)     {
309         _Link_type __x = _M_begin();
310         _Link_type __y = _M_end();
311         while (__x != 0)  {
312             if (_M_impl._M_key_compare(_S_key(__x), __k))      __x = _S_right(__x);
313             else      {
314                 _Link_type __xu(__x), __yu(__y);
315                 return pair<iterator,             iterator>(_M_lower_bound(__x, __y, __k),         _M_upper_bound(__xu, __yu, __k));
316             }
317         }
318     }
319     template<typename _Key, typename _Val, typename _KeyOfValue,            typename _Compare, typename _Alloc>     pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,       _Compare, _Alloc>::const_iterator,   typename _Rb_tree<_Key, _Val, _KeyOfValue,       _Compare, _Alloc>::const_iterator>     _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::     equal_range(const _Key& __k) const     {
320         _Const_Link_type __y = _M_end();
321         return pair<const_iterator, const_iterator>(const_iterator(__y),         const_iterator(__y));
322     }
323     template<typename _Key, typename _Val, typename _KeyOfValue,            typename _Compare, typename _Alloc>     typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator     _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::     _M_insert_equal_(const_iterator __position, const _Val& __v)     {
324         if (__position._M_node == _M_end())  {
325             if (__position._M_node == _M_rightmost())      return _M_insert_(0, _M_rightmost(), __v);
326             else      return _M_insert_equal_lower(__v);
327         }
328     }
329     template<typename _Key, typename _Val, typename _KoV,            typename _Cmp, typename _Alloc>     template<class _II>       void       _Rb_tree<_Key, _Val, _KoV, _Cmp, _Alloc>::       _M_insert_equal(_II __first, _II __last)       {
330         for (;
331              __first != __last;
332              ++__first)    _M_insert_equal_(end(), *__first);
333     }
334     template<typename _Key, typename _Val, typename _KeyOfValue,            typename _Compare, typename _Alloc>     typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type     _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::     count(const _Key& __k) const     {
335         pair<const_iterator, const_iterator> __p = equal_range(__k);
336         const size_type __n = std::distance(__p.first, __p.second);
337     }
338     template<class _E>     class initializer_list     {
339     public:
340         typedef _E value_type;
341         typedef const _E& reference;
342         typedef const _E& const_reference;
343         typedef size_t size_type;
344         typedef const _E* iterator;
345         typedef const _E* const_iterator;
346         iterator _M_array;
347         size_type _M_len;
348         initializer_list(const_iterator __a, size_type __l)       : _M_array(__a), _M_len(__l) {
349         }
350         const_iterator       begin() const {
351         }
352         const_iterator       end() const {
353         }
354     };
355     template <typename _Key, typename _Tp,      typename _Compare = std::less<_Key>,      typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >     class multimap     {
356         typedef _Key key_type;
357         typedef _Tp mapped_type;
358         typedef std::pair<const _Key, _Tp> value_type;
359         typedef _Compare key_compare;
360         typedef _Alloc allocator_type;
361         typedef typename _Alloc::value_type _Alloc_value_type;
362         typedef typename _Alloc::template rebind<value_type>::other         _Pair_alloc_type;
363         typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,          key_compare, _Pair_alloc_type> _Rep_type;
364         _Rep_type _M_t;
365     public:
366         typedef typename _Pair_alloc_type::pointer pointer;
367         typedef typename _Pair_alloc_type::const_pointer const_pointer;
368         typedef typename _Pair_alloc_type::reference reference;
369         typedef typename _Pair_alloc_type::const_reference const_reference;
370         typedef typename _Rep_type::iterator iterator;
371         typedef typename _Rep_type::const_iterator const_iterator;
372         typedef typename _Rep_type::size_type size_type;
373         typedef typename _Rep_type::difference_type difference_type;
374         typedef typename _Rep_type::reverse_iterator reverse_iterator;
375         typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
376         multimap(initializer_list<value_type> __l,         const _Compare& __comp = _Compare(),         const allocator_type& __a = allocator_type())       : _M_t(__comp, __a)       {
377             _M_t._M_insert_equal(__l.begin(), __l.end());
378         }
379         template<typename _InputIterator>         multimap(_InputIterator __first, _InputIterator __last)  : _M_t()         {
380         }
381         template<typename _InputIterator>         multimap(_InputIterator __first, _InputIterator __last,    const _Compare& __comp,    const allocator_type& __a = allocator_type())         : _M_t(__comp, __a)         {
382         }
383         template<typename _InputIterator>         void         insert(_InputIterator __first, _InputIterator __last)         {
384         }
385         size_type       count(const key_type& __x) const       {
386             return _M_t.count(__x);
387         }
388         std::pair<iterator, iterator>       equal_range(const key_type& __x)       {
389             return _M_t.equal_range(__x);
390         }
391         template<typename _K1, typename _T1, typename _C1, typename _A1>         friend bool         operator==(const multimap<_K1, _T1, _C1, _A1>&,      const multimap<_K1, _T1, _C1, _A1>&);
392         template<typename _K1, typename _T1, typename _C1, typename _A1>         friend bool         operator<(const multimap<_K1, _T1, _C1, _A1>&,     const multimap<_K1, _T1, _C1, _A1>&);
393     };
394 }
395 extern "C" {
396     extern void __assert_fail (__const char *__assertion, __const char *__file,       unsigned int __line, __const char *__function)      throw () __attribute__ ((__noreturn__));
397 }
398 using namespace std;
399 int test01() {
400     typedef multimap<int,double> Container;
401     typedef Container::iterator iterator;
402     typedef pair<iterator,iterator> itpair;
403     Container m({
404                 {
405                 1, 1.0 }
406                 }
407                );
408     itpair ip = m.equal_range(1);
409     ((distance(ip.first, ip.second) == 3) ? static_cast<void> (0) : __assert_fail ("distance(ip.first, ip.second) == 3", "/home/richard/src/trunk/libstdc++-v3/testsuite/23_containers/multimap/init-list.cc", 36, __PRETTY_FUNCTION__));
410     ((m.count(7) == 2) ? static_cast<void> (0) : __assert_fail ("m.count(7) == 2", "/home/richard/src/trunk/libstdc++-v3/testsuite/23_containers/multimap/init-list.cc", 54, __PRETTY_FUNCTION__));
411 }