| 1 |
// { dg-do compile } |
| 2 |
// { dg-options "-std=c++11 -O2 -fnon-call-exceptions" } |
| 3 |
|
| 4 |
template < typename > class allocator; |
| 5 |
|
| 6 |
template < class _CharT > struct char_traits; |
| 7 |
template < typename _CharT, typename _Traits = char_traits < _CharT >, |
| 8 |
typename _Alloc = allocator < _CharT > >class basic_string; |
| 9 |
typedef basic_string < char >string; |
| 10 |
|
| 11 |
template < typename _Tp > class new_allocator |
| 12 |
{ |
| 13 |
template < typename _Tp1 > struct rebind |
| 14 |
{ |
| 15 |
typedef new_allocator < _Tp1 > other; |
| 16 |
}; |
| 17 |
}; |
| 18 |
|
| 19 |
template < typename _Tp > using __allocator_base = new_allocator < _Tp >; |
| 20 |
template < typename _Tp > class allocator:public __allocator_base < _Tp > |
| 21 |
{ |
| 22 |
}; |
| 23 |
|
| 24 |
template < typename _CharT, typename _Traits, typename _Alloc > |
| 25 |
class basic_string |
| 26 |
{ |
| 27 |
public: |
| 28 |
basic_string (const _CharT * __s, const _Alloc & __a = _Alloc ()); |
| 29 |
~basic_string ()noexcept; |
| 30 |
}; |
| 31 |
|
| 32 |
template < typename T > struct add_reference |
| 33 |
{ |
| 34 |
typedef T & type; |
| 35 |
}; |
| 36 |
|
| 37 |
template < typename ... Values > class tuple; |
| 38 |
template <> class tuple <> |
| 39 |
{ |
| 40 |
}; |
| 41 |
|
| 42 |
template < typename Head, typename ... Tail > class tuple < Head, Tail ... >:private tuple < |
| 43 |
Tail ... |
| 44 |
> |
| 45 |
{ |
| 46 |
typedef tuple < Tail ... >inherited; |
| 47 |
public: |
| 48 |
template < typename ... VValues > |
| 49 |
tuple (const tuple < VValues ... >&other):inherited (other.tail ()), |
| 50 |
m_head (other.head ()) |
| 51 |
{ |
| 52 |
} |
| 53 |
typename add_reference < const Head >::type head () const |
| 54 |
{ |
| 55 |
return m_head; |
| 56 |
} |
| 57 |
const inherited & tail () const |
| 58 |
{ |
| 59 |
return *this; |
| 60 |
} |
| 61 |
Head m_head; |
| 62 |
}; |
| 63 |
|
| 64 |
template < typename T > struct make_tuple_result |
| 65 |
{ |
| 66 |
typedef T type; |
| 67 |
}; |
| 68 |
|
| 69 |
template < typename ... Values > |
| 70 |
tuple < typename make_tuple_result < |
| 71 |
Values >::type ... >make_tuple (const Values & ... values); |
| 72 |
|
| 73 |
int |
| 74 |
main () |
| 75 |
{ |
| 76 |
tuple < int, float, string > t3c = |
| 77 |
make_tuple (17, 2.718281828, string ("Fun")); |
| 78 |
} |