Guest User

Untitled

a guest
Dec 14th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.42 KB | None | 0 0
  1. // tuple standard header
  2. #pragma once
  3. #ifndef _TUPLE_
  4. #define _TUPLE_
  5. #ifndef RC_INVOKED
  6. #include <new>
  7. #include <type_traits>
  8. #include <xutility>
  9.  
  10. #pragma pack(push,_CRT_PACKING)
  11. #pragma warning(push,3)
  12. #pragma push_macro("new")
  13. #undef new
  14.  
  15. _STD_BEGIN
  16. // ALIAS TEMPLATE _Tuple_implicit_t
  17. template<bool _Same,
  18. class _Dest,
  19. class... _Srcs>
  20. struct _Tuple_implicit_val0
  21. : false_type
  22. { // Constrain tuple's implicit constructors
  23. };
  24.  
  25. template<class... _Dests,
  26. class... _Srcs>
  27. struct _Tuple_implicit_val0<true, tuple<_Dests...>, _Srcs...>
  28. : conjunction<
  29. is_constructible<_Dests, _Srcs>...,
  30. is_convertible<_Srcs, _Dests>...
  31. >::type
  32. { // Constrain tuple's implicit constructors
  33. };
  34.  
  35. template<class _Dest,
  36. class... _Srcs>
  37. struct _Tuple_implicit_val
  38. : _Tuple_implicit_val0<tuple_size<_Dest>::value == sizeof...(_Srcs), _Dest, _Srcs...>::type
  39. { // Constrain tuple's implicit constructors
  40. };
  41.  
  42. template<class _Dest,
  43. class... _Srcs>
  44. using _Tuple_implicit_t = enable_if_t<_Tuple_implicit_val<_Dest, _Srcs...>::value, int>;
  45.  
  46. // ALIAS TEMPLATE _Tuple_explicit_t
  47. template<bool _Same,
  48. class _Dest,
  49. class... _Srcs>
  50. struct _Tuple_explicit_val0
  51. : false_type
  52. { // Constrain tuple's explicit constructors
  53. };
  54.  
  55. template<class... _Dests,
  56. class... _Srcs>
  57. struct _Tuple_explicit_val0<true, tuple<_Dests...>, _Srcs...>
  58. : conjunction<
  59. is_constructible<_Dests, _Srcs>...,
  60. negation<conjunction<is_convertible<_Srcs, _Dests>...>>
  61. >::type
  62. { // Constrain tuple's explicit constructors
  63. };
  64.  
  65. template<class _Dest,
  66. class... _Srcs>
  67. struct _Tuple_explicit_val
  68. : _Tuple_explicit_val0<tuple_size<_Dest>::value == sizeof...(_Srcs), _Dest, _Srcs...>::type
  69. { // Constrain tuple's explicit constructors
  70. };
  71.  
  72. template<class _Dest,
  73. class... _Srcs>
  74. using _Tuple_explicit_t = enable_if_t<_Tuple_explicit_val<_Dest, _Srcs...>::value, int>;
  75.  
  76. // ALIAS TEMPLATE _Tuple_convert_copy_t
  77. template<class _Myt,
  78. class... _Other>
  79. struct _Tuple_convert_copy
  80. { // Constrain tuple's converting copy constructor (LWG 2549)
  81. typedef int type;
  82. };
  83.  
  84. template<class _This,
  85. class _Uty>
  86. struct _Tuple_convert_copy<tuple<_This>, _Uty>
  87. : enable_if<!is_same<_This, _Uty>::value
  88. && !is_constructible<_This, const tuple<_Uty>&>::value
  89. && !is_convertible<const tuple<_Uty>&, _This>::value, int>
  90. { // Constrain tuple's converting copy constructor (LWG 2549)
  91. };
  92.  
  93. template<class _Myt,
  94. class... _Other>
  95. using _Tuple_convert_copy_t = typename _Tuple_convert_copy<_Myt, _Other...>::type;
  96.  
  97. // ALIAS TEMPLATE _Tuple_convert_move_t
  98. template<class _Myt,
  99. class... _Other>
  100. struct _Tuple_convert_move
  101. { // Constrain tuple's converting move constructor (LWG 2549)
  102. typedef int type;
  103. };
  104.  
  105. template<class _This,
  106. class _Uty>
  107. struct _Tuple_convert_move<tuple<_This>, _Uty>
  108. : enable_if<!is_same<_This, _Uty>::value
  109. && !is_constructible<_This, tuple<_Uty> >::value
  110. && !is_convertible<tuple<_Uty>, _This>::value, int>
  111. { // Constrain tuple's converting move constructor (LWG 2549)
  112. };
  113.  
  114. template<class _Myt,
  115. class... _Other>
  116. using _Tuple_convert_move_t = typename _Tuple_convert_move<_Myt, _Other...>::type;
  117.  
  118. // STRUCT TEMPLATE _Tuple_perfect_val
  119. template<class _Myt,
  120. class _This2,
  121. class... _Rest2>
  122. struct _Tuple_perfect_val
  123. : true_type
  124. { // Constrain tuple's perfect forwarding constructor (LWG issue not yet filed)
  125. };
  126.  
  127. template<class _Myt,
  128. class _This2>
  129. struct _Tuple_perfect_val<_Myt, _This2>
  130. : negation<is_same<_Myt, remove_const_t<remove_reference_t<_This2>>>>::type
  131. { // Constrain tuple's perfect forwarding constructor (LWG issue not yet filed)
  132. };
  133.  
  134. // STRUCT _Ignore
  135. struct _Ignore
  136. { // struct that ignores assignments
  137. template<class _Ty>
  138. void operator=(const _Ty&) const
  139. { // do nothing
  140. }
  141. };
  142.  
  143. constexpr _Ignore ignore{};
  144.  
  145. // STRUCT _Tuple_alloc_t
  146. struct _Tuple_alloc_t
  147. { // tag type to disambiguate added allocator argument
  148. };
  149.  
  150. constexpr _Tuple_alloc_t _Tuple_alloc{};
  151.  
  152. // TEMPLATE CLASS _Tuple_val
  153. template<class _Ty>
  154. struct _Tuple_val
  155. { // stores each value in a tuple
  156. constexpr _Tuple_val()
  157. : _Val()
  158. { // default construct
  159. }
  160.  
  161. template<class _Other>
  162. constexpr _Tuple_val(_Other&& _Arg)
  163. : _Val(_STD forward<_Other>(_Arg))
  164. { // construct with argument
  165. }
  166.  
  167. template<class _Other>
  168. _Tuple_val& operator=(_Other&& _Right)
  169. { // assign
  170. _Val = _STD forward<_Other>(_Right);
  171. return (*this);
  172. }
  173.  
  174. template<class _Alloc,
  175. class... _Other>
  176. _Tuple_val(const _Alloc&,
  177. typename enable_if<!uses_allocator<_Ty, _Alloc>::value,
  178. _Tuple_alloc_t>::type, _Other&&... _Arg)
  179. : _Val(_STD forward<_Other>(_Arg)...)
  180. { // construct with optional arguments, no allocator
  181. }
  182.  
  183. template<class _Alloc,
  184. class... _Other>
  185. _Tuple_val(const _Alloc& _Al,
  186. typename enable_if<uses_allocator<_Ty, _Alloc>::value
  187. && is_constructible<_Ty,
  188. allocator_arg_t, _Alloc>::value,
  189. _Tuple_alloc_t>::type, _Other&&... _Arg)
  190. : _Val(allocator_arg, _Al, _STD forward<_Other>(_Arg)...)
  191. { // construct with optional arguments, leading allocator
  192. }
  193.  
  194. template<class _Alloc,
  195. class... _Other>
  196. _Tuple_val(const _Alloc& _Al,
  197. typename enable_if<uses_allocator<_Ty, _Alloc>::value
  198. && !is_constructible<_Ty,
  199. allocator_arg_t, _Alloc>::value,
  200. _Tuple_alloc_t>::type, _Other&&... _Arg)
  201. : _Val(_STD forward<_Other>(_Arg)..., _Al)
  202. { // construct with optional arguments, trailing allocator
  203. }
  204.  
  205. _Ty _Val;
  206. };
  207.  
  208. // TEMPLATE CLASS tuple
  209. struct _Exact_args_t
  210. { // tag type to disambiguate construction (from one arg per element)
  211. };
  212.  
  213. struct _Unpack_tuple_t
  214. { // tag type to disambiguate construction (from unpacking a tuple/pair)
  215. };
  216.  
  217. struct _Alloc_exact_args_t
  218. { // tag type to disambiguate construction (from an allocator and one arg per element)
  219. };
  220.  
  221. struct _Alloc_unpack_tuple_t
  222. { // tag type to disambiguate construction (from an allocator and unpacking a tuple/pair)
  223. };
  224.  
  225. template<class... _Types>
  226. class tuple;
  227.  
  228. template<>
  229. class tuple<>
  230. { // empty tuple
  231. public:
  232. typedef tuple<> _Myt;
  233.  
  234. constexpr tuple() _NOEXCEPT
  235. { // default construct
  236. }
  237.  
  238. template<class _Alloc>
  239. tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT
  240. { // default construct, allocator
  241. }
  242.  
  243. constexpr tuple(const tuple&) _NOEXCEPT
  244. { // copy construct
  245. }
  246.  
  247. template<class _Alloc>
  248. tuple(allocator_arg_t, const _Alloc&, const _Myt&) _NOEXCEPT
  249. { // copy construct, allocator
  250. }
  251.  
  252. template<class _Tag,
  253. enable_if_t<is_same<_Tag, _Exact_args_t>::value, int> = 0>
  254. constexpr tuple(_Tag) _NOEXCEPT
  255. { // construct from one arg per element
  256. }
  257.  
  258. template<class _Tag,
  259. enable_if_t<is_same<_Tag, _Unpack_tuple_t>::value, int> = 0>
  260. constexpr tuple(_Tag, const _Myt&) _NOEXCEPT
  261. { // construct from unpacking a tuple (TRANSITION, VSO#194815)
  262. }
  263.  
  264. template<class _Tag,
  265. class _Alloc,
  266. enable_if_t<is_same<_Tag, _Alloc_exact_args_t>::value, int> = 0>
  267. tuple(_Tag, const _Alloc&) _NOEXCEPT
  268. { // construct from an allocator and one arg per element
  269. }
  270.  
  271. void swap(_Myt&) _NOEXCEPT
  272. { // swap elements
  273. }
  274.  
  275. constexpr bool _Equals(const _Myt&) const _NOEXCEPT
  276. { // test if *this == _Right
  277. return (true);
  278. }
  279.  
  280. constexpr bool _Less(const _Myt&) const _NOEXCEPT
  281. { // test if *this < _Right
  282. return (false);
  283. }
  284. };
  285.  
  286. template<class _This,
  287. class... _Rest>
  288. class tuple<_This, _Rest...>
  289. : private tuple<_Rest...>
  290. { // recursive tuple definition
  291. public:
  292. typedef _This _This_type;
  293. typedef tuple<_This, _Rest...> _Myt;
  294. typedef tuple<_Rest...> _Mybase;
  295. static constexpr size_t _Mysize = 1 + sizeof...(_Rest);
  296.  
  297. template<class _Tag,
  298. class _This2,
  299. class... _Rest2,
  300. enable_if_t<is_same<_Tag, _Exact_args_t>::value, int> = 0>
  301. constexpr tuple(_Tag, _This2&& _This_arg, _Rest2&&... _Rest_arg)
  302. : _Mybase(_Exact_args_t{}, _STD forward<_Rest2>(_Rest_arg)...),
  303. _Myfirst(_STD forward<_This2>(_This_arg))
  304. { // construct from one arg per element
  305. }
  306.  
  307. /* TRANSITION, VSO#194815
  308. template<class _Tag,
  309. class _Tpl,
  310. size_t... _Indices,
  311. enable_if_t<is_same<_Tag, _Unpack_tuple_t>::value, int> = 0> inline
  312. constexpr tuple(_Tag, _Tpl&& _Right, integer_sequence<size_t, _Indices...>);
  313. */
  314.  
  315. /* TRANSITION, VSO#194815
  316. template<class _Tag,
  317. class _Tpl,
  318. enable_if_t<is_same<_Tag, _Unpack_tuple_t>::value, int> = 0>
  319. constexpr tuple(_Tag, _Tpl&& _Right)
  320. : tuple(_Unpack_tuple_t{}, _STD forward<_Tpl>(_Right),
  321. make_integer_sequence<size_t, tuple_size<remove_reference_t<_Tpl>>::value>{})
  322. { // construct from unpacking a tuple/pair
  323. }
  324. */
  325.  
  326. template<class _Tag,
  327. class... _Other,
  328. enable_if_t<is_same<_Tag, _Unpack_tuple_t>::value, int> = 0>
  329. constexpr tuple(_Tag, const tuple<_Other...>& _Right)
  330. : _Mybase(_Unpack_tuple_t{}, _Right._Get_rest()),
  331. _Myfirst(_Right._Myfirst._Val)
  332. { // construct from unpacking a tuple (TRANSITION, VSO#194815)
  333. }
  334.  
  335. template<class _Tag,
  336. class... _Other,
  337. enable_if_t<is_same<_Tag, _Unpack_tuple_t>::value, int> = 0>
  338. constexpr tuple(_Tag, tuple<_Other...>&& _Right)
  339. : _Mybase(_Unpack_tuple_t{}, (typename tuple<_Other...>::_Mybase&&) _Right),
  340. _Myfirst(_STD forward<typename tuple<_Other...>::_This_type>(_Right._Myfirst._Val))
  341. { // construct from unpacking a tuple (TRANSITION, VSO#194815)
  342. }
  343.  
  344. template<class _Tag,
  345. class _Alloc,
  346. class _This2,
  347. class... _Rest2,
  348. enable_if_t<is_same<_Tag, _Alloc_exact_args_t>::value, int> = 0>
  349. tuple(_Tag, const _Alloc& _Al, _This2&& _This_arg, _Rest2&&... _Rest_arg)
  350. : _Mybase(_Alloc_exact_args_t{}, _Al, _STD forward<_Rest2>(_Rest_arg)...),
  351. _Myfirst(_Al, _Tuple_alloc, _STD forward<_This2>(_This_arg))
  352. { // construct from an allocator and one arg per element
  353. }
  354.  
  355. template<class _Tag,
  356. class _Alloc,
  357. class _Tpl,
  358. size_t... _Indices,
  359. enable_if_t<is_same<_Tag, _Alloc_unpack_tuple_t>::value, int> = 0> inline
  360. tuple(_Tag, const _Alloc& _Al, _Tpl&& _Right, integer_sequence<size_t, _Indices...>);
  361.  
  362. template<class _Tag,
  363. class _Alloc,
  364. class _Tpl,
  365. enable_if_t<is_same<_Tag, _Alloc_unpack_tuple_t>::value, int> = 0>
  366. tuple(_Tag, const _Alloc& _Al, _Tpl&& _Right)
  367. : tuple(_Alloc_unpack_tuple_t{}, _Al, _STD forward<_Tpl>(_Right),
  368. make_integer_sequence<size_t, tuple_size<remove_reference_t<_Tpl>>::value>{})
  369. { // construct from an allocator and unpacking a tuple/pair
  370. }
  371.  
  372. template<class _This2 = _This,
  373. class = enable_if_t<conjunction<is_default_constructible<_This2>,
  374. is_default_constructible<_Rest>...>::value> >
  375. constexpr tuple()
  376. : _Mybase(), _Myfirst()
  377. { // construct default
  378. }
  379.  
  380. template<class... _Other,
  381. _Tuple_implicit_t<_Myt, const _Other&...> = 0,
  382. _Tuple_convert_copy_t<_Myt, _Other...> = 0>
  383. constexpr tuple(const tuple<_Other...>& _Right)
  384. // TRANSITION, VSO#194815
  385. // : tuple(_Unpack_tuple_t{}, _Right)
  386. : _Mybase(_Unpack_tuple_t{}, _Right._Get_rest()),
  387. _Myfirst(_Right._Myfirst._Val)
  388. { // construct by copying same size tuple
  389. }
  390.  
  391. template<class... _Other,
  392. _Tuple_explicit_t<_Myt, const _Other&...> = 0,
  393. _Tuple_convert_copy_t<_Myt, _Other...> = 0>
  394. constexpr explicit tuple(const tuple<_Other...>& _Right)
  395. // TRANSITION, VSO#194815
  396. // : tuple(_Unpack_tuple_t{}, _Right)
  397. : _Mybase(_Unpack_tuple_t{}, _Right._Get_rest()),
  398. _Myfirst(_Right._Myfirst._Val)
  399. { // construct by copying same size tuple
  400. }
  401.  
  402. template<class _Alloc,
  403. class... _Other,
  404. _Tuple_implicit_t<_Myt, const _Other&...> = 0,
  405. _Tuple_convert_copy_t<_Myt, _Other...> = 0>
  406. tuple(allocator_arg_t, const _Alloc& _Al,
  407. const tuple<_Other...>& _Right)
  408. : tuple(_Alloc_unpack_tuple_t{}, _Al, _Right)
  409. { // construct by copying same size tuple, allocator
  410. }
  411.  
  412. template<class _Alloc,
  413. class... _Other,
  414. _Tuple_explicit_t<_Myt, const _Other&...> = 0,
  415. _Tuple_convert_copy_t<_Myt, _Other...> = 0>
  416. explicit tuple(allocator_arg_t, const _Alloc& _Al,
  417. const tuple<_Other...>& _Right)
  418. : tuple(_Alloc_unpack_tuple_t{}, _Al, _Right)
  419. { // construct by copying same size tuple, allocator
  420. }
  421.  
  422. template<class _This2 = _This,
  423. _Tuple_implicit_t<_Myt, const _This2&, const _Rest&...> = 0>
  424. constexpr tuple(const _This& _This_arg, const _Rest&... _Rest_arg)
  425. // TRANSITION, VSO#194815
  426. // : tuple(_Exact_args_t{}, _This_arg, _Rest_arg...)
  427. : _Mybase(_Exact_args_t{}, _Rest_arg...), _Myfirst(_This_arg)
  428. { // construct from one or more copied elements
  429. }
  430.  
  431. template<class _This2 = _This,
  432. _Tuple_explicit_t<_Myt, const _This2&, const _Rest&...> = 0>
  433. constexpr explicit tuple(const _This& _This_arg, const _Rest&... _Rest_arg)
  434. // TRANSITION, VSO#194815
  435. // : tuple(_Exact_args_t{}, _This_arg, _Rest_arg...)
  436. : _Mybase(_Exact_args_t{}, _Rest_arg...), _Myfirst(_This_arg)
  437. { // construct from one or more copied elements
  438. }
  439.  
  440. template<class _Alloc,
  441. class _This2 = _This,
  442. _Tuple_implicit_t<_Myt, const _This2&, const _Rest&...> = 0>
  443. tuple(allocator_arg_t, const _Alloc& _Al,
  444. const _This& _This_arg, const _Rest&... _Rest_arg)
  445. : tuple(_Alloc_exact_args_t{}, _Al, _This_arg, _Rest_arg...)
  446. { // construct from one or more copied elements, allocator
  447. }
  448.  
  449. template<class _Alloc,
  450. class _This2 = _This,
  451. _Tuple_explicit_t<_Myt, const _This2&, const _Rest&...> = 0>
  452. explicit tuple(allocator_arg_t, const _Alloc& _Al,
  453. const _This& _This_arg, const _Rest&... _Rest_arg)
  454. : tuple(_Alloc_exact_args_t{}, _Al, _This_arg, _Rest_arg...)
  455. { // construct from one or more copied elements, allocator
  456. }
  457.  
  458. template<class _This2,
  459. class... _Rest2,
  460. enable_if_t<conjunction<
  461. _Tuple_perfect_val<_Myt, _This2, _Rest2...>,
  462. _Tuple_implicit_val<_Myt, _This2, _Rest2...>
  463. >::value, int> = 0>
  464. constexpr tuple(_This2&& _This_arg, _Rest2&&... _Rest_arg)
  465. // TRANSITION, VSO#194815
  466. // : tuple(_Exact_args_t{}, _STD forward<_This2>(_This_arg), _STD forward<_Rest2>(_Rest_arg)...)
  467. : _Mybase(_Exact_args_t{}, _STD forward<_Rest2>(_Rest_arg)...),
  468. _Myfirst(_STD forward<_This2>(_This_arg))
  469. { // construct from one or more moved elements
  470. }
  471.  
  472. template<class _This2,
  473. class... _Rest2,
  474. enable_if_t<conjunction<
  475. _Tuple_perfect_val<_Myt, _This2, _Rest2...>,
  476. _Tuple_explicit_val<_Myt, _This2, _Rest2...>
  477. >::value, int> = 0>
  478. constexpr explicit tuple(_This2&& _This_arg, _Rest2&&... _Rest_arg)
  479. // TRANSITION, VSO#194815
  480. // : tuple(_Exact_args_t{}, _STD forward<_This2>(_This_arg), _STD forward<_Rest2>(_Rest_arg)...)
  481. : _Mybase(_Exact_args_t{}, _STD forward<_Rest2>(_Rest_arg)...),
  482. _Myfirst(_STD forward<_This2>(_This_arg))
  483. { // construct from one or more moved elements
  484. }
  485.  
  486. template<class _Alloc,
  487. class _This2,
  488. class... _Rest2,
  489. enable_if_t<conjunction<
  490. _Tuple_perfect_val<_Myt, _This2, _Rest2...>,
  491. _Tuple_implicit_val<_Myt, _This2, _Rest2...>
  492. >::value, int> = 0>
  493. tuple(allocator_arg_t, const _Alloc& _Al,
  494. _This2&& _This_arg, _Rest2&&... _Rest_arg)
  495. : tuple(_Alloc_exact_args_t{}, _Al, _STD forward<_This2>(_This_arg), _STD forward<_Rest2>(_Rest_arg)...)
  496. { // construct from one or more moved elements, allocator
  497. }
  498.  
  499. template<class _Alloc,
  500. class _This2,
  501. class... _Rest2,
  502. enable_if_t<conjunction<
  503. _Tuple_perfect_val<_Myt, _This2, _Rest2...>,
  504. _Tuple_explicit_val<_Myt, _This2, _Rest2...>
  505. >::value, int> = 0>
  506. explicit tuple(allocator_arg_t, const _Alloc& _Al,
  507. _This2&& _This_arg, _Rest2&&... _Rest_arg)
  508. : tuple(_Alloc_exact_args_t{}, _Al, _STD forward<_This2>(_This_arg), _STD forward<_Rest2>(_Rest_arg)...)
  509. { // construct from one or more moved elements, allocator
  510. }
  511.  
  512. template<class... _Other,
  513. _Tuple_implicit_t<_Myt, _Other...> = 0,
  514. _Tuple_convert_move_t<_Myt, _Other...> = 0>
  515. constexpr tuple(tuple<_Other...>&& _Right)
  516. // TRANSITION, VSO#194815
  517. // : tuple(_Unpack_tuple_t{}, _STD move(_Right))
  518. : _Mybase(_Unpack_tuple_t{}, (typename tuple<_Other...>::_Mybase&&) _Right),
  519. _Myfirst(_STD forward<typename tuple<_Other...>::_This_type>(_Right._Myfirst._Val))
  520. { // construct by moving same size tuple
  521. }
  522.  
  523. template<class... _Other,
  524. _Tuple_explicit_t<_Myt, _Other...> = 0,
  525. _Tuple_convert_move_t<_Myt, _Other...> = 0>
  526. constexpr explicit tuple(tuple<_Other...>&& _Right)
  527. // TRANSITION, VSO#194815
  528. // : tuple(_Unpack_tuple_t{}, _STD move(_Right))
  529. : _Mybase(_Unpack_tuple_t{}, (typename tuple<_Other...>::_Mybase&&) _Right),
  530. _Myfirst(_STD forward<typename tuple<_Other...>::_This_type>(_Right._Myfirst._Val))
  531. { // construct by moving same size tuple
  532. }
  533.  
  534. template<class _Alloc,
  535. class... _Other,
  536. _Tuple_implicit_t<_Myt, _Other...> = 0,
  537. _Tuple_convert_move_t<_Myt, _Other...> = 0>
  538. tuple(allocator_arg_t, const _Alloc& _Al,
  539. tuple<_Other...>&& _Right)
  540. : tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right))
  541. { // construct by moving same size tuple, allocator
  542. }
  543.  
  544. template<class _Alloc,
  545. class... _Other,
  546. _Tuple_explicit_t<_Myt, _Other...> = 0,
  547. _Tuple_convert_move_t<_Myt, _Other...> = 0>
  548. explicit tuple(allocator_arg_t, const _Alloc& _Al,
  549. tuple<_Other...>&& _Right)
  550. : tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right))
  551. { // construct by moving same size tuple, allocator
  552. }
  553.  
  554. template<class... _Other>
  555. _Myt& operator=(const tuple<_Other...>& _Right)
  556. { // assign by copying same size tuple
  557. _Myfirst._Val = _Right._Myfirst._Val;
  558. _Get_rest() = _Right._Get_rest();
  559. return (*this);
  560. }
  561.  
  562. template<class... _Other>
  563. _Myt& operator=(tuple<_Other...>&& _Right)
  564. { // assign by moving same size tuple
  565. _Myfirst._Val = _STD forward<typename tuple<_Other...>::_This_type>
  566. (_Right._Myfirst._Val);
  567. _Get_rest() = _STD forward<typename tuple<_Other...>::_Mybase>
  568. (_Right._Get_rest());
  569. return (*this);
  570. }
  571.  
  572. template<class... _Other>
  573. constexpr bool _Equals(const tuple<_Other...>& _Right) const
  574. { // test if *this == _Right
  575. static_assert(_Mysize == sizeof...(_Other),
  576. "comparing tuple to object with different size");
  577. return (_Myfirst._Val == _Right._Myfirst._Val
  578. && _Mybase::_Equals(_Right._Get_rest()));
  579. }
  580.  
  581. template<class... _Other>
  582. constexpr bool _Less(const tuple<_Other...>& _Right) const
  583. { // test if *this < _Right
  584. static_assert(_Mysize == sizeof...(_Other),
  585. "comparing tuple to object with different size");
  586. return (_Myfirst._Val < _Right._Myfirst._Val
  587. || (!(_Right._Myfirst._Val < _Myfirst._Val)
  588. && _Mybase::_Less(_Right._Get_rest())));
  589. }
  590.  
  591. template<class _Alloc,
  592. class _This2 = _This,
  593. class = enable_if_t<conjunction<is_default_constructible<_This2>,
  594. is_default_constructible<_Rest>...>::value> >
  595. tuple(allocator_arg_t, const _Alloc& _Al)
  596. : _Mybase(allocator_arg, _Al), _Myfirst(_Al, _Tuple_alloc)
  597. { // construct default, allocator
  598. }
  599.  
  600. template<class _Alloc>
  601. tuple(allocator_arg_t, const _Alloc& _Al,
  602. const _Myt& _Right)
  603. : tuple(_Alloc_unpack_tuple_t{}, _Al, _Right)
  604. { // construct by copying, allocator
  605. }
  606.  
  607. tuple(const _Myt&) = default;
  608. tuple(_Myt&&) = default;
  609.  
  610. template<class _First,
  611. class _Second,
  612. _Tuple_implicit_t<_Myt, const _First&, const _Second&> = 0>
  613. constexpr tuple(const pair<_First, _Second>& _Right)
  614. // TRANSITION, VSO#194815
  615. // : tuple(_Unpack_tuple_t{}, _Right)
  616. : _Mybase(_Exact_args_t{}, _Right.second), _Myfirst(_Right.first)
  617. { // construct by copying pair
  618. }
  619.  
  620. template<class _First,
  621. class _Second,
  622. _Tuple_explicit_t<_Myt, const _First&, const _Second&> = 0>
  623. constexpr explicit tuple(const pair<_First, _Second>& _Right)
  624. // TRANSITION, VSO#194815
  625. // : tuple(_Unpack_tuple_t{}, _Right)
  626. : _Mybase(_Exact_args_t{}, _Right.second), _Myfirst(_Right.first)
  627. { // construct by copying pair
  628. }
  629.  
  630. template<class _Alloc,
  631. class _First,
  632. class _Second,
  633. _Tuple_implicit_t<_Myt, const _First&, const _Second&> = 0>
  634. tuple(allocator_arg_t, const _Alloc& _Al,
  635. const pair<_First, _Second>& _Right)
  636. : tuple(_Alloc_unpack_tuple_t{}, _Al, _Right)
  637. { // construct by copying pair, allocator
  638. }
  639.  
  640. template<class _Alloc,
  641. class _First,
  642. class _Second,
  643. _Tuple_explicit_t<_Myt, const _First&, const _Second&> = 0>
  644. explicit tuple(allocator_arg_t, const _Alloc& _Al,
  645. const pair<_First, _Second>& _Right)
  646. : tuple(_Alloc_unpack_tuple_t{}, _Al, _Right)
  647. { // construct by copying pair, allocator
  648. }
  649.  
  650. _Myt& operator=(const _Myt& _Right)
  651. { // assign
  652. _Myfirst._Val = _Right._Myfirst._Val;
  653. _Get_rest() = _Right._Get_rest();
  654. return (*this);
  655. }
  656.  
  657. template<class _First,
  658. class _Second>
  659. _Myt& operator=(const pair<_First, _Second>& _Right)
  660. { // assign by copying pair
  661. static_assert(_Mysize == 2,
  662. "assigning to tuple from object with different size");
  663. _Myfirst._Val = _Right.first;
  664. _Get_rest()._Myfirst._Val = _Right.second;
  665. return (*this);
  666. }
  667.  
  668. template<class _Alloc>
  669. tuple(allocator_arg_t, const _Alloc& _Al,
  670. _Myt&& _Right)
  671. : tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right))
  672. { // construct by moving, allocator
  673. }
  674.  
  675. template<class _First,
  676. class _Second,
  677. _Tuple_implicit_t<_Myt, _First, _Second> = 0>
  678. constexpr tuple(pair<_First, _Second>&& _Right)
  679. // TRANSITION, VSO#194815
  680. // : tuple(_Unpack_tuple_t{}, _STD move(_Right))
  681. : _Mybase(_Exact_args_t{}, _STD forward<_Second>(_Right.second)),
  682. _Myfirst(_STD forward<_First>(_Right.first))
  683. { // construct by moving pair
  684. }
  685.  
  686. template<class _First,
  687. class _Second,
  688. _Tuple_explicit_t<_Myt, _First, _Second> = 0>
  689. constexpr explicit tuple(pair<_First, _Second>&& _Right)
  690. // TRANSITION, VSO#194815
  691. // : tuple(_Unpack_tuple_t{}, _STD move(_Right))
  692. : _Mybase(_Exact_args_t{}, _STD forward<_Second>(_Right.second)),
  693. _Myfirst(_STD forward<_First>(_Right.first))
  694. { // construct by moving pair
  695. }
  696.  
  697. template<class _Alloc,
  698. class _First,
  699. class _Second,
  700. _Tuple_implicit_t<_Myt, _First, _Second> = 0>
  701. tuple(allocator_arg_t, const _Alloc& _Al,
  702. pair<_First, _Second>&& _Right)
  703. : tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right))
  704. { // construct by moving pair, allocator
  705. }
  706.  
  707. template<class _Alloc,
  708. class _First,
  709. class _Second,
  710. _Tuple_explicit_t<_Myt, _First, _Second> = 0>
  711. explicit tuple(allocator_arg_t, const _Alloc& _Al,
  712. pair<_First, _Second>&& _Right)
  713. : tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right))
  714. { // construct by moving pair, allocator
  715. }
  716.  
  717. _Myt& operator=(_Myt&& _Right)
  718. _NOEXCEPT_OP(is_nothrow_move_assignable<_This>::value
  719. && is_nothrow_move_assignable<_Mybase>::value)
  720. { // assign by moving
  721. _Myfirst._Val = _STD forward<_This>(_Right._Myfirst._Val);
  722. _Get_rest() = _STD forward<_Mybase>(_Right._Get_rest());
  723. return (*this);
  724. }
  725.  
  726. template<class _First,
  727. class _Second>
  728. _Myt& operator=(pair<_First, _Second>&& _Right)
  729. { // assign by moving pair
  730. static_assert(_Mysize == 2,
  731. "assigning to tuple from object with different size");
  732. _Myfirst._Val = _STD forward<_First>(_Right.first);
  733. _Get_rest()._Myfirst._Val = _STD forward<_Second>(_Right.second);
  734. return (*this);
  735. }
  736.  
  737. _Mybase& _Get_rest() _NOEXCEPT
  738. { // get reference to rest of elements
  739. return (*this);
  740. }
  741.  
  742. constexpr const _Mybase& _Get_rest() const _NOEXCEPT
  743. { // get const reference to rest of elements
  744. return (*this);
  745. }
  746.  
  747. _Tuple_val<_This> _Myfirst; // the stored element
  748.  
  749. void swap(tuple& _Right)
  750. _NOEXCEPT_OP((conjunction<_Is_nothrow_swappable<_This>,
  751. _Is_nothrow_swappable<_Rest>...>::value))
  752. { // swap *this and _Right
  753. _Swap_adl(_Myfirst._Val, _Right._Myfirst._Val);
  754. _Mybase::swap(_Right._Get_rest());
  755. }
  756. };
  757.  
  758.  
  759. // OPERATORS FOR tuple
  760.  
  761. template<class... _Types1,
  762. class... _Types2> inline
  763. constexpr bool operator==(const tuple<_Types1...>& _Left,
  764. const tuple<_Types2...>& _Right)
  765. { // test if _Left == _Right
  766. return (_Left._Equals(_Right));
  767. }
  768.  
  769. template<class... _Types1,
  770. class... _Types2> inline
  771. constexpr bool operator!=(const tuple<_Types1...>& _Left,
  772. const tuple<_Types2...>& _Right)
  773. { // test if _Left != _Right
  774. return (!(_Left == _Right));
  775. }
  776.  
  777. template<class... _Types1,
  778. class... _Types2> inline
  779. constexpr bool operator<(const tuple<_Types1...>& _Left,
  780. const tuple<_Types2...>& _Right)
  781. { // test if _Left < _Right
  782. return (_Left._Less(_Right));
  783. }
  784.  
  785. template<class... _Types1,
  786. class... _Types2> inline
  787. constexpr bool operator>=(const tuple<_Types1...>& _Left,
  788. const tuple<_Types2...>& _Right)
  789. { // test if _Left >= _Right
  790. return (!(_Left < _Right));
  791. }
  792.  
  793. template<class... _Types1,
  794. class... _Types2> inline
  795. constexpr bool operator>(const tuple<_Types1...>& _Left,
  796. const tuple<_Types2...>& _Right)
  797. { // test if _Left > _Right
  798. return (_Right < _Left);
  799. }
  800.  
  801. template<class... _Types1,
  802. class... _Types2> inline
  803. constexpr bool operator<=(const tuple<_Types1...>& _Left,
  804. const tuple<_Types2...>& _Right)
  805. { // test if _Left <= _Right
  806. return (!(_Right < _Left));
  807. }
  808.  
  809. template<class... _Types,
  810. class = enable_if_t<conjunction<_Is_swappable<_Types>...>::value>> inline
  811. void swap(tuple<_Types...>& _Left,
  812. tuple<_Types...>& _Right)
  813. _NOEXCEPT_OP(_NOEXCEPT_OP(_Left.swap(_Right)))
  814. { // swap _Left and _Right
  815. return (_Left.swap(_Right));
  816. }
  817.  
  818.  
  819. // CLASS _Tuple_element (find element by type)
  820. template<class _Ty,
  821. class _Tuple>
  822. struct _Tuple_element;
  823.  
  824. template<class _This,
  825. class... _Rest>
  826. struct _Tuple_element<_This, tuple<_This, _Rest...> >
  827. { // select first element
  828. typedef int _Check_type;
  829. static_assert(is_void<typename _Tuple_element<_This,
  830. tuple<_Rest...> >::_Check_type>::value,
  831. "duplicate type T in get<T>(tuple)");
  832.  
  833. typedef _This type;
  834. typedef tuple<_This, _Rest...> _Ttype;
  835. };
  836.  
  837. template<class _Ty,
  838. class _This,
  839. class... _Rest>
  840. struct _Tuple_element<_Ty, tuple<_This, _Rest...> >
  841. : public _Tuple_element<_Ty, tuple<_Rest...> >
  842. { // recursive _Tuple_element definition
  843. };
  844.  
  845. template<class _Ty>
  846. struct _Tuple_element<_Ty, tuple<> >
  847. { // backstop _Tuple_element definition
  848. typedef void _Check_type; // proof that no duplicate type exists
  849. };
  850.  
  851. template<class _Ty,
  852. class _Tuple>
  853. struct _Tuple_element<_Ty, const _Tuple>
  854. : public _Tuple_element<_Ty, _Tuple>
  855. { // _Tuple_element for const
  856. typedef _Tuple_element<_Ty, _Tuple> _Mybase;
  857. typedef typename add_const<typename _Mybase::type>::type type;
  858. };
  859.  
  860. template<class _Ty,
  861. class _Tuple>
  862. struct _Tuple_element<_Ty, volatile _Tuple>
  863. : public _Tuple_element<_Ty, _Tuple>
  864. { // _Tuple_element for volatile
  865. typedef _Tuple_element<_Ty, _Tuple> _Mybase;
  866. typedef typename add_volatile<typename _Mybase::type>::type type;
  867. };
  868.  
  869. template<class _Ty,
  870. class _Tuple>
  871. struct _Tuple_element<_Ty, const volatile _Tuple>
  872. : public _Tuple_element<_Ty, _Tuple>
  873. { // _Tuple_element for const volatile
  874. typedef _Tuple_element<_Ty, _Tuple> _Mybase;
  875. typedef typename add_cv<typename _Mybase::type>::type type;
  876. };
  877.  
  878. // TEMPLATE FUNCTION get (by index)
  879. template<size_t _Index,
  880. class... _Types> inline
  881. constexpr typename tuple_element<_Index, tuple<_Types...> >::type&
  882. get(tuple<_Types...>& _Tuple) _NOEXCEPT
  883. { // get reference to _Index element of tuple
  884. typedef typename tuple_element<_Index, tuple<_Types...> >::_Ttype
  885. _Ttype;
  886. return (((_Ttype&)_Tuple)._Myfirst._Val);
  887. }
  888.  
  889. template<size_t _Index,
  890. class... _Types> inline
  891. constexpr const typename tuple_element<_Index, tuple<_Types...> >::type&
  892. get(const tuple<_Types...>& _Tuple) _NOEXCEPT
  893. { // get const reference to _Index element of tuple
  894. typedef typename tuple_element<_Index, tuple<_Types...> >::_Ttype
  895. _Ttype;
  896. return (((_Ttype&)_Tuple)._Myfirst._Val);
  897. }
  898.  
  899. template<size_t _Index,
  900. class... _Types> inline
  901. constexpr typename tuple_element<_Index, tuple<_Types...> >::type&&
  902. get(tuple<_Types...>&& _Tuple) _NOEXCEPT
  903. { // get rvalue reference to _Index element of tuple
  904. typedef typename tuple_element<_Index, tuple<_Types...> >::_Ttype
  905. _Ttype;
  906. typedef typename tuple_element<_Index, tuple<_Types...> >::type&&
  907. _RRtype;
  908. return (_STD forward<_RRtype>(((_Ttype&)_Tuple)._Myfirst._Val));
  909. }
  910.  
  911. // TEMPLATE FUNCTION get (by type)
  912. template<class _Ty,
  913. class... _Types> inline
  914. constexpr _Ty& get(tuple<_Types...>& _Tuple) _NOEXCEPT
  915. { // get reference to _Ty element of tuple
  916. typedef typename _Tuple_element<_Ty, tuple<_Types...> >::_Ttype _Ttype;
  917. return (((_Ttype&)_Tuple)._Myfirst._Val);
  918. }
  919.  
  920. template<class _Ty,
  921. class... _Types> inline
  922. constexpr const _Ty& get(const tuple<_Types...>& _Tuple) _NOEXCEPT
  923. { // get const reference to _Ty element of tuple
  924. typedef typename _Tuple_element<_Ty, tuple<_Types...> >::_Ttype _Ttype;
  925. return (((_Ttype&)_Tuple)._Myfirst._Val);
  926. }
  927.  
  928. template<class _Ty,
  929. class... _Types> inline
  930. constexpr _Ty&& get(tuple<_Types...>&& _Tuple) _NOEXCEPT
  931. { // get rvalue reference to _Ty element of tuple
  932. typedef typename _Tuple_element<_Ty, tuple<_Types...> >::_Ttype _Ttype;
  933. return (_STD forward<_Ty&&>(((_Ttype&)_Tuple)._Myfirst._Val));
  934. }
  935.  
  936. // CONSTRUCTOR TEMPLATES FOR tuple
  937. /* TRANSITION, VSO#194815
  938. template<class _This,
  939. class... _Rest>
  940. template<class _Tag,
  941. class _Tpl,
  942. size_t... _Indices,
  943. enable_if_t<is_same<_Tag, _Unpack_tuple_t>::value, int>> inline
  944. constexpr tuple<_This, _Rest...>::tuple(_Tag, _Tpl&& _Right, integer_sequence<size_t, _Indices...>)
  945. : tuple(_Exact_args_t{}, _STD get<_Indices>(_STD forward<_Tpl>(_Right))...)
  946. { // construct from unpacking a tuple/pair, using get<I>()
  947. }
  948. */
  949.  
  950. template<class _This,
  951. class... _Rest>
  952. template<class _Tag,
  953. class _Alloc,
  954. class _Tpl,
  955. size_t... _Indices,
  956. enable_if_t<is_same<_Tag, _Alloc_unpack_tuple_t>::value, int>> inline
  957. tuple<_This, _Rest...>::tuple(_Tag, const _Alloc& _Al, _Tpl&& _Right, integer_sequence<size_t, _Indices...>)
  958. : tuple(_Alloc_exact_args_t{}, _Al, _STD get<_Indices>(_STD forward<_Tpl>(_Right))...)
  959. { // construct from an allocator and unpacking a tuple/pair, using get<I>()
  960. }
  961.  
  962. // TEMPLATE FUNCTION make_tuple
  963. template<class... _Types> inline
  964. constexpr tuple<typename _Unrefwrap<_Types>::type...>
  965. make_tuple(_Types&&... _Args)
  966. { // make tuple from elements
  967. typedef tuple<typename _Unrefwrap<_Types>::type...> _Ttype;
  968. return (_Ttype(_STD forward<_Types>(_Args)...));
  969. }
  970.  
  971. // TEMPLATE FUNCTION tie
  972. template<class... _Types> inline
  973. constexpr tuple<_Types&...>
  974. tie(_Types&... _Args) _NOEXCEPT
  975. { // make tuple from elements
  976. typedef tuple<_Types&...> _Ttype;
  977. return (_Ttype(_Args...));
  978. }
  979.  
  980.  
  981. // TEMPLATE FUNCTION forward_as_tuple
  982.  
  983. template<class... _Types> inline
  984. constexpr tuple<_Types&&...>
  985. forward_as_tuple(_Types&&... _Args) _NOEXCEPT
  986. { // forward arguments in a tuple
  987. return (tuple<_Types&&...>(_STD forward<_Types>(_Args)...));
  988. }
  989.  
  990.  
  991. // TEMPLATE STRUCT _Cat_sequences
  992. template<class _Seq_type1,
  993. class _Seq_type2>
  994. struct _Cat_sequences;
  995.  
  996. template<size_t... _Indexes1,
  997. size_t... _Indexes2>
  998. struct _Cat_sequences<integer_sequence<size_t, _Indexes1...>,
  999. integer_sequence<size_t, _Indexes2...> >
  1000. { // concatenates two integer_sequence types
  1001. typedef integer_sequence<size_t, _Indexes1..., _Indexes2...> type;
  1002. };
  1003.  
  1004. // FORWARD DECLARATIONS
  1005. template<class _Ty,
  1006. size_t _Size>
  1007. class array;
  1008.  
  1009. template<size_t _Idx,
  1010. class _Ty,
  1011. size_t _Size>
  1012. constexpr _Ty& get(array<_Ty, _Size>& _Arr) _NOEXCEPT;
  1013.  
  1014. template<size_t _Idx,
  1015. class _Ty,
  1016. size_t _Size>
  1017. constexpr const _Ty& get(const array<_Ty, _Size>& _Arr) _NOEXCEPT;
  1018.  
  1019. template<size_t _Idx,
  1020. class _Ty,
  1021. size_t _Size>
  1022. constexpr _Ty&& get(array<_Ty, _Size>&& _Arr) _NOEXCEPT;
  1023.  
  1024. // TEMPLATE STRUCT _View_as_tuple
  1025. template<class _Ty,
  1026. class... _For_array>
  1027. struct _View_as_tuple
  1028. { // tuple_cat() supports only tuples, pairs, and arrays
  1029. static_assert(_Always_false<_Ty>::value,
  1030. "Unsupported tuple_cat arguments.");
  1031. };
  1032.  
  1033. template<class... _Types>
  1034. struct _View_as_tuple<tuple<_Types...> >
  1035. { // view a tuple as a tuple
  1036. typedef tuple<_Types...> type;
  1037. };
  1038.  
  1039. template<class _Ty1,
  1040. class _Ty2>
  1041. struct _View_as_tuple<pair<_Ty1, _Ty2> >
  1042. { // view a pair as a tuple
  1043. typedef tuple<_Ty1, _Ty2> type;
  1044. };
  1045.  
  1046. template<class _Ty,
  1047. class... _Types>
  1048. struct _View_as_tuple<array<_Ty, 0>, _Types...>
  1049. { // view an array as a tuple; ends recursion at 0
  1050. typedef tuple<_Types...> type;
  1051. };
  1052.  
  1053. template<class _Ty,
  1054. size_t _Size,
  1055. class... _Types>
  1056. struct _View_as_tuple<array<_Ty, _Size>, _Types...>
  1057. : _View_as_tuple<array<_Ty, _Size - 1>, _Ty, _Types...>
  1058. { // view an array as a tuple; counts down to 0
  1059. };
  1060.  
  1061. // TEMPLATE STRUCT _Repeat_for
  1062. template<size_t _Nx,
  1063. class _Ty>
  1064. struct _Repeat_for
  1065. : integral_constant<size_t, _Nx>
  1066. { // repeats _Nx for each _Ty in a parameter pack
  1067. };
  1068.  
  1069. // TEMPLATE FUNCTION tuple_cat
  1070. template<class _Ret,
  1071. class _Kx_arg,
  1072. class _Ix_arg,
  1073. size_t _Ix_next,
  1074. class... _Tuples>
  1075. struct _Tuple_cat2
  1076. { // determine tuple_cat's return type and _Kx/_Ix indices
  1077. static_assert(sizeof...(_Tuples) == 0,
  1078. "Unsupported tuple_cat arguments.");
  1079. typedef _Ret type;
  1080. typedef _Kx_arg _Kx_arg_seq;
  1081. typedef _Ix_arg _Ix_arg_seq;
  1082. };
  1083.  
  1084. template<class... _Types1,
  1085. class _Kx_arg,
  1086. size_t... _Ix,
  1087. size_t _Ix_next,
  1088. class... _Types2,
  1089. class... _Rest>
  1090. struct _Tuple_cat2<tuple<_Types1...>, _Kx_arg,
  1091. integer_sequence<size_t, _Ix...>, _Ix_next,
  1092. tuple<_Types2...>, _Rest...>
  1093. : _Tuple_cat2<
  1094. tuple<_Types1..., _Types2...>,
  1095. typename _Cat_sequences<_Kx_arg,
  1096. make_integer_sequence<size_t, sizeof...(_Types2)> >::type,
  1097. integer_sequence<size_t, _Ix...,
  1098. _Repeat_for<_Ix_next, _Types2>::value...>,
  1099. _Ix_next + 1,
  1100. _Rest...>
  1101. { // determine tuple_cat's return type and _Kx/_Ix indices
  1102. };
  1103.  
  1104. template<class... _Tuples>
  1105. struct _Tuple_cat1
  1106. : _Tuple_cat2<tuple<>, integer_sequence<size_t>,
  1107. integer_sequence<size_t>, 0,
  1108. typename _View_as_tuple<typename decay<_Tuples>::type>::type...>
  1109. { // prepare to determine tuple_cat's return type and _Kx/_Ix indices
  1110. };
  1111.  
  1112. template<class _Ret,
  1113. size_t... _Kx,
  1114. size_t... _Ix,
  1115. class _Ty> inline
  1116. constexpr _Ret _Tuple_cat(integer_sequence<size_t, _Kx...>,
  1117. integer_sequence<size_t, _Ix...>, _Ty&& _Arg)
  1118. { // concatenate tuples
  1119. return (_Ret(_STD get<_Kx>(_STD get<_Ix>(_STD forward<_Ty>(_Arg)))...));
  1120. }
  1121.  
  1122. template<class _Ret,
  1123. class _Ty> inline
  1124. constexpr _Ret _Tuple_cat(integer_sequence<size_t>,
  1125. integer_sequence<size_t>, _Ty&&)
  1126. { // TRANSITION, VSO#181496
  1127. return (_Ret());
  1128. }
  1129.  
  1130. template<class... _Tuples> inline
  1131. constexpr typename _Tuple_cat1<_Tuples...>::type
  1132. tuple_cat(_Tuples&&... _Tpls)
  1133. { // concatenate tuples
  1134. typedef _Tuple_cat1<_Tuples...> _Cat1;
  1135. return (_Tuple_cat<typename _Cat1::type>(
  1136. typename _Cat1::_Kx_arg_seq(), typename _Cat1::_Ix_arg_seq(),
  1137. _STD forward_as_tuple(_STD forward<_Tuples>(_Tpls)...)));
  1138. }
  1139.  
  1140.  
  1141. // FUNCTION TEMPLATE _For_each_tuple_element
  1142. template<class _Tpl,
  1143. class _Fx,
  1144. size_t... _Indices> inline
  1145. void _For_each_tuple_element_impl(_Tpl&& _Tuple,
  1146. _Fx _Func, integer_sequence<size_t, _Indices...>)
  1147. { // call _Func() on the _Indices elements of _Tuple
  1148. int _Ignored[] = { (static_cast<void>(_Func(
  1149. _STD get<_Indices>(_STD forward<_Tpl>(_Tuple))
  1150. )), 0)... };
  1151. (void)_Ignored;
  1152. }
  1153.  
  1154. template<class _Tpl,
  1155. class _Fx> inline
  1156. void _For_each_tuple_element(_Tpl&& _Tuple, _Fx _Func)
  1157. { // call _Func() on each element in _Tuple
  1158. _For_each_tuple_element_impl(
  1159. _STD forward<_Tpl>(_Tuple),
  1160. _Func,
  1161. make_integer_sequence<size_t,
  1162. tuple_size<remove_reference_t<_Tpl>>::value>()
  1163. );
  1164. }
  1165.  
  1166.  
  1167. // TEMPLATE CONSTRUCTOR pair::pair(tuple, tuple, sequence, sequence)
  1168. template<class _Ty1,
  1169. class _Ty2>
  1170. template<class _Tuple1,
  1171. class _Tuple2,
  1172. size_t... _Indexes1,
  1173. size_t... _Indexes2> inline
  1174. pair<_Ty1, _Ty2>::pair(_Tuple1& _Val1,
  1175. _Tuple2& _Val2,
  1176. integer_sequence<size_t, _Indexes1...>,
  1177. integer_sequence<size_t, _Indexes2...>)
  1178. : first(_STD get<_Indexes1>(_STD move(_Val1))...),
  1179. second(_STD get<_Indexes2>(_STD move(_Val2))...)
  1180. { // construct from pair of tuples
  1181. (void) _Val1; // TRANSITION, VSO#181496
  1182. (void) _Val2;
  1183. }
  1184.  
  1185. // TEMPLATE CONSTRUCTOR pair::pair(piecewise_construct_t, tuple, tuple)
  1186. template<class _Ty1,
  1187. class _Ty2>
  1188. template<class... _Types1,
  1189. class... _Types2> inline
  1190. pair<_Ty1, _Ty2>::pair(piecewise_construct_t,
  1191. tuple<_Types1...> _Val1,
  1192. tuple<_Types2...> _Val2)
  1193. : pair(_Val1, _Val2,
  1194. make_integer_sequence<size_t, sizeof...(_Types1)>(),
  1195. make_integer_sequence<size_t, sizeof...(_Types2)>())
  1196. { // construct from pair of tuples
  1197. }
  1198.  
  1199. _STD_END
  1200.  
  1201. namespace std {
  1202. // TEMPLATE STRUCT uses_allocator
  1203. template<class... _Types,
  1204. class _Alloc>
  1205. struct uses_allocator<tuple<_Types...>, _Alloc>
  1206. : true_type
  1207. { // true_type if container allocator enabled
  1208. };
  1209.  
  1210. } // namespace std
  1211.  
  1212. #if _HAS_TR1_NAMESPACE
  1213. _STD_BEGIN
  1214. namespace tr1 { // TR1 ADDITIONS
  1215. using _STD get;
  1216. using _STD ignore;
  1217. using _STD make_tuple;
  1218. using _STD ref;
  1219. using _STD tie;
  1220. using _STD tuple;
  1221. } // namespace tr1
  1222. _STD_END
  1223. #endif /* _HAS_TR1_NAMESPACE */
  1224.  
  1225. #pragma pop_macro("new")
  1226. #pragma warning(pop)
  1227. #pragma pack(pop)
  1228. #endif /* RC_INVOKED */
  1229. #endif /* _TUPLE_ */
  1230.  
  1231. /*
  1232. * Copyright (c) by P.J. Plauger. All rights reserved.
  1233. * Consult your license regarding permissions and restrictions.
  1234. V6.50:0009 */
Add Comment
Please, Sign In to add comment