Changeset 207517 in webkit
- Timestamp:
- Oct 18, 2016 7:43:44 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r207500 r207517 1 2016-10-18 Sam Weinig <sam@webkit.org> 2 3 Replace std::experimental::variant with WTF::Variant (or similar) 4 https://bugs.webkit.org/show_bug.cgi?id=163626 5 6 Reviewed by Chris Dumez. 7 8 Rename std::experimental::variant, Variant. Move helpers get/holds_alternative/etc. 9 into the WTF namespace. 10 11 * domjit/DOMJITReg.h: 12 (JSC::DOMJIT::Reg::gpr): 13 (JSC::DOMJIT::Reg::fpr): 14 (JSC::DOMJIT::Reg::jsValueRegs): 15 1 16 2016-10-18 Keith Miller <keith_miller@apple.com> 2 17 -
trunk/Source/JavaScriptCore/domjit/DOMJITReg.h
r206846 r207517 72 72 { 73 73 ASSERT(isGPR()); 74 return std::experimental::get<GPRReg>(m_variant);74 return WTF::get<GPRReg>(m_variant); 75 75 } 76 76 FPRReg fpr() const 77 77 { 78 78 ASSERT(isFPR()); 79 return std::experimental::get<FPRReg>(m_variant);79 return WTF::get<FPRReg>(m_variant); 80 80 } 81 81 JSValueRegs jsValueRegs() const 82 82 { 83 83 ASSERT(isJSValueRegs()); 84 return std::experimental::get<JSValueRegs>(m_variant);84 return WTF::get<JSValueRegs>(m_variant); 85 85 } 86 86 87 87 private: 88 std::experimental::variant<GPRReg, FPRReg, JSValueRegs> m_variant;88 Variant<GPRReg, FPRReg, JSValueRegs> m_variant; 89 89 }; 90 90 -
trunk/Source/WTF/ChangeLog
r207480 r207517 1 2016-10-18 Sam Weinig <sam@webkit.org> 2 3 Replace std::experimental::variant with WTF::Variant (or similar) 4 https://bugs.webkit.org/show_bug.cgi?id=163626 5 6 Reviewed by Chris Dumez. 7 8 Rename std::experimental::variant, Variant. Move helpers get/holds_alternative/etc. 9 into the WTF namespace. 10 11 * wtf/Forward.h: 12 * wtf/Variant.h: 13 1 14 2016-10-18 Filip Pizlo <fpizlo@apple.com> 2 15 -
trunk/Source/WTF/wtf/Forward.h
r204977 r207517 35 35 template<typename T> class StringBuffer; 36 36 37 template<typename... T> class Variant; 37 38 template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity> class Vector; 38 39 … … 49 50 class StringView; 50 51 class TextPosition; 51 52 }53 54 namespace std {55 namespace experimental {56 57 template<typename... T> class variant;58 59 }60 61 template<typename... Types>62 using variant = std::experimental::variant<Types...>;63 52 64 53 } … … 85 74 using WTF::StringView; 86 75 using WTF::TextPosition; 76 using WTF::Variant; 87 77 using WTF::Vector; -
trunk/Source/WTF/wtf/Variant.h
r207381 r207517 60 60 #if !COMPILER(CLANG) || WTF_CPP_STD_VER >= 14 61 61 62 namespace std { 63 namespace experimental { 62 namespace WTF { 64 63 65 64 #if COMPILER_SUPPORTS(EXCEPTIONS) … … 166 165 167 166 template<typename ... _Types> 168 class variant;167 class Variant; 169 168 170 169 template<typename> … … 181 180 182 181 template <typename... _Types> 183 struct variant_size< variant<_Types...>>182 struct variant_size<Variant<_Types...>> 184 183 : std::integral_constant<size_t, sizeof...(_Types)> {}; 185 184 … … 206 205 207 206 template<size_t _Index,typename ... _Types> 208 struct variant_alternative<_Index, variant<_Types...>>{207 struct variant_alternative<_Index,Variant<_Types...>>{ 209 208 using type=typename __indexed_type<_Index,_Types...>::__type; 210 209 }; … … 213 212 214 213 template<typename _Type,typename ... _Types> 215 constexpr _Type& get( variant<_Types...>&);214 constexpr _Type& get(Variant<_Types...>&); 216 215 217 216 template<typename _Type,typename ... _Types> 218 constexpr _Type const& get( variant<_Types...> const&);217 constexpr _Type const& get(Variant<_Types...> const&); 219 218 220 219 template<typename _Type,typename ... _Types> 221 constexpr _Type&& get( variant<_Types...>&&);220 constexpr _Type&& get(Variant<_Types...>&&); 222 221 223 222 template<typename _Type,typename ... _Types> 224 constexpr const _Type&& get( variant<_Types...> const&&);223 constexpr const _Type&& get(Variant<_Types...> const&&); 225 224 226 225 template<ptrdiff_t _Index,typename ... _Types> 227 constexpr typename __indexed_type<_Index,_Types...>::__type& get( variant<_Types...>&);226 constexpr typename __indexed_type<_Index,_Types...>::__type& get(Variant<_Types...>&); 228 227 229 228 template<ptrdiff_t _Index,typename ... _Types> 230 constexpr typename __indexed_type<_Index,_Types...>::__type&& get( variant<_Types...>&&);229 constexpr typename __indexed_type<_Index,_Types...>::__type&& get(Variant<_Types...>&&); 231 230 232 231 template<ptrdiff_t _Index,typename ... _Types> 233 232 constexpr typename __indexed_type<_Index,_Types...>::__type const& get( 234 variant<_Types...> const&);233 Variant<_Types...> const&); 235 234 236 235 template <ptrdiff_t _Index, typename... _Types> 237 236 constexpr const typename __indexed_type<_Index, _Types...>::__type && 238 get( variant<_Types...> const &&);237 get(Variant<_Types...> const &&); 239 238 240 239 template<typename _Type,typename ... _Types> 241 constexpr std::add_pointer_t<_Type> get_if( variant<_Types...>&);240 constexpr std::add_pointer_t<_Type> get_if(Variant<_Types...>&); 242 241 243 242 template<typename _Type,typename ... _Types> 244 constexpr std::add_pointer_t<_Type const> get_if( variant<_Types...> const&);243 constexpr std::add_pointer_t<_Type const> get_if(Variant<_Types...> const&); 245 244 246 245 template<ptrdiff_t _Index,typename ... _Types> 247 constexpr std::add_pointer_t<typename __indexed_type<_Index,_Types...>::__type> get_if( variant<_Types...>&);246 constexpr std::add_pointer_t<typename __indexed_type<_Index,_Types...>::__type> get_if(Variant<_Types...>&); 248 247 249 248 template<ptrdiff_t _Index,typename ... _Types> 250 249 constexpr std::add_pointer_t<typename __indexed_type<_Index,_Types...>::__type const> get_if( 251 variant<_Types...> const&);250 Variant<_Types...> const&); 252 251 253 252 template<ptrdiff_t _Index,typename ... _Types> … … 380 379 381 380 template<typename ... _Types> 382 struct __any_backup_storage_required< variant<_Types...> >{381 struct __any_backup_storage_required<Variant<_Types...> >{ 383 382 static const bool __value= 384 383 __any_backup_storage_required_impl<0,sizeof...(_Types),_Types...>::__value; … … 705 704 706 705 template<typename ... _Types> 707 struct __variant_indices< variant<_Types...>>{706 struct __variant_indices<Variant<_Types...>>{ 708 707 typedef typename __type_indices<_Types...>::__type __type; 709 708 }; … … 1437 1436 1438 1437 template<typename ... _Types> 1439 class variant:1438 class Variant: 1440 1439 private __variant_base< 1441 variant<_Types...>,__all_trivially_destructible<_Types...>::__value>1440 Variant<_Types...>,__all_trivially_destructible<_Types...>::__value> 1442 1441 { 1443 typedef __variant_base< variant<_Types...>,__all_trivially_destructible<_Types...>::__value> __base_type;1442 typedef __variant_base<Variant<_Types...>,__all_trivially_destructible<_Types...>::__value> __base_type; 1444 1443 friend __base_type; 1445 friend struct __copy_construct_op_table< variant>;1446 friend struct __copy_assign_op_table< variant>;1447 friend struct __move_construct_op_table< variant>;1448 friend struct __move_assign_op_table< variant>;1449 friend struct __destroy_op_table< variant>;1444 friend struct __copy_construct_op_table<Variant>; 1445 friend struct __copy_assign_op_table<Variant>; 1446 friend struct __move_construct_op_table<Variant>; 1447 friend struct __move_assign_op_table<Variant>; 1448 friend struct __destroy_op_table<Variant>; 1450 1449 1451 1450 template<ptrdiff_t _Index,typename ... _Types2> … … 1468 1467 if(valueless_by_exception()) 1469 1468 return; 1470 __destroy_op_table< variant>::__apply[index()](this);1469 __destroy_op_table<Variant>::__apply[index()](this); 1471 1470 __index=-1; 1472 1471 } 1473 1472 1474 ptrdiff_t __move_construct( variant& __other){1473 ptrdiff_t __move_construct(Variant& __other){ 1475 1474 ptrdiff_t const __other_index=__other.index(); 1476 1475 if(__other_index==-1) 1477 1476 return -1; 1478 __move_construct_op_table< variant>::__apply[__other_index](this,__other);1477 __move_construct_op_table<Variant>::__apply[__other_index](this,__other); 1479 1478 __other.__destroy_self(); 1480 1479 return __other_index; 1481 1480 } 1482 1481 1483 ptrdiff_t __copy_construct( variant const& __other){1482 ptrdiff_t __copy_construct(Variant const& __other){ 1484 1483 ptrdiff_t const __other_index=__other.index(); 1485 1484 if(__other_index==-1) 1486 1485 return -1; 1487 __copy_construct_op_table< variant>::__apply[__other_index](this,__other);1486 __copy_construct_op_table<Variant>::__apply[__other_index](this,__other); 1488 1487 return __other_index; 1489 1488 } … … 1532 1531 1533 1532 public: 1534 constexpr variant()1533 constexpr Variant() 1535 1534 __NOEXCEPT_(noexcept(typename __indexed_type<0,_Types...>::__type())): 1536 1535 __storage(in_place<0>), … … 1538 1537 {} 1539 1538 1540 constexpr variant(typename std::conditional<__all_move_constructible<_Types...>::value,variant,__private_type>::type&& __other)1539 constexpr Variant(typename std::conditional<__all_move_constructible<_Types...>::value,Variant,__private_type>::type&& __other) 1541 1540 __NOEXCEPT_(__noexcept_variant_move_construct<_Types...>::value): 1542 1541 __index(__move_construct(__other)) 1543 1542 {} 1544 1543 1545 constexpr variant(typename std::conditional<!__all_move_constructible<_Types...>::value,variant,__private_type>::type&& __other)=delete;1546 1547 constexpr variant(typename std::conditional<__all_copy_constructible<_Types...>::value,variant,__private_type>::type& __other)1544 constexpr Variant(typename std::conditional<!__all_move_constructible<_Types...>::value,Variant,__private_type>::type&& __other)=delete; 1545 1546 constexpr Variant(typename std::conditional<__all_copy_constructible<_Types...>::value,Variant,__private_type>::type& __other) 1548 1547 __NOEXCEPT_(__noexcept_variant_non_const_copy_construct<_Types...>::value): 1549 1548 __index(__copy_construct(__other)) 1550 1549 {} 1551 1550 1552 constexpr variant(typename std::conditional<!__all_copy_constructible<_Types...>::value,variant,__private_type>::type& __other)=delete;1553 1554 constexpr variant(typename std::conditional<__all_copy_constructible<_Types...>::value,variant,__private_type>::type const& __other)1551 constexpr Variant(typename std::conditional<!__all_copy_constructible<_Types...>::value,Variant,__private_type>::type& __other)=delete; 1552 1553 constexpr Variant(typename std::conditional<__all_copy_constructible<_Types...>::value,Variant,__private_type>::type const& __other) 1555 1554 __NOEXCEPT_(__noexcept_variant_const_copy_construct<_Types...>::value): 1556 1555 __index(__copy_construct(__other)) 1557 1556 {} 1558 1557 1559 constexpr variant(typename std::conditional<!__all_copy_constructible<_Types...>::value,variant,__private_type>::type const& __other)=delete;1558 constexpr Variant(typename std::conditional<!__all_copy_constructible<_Types...>::value,Variant,__private_type>::type const& __other)=delete; 1560 1559 1561 1560 template<typename _Type,typename ... _Args> 1562 explicit constexpr variant(in_place_type_t<_Type>,_Args&& ... __args):1561 explicit constexpr Variant(in_place_type_t<_Type>,_Args&& ... __args): 1563 1562 __storage( 1564 1563 in_place<__type_index<_Type,_Types...>::__value>, … … 1570 1569 1571 1570 template<size_t _Index,typename ... _Args> 1572 explicit constexpr variant(in_place_index_t<_Index>,_Args&& ... __args):1571 explicit constexpr Variant(in_place_index_t<_Index>,_Args&& ... __args): 1573 1572 __storage(in_place<_Index>,std::forward<_Args>(__args)...), 1574 1573 __index(_Index) … … 1578 1577 1579 1578 template<typename _Type> 1580 constexpr variant(_Type&& __x):1579 constexpr Variant(_Type&& __x): 1581 1580 __storage( 1582 1581 in_place< … … 1591 1590 (__constructible_matches<std::initializer_list<_Type>,_Types...>::__type::__length>0) 1592 1591 >::type> 1593 constexpr variant(std::initializer_list<_Type> __x):1592 constexpr Variant(std::initializer_list<_Type> __x): 1594 1593 __storage( 1595 1594 in_place< … … 1600 1599 1601 1600 template<typename _Type> 1602 variant& operator=(_Type&& __x){1601 Variant& operator=(_Type&& __x){ 1603 1602 constexpr size_t _Index= 1604 1603 __type_index_to_construct<_Type,_Types...>::__value; … … 1612 1611 } 1613 1612 1614 variant &operator=(1613 Variant &operator=( 1615 1614 typename std::conditional< 1616 1615 !(__all_copy_constructible<_Types...>::value && 1617 1616 __all_move_constructible<_Types...>::value && 1618 1617 __all_copy_assignable<_Types...>::value), 1619 variant, __private_type>::type const &__other) = delete;1620 1621 variant &operator=(1618 Variant, __private_type>::type const &__other) = delete; 1619 1620 Variant &operator=( 1622 1621 typename std::conditional< 1623 1622 __all_copy_constructible<_Types...>::value && 1624 1623 __all_move_constructible<_Types...>::value && 1625 1624 __all_copy_assignable<_Types...>::value, 1626 variant, __private_type>::type const &__other) {1625 Variant, __private_type>::type const &__other) { 1627 1626 if (__other.valueless_by_exception()) { 1628 1627 __destroy_self(); 1629 1628 } 1630 1629 else if(__other.index()==index()){ 1631 __copy_assign_op_table< variant>::__apply[index()](this,__other);1630 __copy_assign_op_table<Variant>::__apply[index()](this,__other); 1632 1631 } 1633 1632 else{ 1634 __replace_construct_helper::__op_table< variant>::__copy_assign[1633 __replace_construct_helper::__op_table<Variant>::__copy_assign[ 1635 1634 __other.index()](this,__other); 1636 1635 } 1637 1636 return *this; 1638 1637 } 1639 variant &operator=(1638 Variant &operator=( 1640 1639 typename std::conditional< 1641 1640 !(__all_copy_constructible<_Types...>::value && 1642 1641 __all_move_constructible<_Types...>::value && 1643 1642 __all_copy_assignable<_Types...>::value), 1644 variant, __private_type>::type &__other) = delete;1645 1646 variant &operator=(1643 Variant, __private_type>::type &__other) = delete; 1644 1645 Variant &operator=( 1647 1646 typename std::conditional< 1648 1647 __all_copy_constructible<_Types...>::value && 1649 1648 __all_move_constructible<_Types...>::value && 1650 1649 __all_copy_assignable<_Types...>::value, 1651 variant, __private_type>::type &__other) {1650 Variant, __private_type>::type &__other) { 1652 1651 if(__other.valueless_by_exception()){ 1653 1652 __destroy_self(); 1654 1653 } 1655 1654 else if(__other.index()==index()){ 1656 __copy_assign_op_table< variant>::__apply[index()](this,__other);1655 __copy_assign_op_table<Variant>::__apply[index()](this,__other); 1657 1656 } 1658 1657 else{ 1659 __replace_construct_helper::__op_table< variant>::__copy_assign[1658 __replace_construct_helper::__op_table<Variant>::__copy_assign[ 1660 1659 __other.index()](this,__other); 1661 1660 } 1662 1661 return *this; 1663 1662 } 1664 variant &operator=(1663 Variant &operator=( 1665 1664 typename std::conditional< 1666 1665 !(__all_move_constructible<_Types...>::value && 1667 1666 __all_move_assignable<_Types...>::value), 1668 variant, __private_type>::type &&__other) = delete;1669 1670 variant &operator=(1667 Variant, __private_type>::type &&__other) = delete; 1668 1669 Variant &operator=( 1671 1670 typename std::conditional<__all_move_constructible<_Types...>::value && 1672 1671 __all_move_assignable<_Types...>::value, 1673 variant, __private_type>::type &&1672 Variant, __private_type>::type && 1674 1673 __other) __NOEXCEPT_(__noexcept_variant_move_assign<_Types...>::value) { 1675 1674 if (__other.valueless_by_exception()) { … … 1677 1676 } 1678 1677 else if(__other.index()==index()){ 1679 __move_assign_op_table< variant>::__apply[index()](this,__other);1678 __move_assign_op_table<Variant>::__apply[index()](this,__other); 1680 1679 __other.__destroy_self(); 1681 1680 } 1682 1681 else{ 1683 __replace_construct_helper::__op_table< variant>::__move_assign[1682 __replace_construct_helper::__op_table<Variant>::__move_assign[ 1684 1683 __other.index()](this,__other); 1685 1684 } … … 1709 1708 __all_swappable<_Types...>::value && 1710 1709 __all_move_constructible<_Types...>::value, 1711 variant, __private_type>::type1710 Variant, __private_type>::type 1712 1711 &__other) __NOEXCEPT_(__noexcept_variant_swap<_Types...>::value) { 1713 1712 if (__other.index() == index()) { 1714 1713 if(!valueless_by_exception()) 1715 __swap_op_table< variant>::__apply[index()](*this,__other);1714 __swap_op_table<Variant>::__apply[index()](*this,__other); 1716 1715 } 1717 1716 else{ 1718 variant __temp(std::move(__other));1717 Variant __temp(std::move(__other)); 1719 1718 __other.__index=__other.__move_construct(*this); 1720 1719 __index=__move_construct(__temp); … … 1724 1723 1725 1724 template<> 1726 class variant<>{1725 class Variant<>{ 1727 1726 public: 1728 variant()=delete;1727 Variant()=delete; 1729 1728 1730 1729 constexpr bool valueless_by_exception() const __NOEXCEPT{ … … 1735 1734 } 1736 1735 1737 void swap( variant&){}1736 void swap(Variant&){} 1738 1737 }; 1739 1738 … … 1742 1741 __all_move_constructible<_Types...>::value, 1743 1742 void>::type 1744 swap( variant<_Types...> &__lhs, variant<_Types...> &__rhs) __NOEXCEPT_(1743 swap(Variant<_Types...> &__lhs, Variant<_Types...> &__rhs) __NOEXCEPT_( 1745 1744 __noexcept_variant_swap<_Types...>::value) { 1746 1745 __lhs.swap(__rhs); … … 1750 1749 struct __variant_accessor{ 1751 1750 typedef typename __indexed_type<_Index,_Types...>::__type __type; 1752 static constexpr __type& get( variant<_Types...>& __v){1751 static constexpr __type& get(Variant<_Types...>& __v){ 1753 1752 return __v.__storage.__get(in_place<_Index>); 1754 1753 } 1755 static constexpr __type const& get( variant<_Types...> const& __v){1754 static constexpr __type const& get(Variant<_Types...> const& __v){ 1756 1755 return __v.__storage.__get(in_place<_Index>); 1757 1756 } 1758 static constexpr __type&& get( variant<_Types...>&& __v){1757 static constexpr __type&& get(Variant<_Types...>&& __v){ 1759 1758 return __v.__storage.__get_rref(in_place<_Index>); 1760 1759 } 1761 static constexpr const __type&& get( variant<_Types...> const&& __v){1760 static constexpr const __type&& get(Variant<_Types...> const&& __v){ 1762 1761 return __v.__storage.__get_rref(in_place<_Index>); 1763 1762 } … … 1765 1764 1766 1765 template<typename _Type,typename ... _Types> 1767 constexpr _Type& get( variant<_Types...>& __v){1766 constexpr _Type& get(Variant<_Types...>& __v){ 1768 1767 return get<__type_index<_Type,_Types...>::__value>(__v); 1769 1768 } 1770 1769 1771 1770 template<typename _Type,typename ... _Types> 1772 constexpr _Type&& get( variant<_Types...>&& __v){1771 constexpr _Type&& get(Variant<_Types...>&& __v){ 1773 1772 return get<__type_index<_Type,_Types...>::__value>(std::move(__v)); 1774 1773 } 1775 1774 1776 1775 template<typename _Type,typename ... _Types> 1777 constexpr _Type const& get( variant<_Types...> const& __v){1776 constexpr _Type const& get(Variant<_Types...> const& __v){ 1778 1777 return get<__type_index<_Type,_Types...>::__value>(__v); 1779 1778 } 1780 1779 1781 1780 template<typename _Type,typename ... _Types> 1782 constexpr const _Type&& get( variant<_Types...> const&& __v){1781 constexpr const _Type&& get(Variant<_Types...> const&& __v){ 1783 1782 return get<__type_index<_Type,_Types...>::__value>(std::move(__v)); 1784 1783 } … … 1786 1785 1787 1786 template<ptrdiff_t _Index,typename ... _Types> 1788 constexpr typename __indexed_type<_Index,_Types...>::__type const& get( variant<_Types...> const& __v){1787 constexpr typename __indexed_type<_Index,_Types...>::__type const& get(Variant<_Types...> const& __v){ 1789 1788 return *( 1790 1789 (_Index!=__v.index()) 1791 ? &__throw_bad_variant_access<typename __indexed_type<_Index,_Types...>::__type const&>("Bad variant index in get")1790 ? &__throw_bad_variant_access<typename __indexed_type<_Index,_Types...>::__type const&>("Bad Variant index in get") 1792 1791 : &__variant_accessor<_Index,_Types...>::get(__v) 1793 1792 ); … … 1795 1794 1796 1795 template<ptrdiff_t _Index,typename ... _Types> 1797 constexpr typename __indexed_type<_Index,_Types...>::__type& get( variant<_Types...>& __v){1796 constexpr typename __indexed_type<_Index,_Types...>::__type& get(Variant<_Types...>& __v){ 1798 1797 return *( 1799 1798 (_Index!=__v.index()) 1800 ? &__throw_bad_variant_access<typename __indexed_type<_Index,_Types...>::__type&>("Bad variant index in get")1799 ? &__throw_bad_variant_access<typename __indexed_type<_Index,_Types...>::__type&>("Bad Variant index in get") 1801 1800 : &__variant_accessor<_Index,_Types...>::get(__v) 1802 1801 ); … … 1804 1803 1805 1804 template<ptrdiff_t _Index,typename ... _Types> 1806 constexpr typename __indexed_type<_Index,_Types...>::__type&& get( variant<_Types...>&& __v){1805 constexpr typename __indexed_type<_Index,_Types...>::__type&& get(Variant<_Types...>&& __v){ 1807 1806 return __variant_accessor<_Index,_Types...>::get( 1808 (((_Index!=__v.index()) ? __throw_bad_variant_access<int>("Bad variant index in get") : 0), std::move(__v))1807 (((_Index!=__v.index()) ? __throw_bad_variant_access<int>("Bad Variant index in get") : 0), std::move(__v)) 1809 1808 ); 1810 1809 } 1811 1810 1812 1811 template<ptrdiff_t _Index,typename ... _Types> 1813 constexpr const typename __indexed_type<_Index,_Types...>::__type&& get( variant<_Types...> const&& __v){1812 constexpr const typename __indexed_type<_Index,_Types...>::__type&& get(Variant<_Types...> const&& __v){ 1814 1813 return __variant_accessor<_Index,_Types...>::get( 1815 (((_Index!=__v.index()) ? __throw_bad_variant_access<int>("Bad variant index in get") : 0), std::move(__v))1814 (((_Index!=__v.index()) ? __throw_bad_variant_access<int>("Bad Variant index in get") : 0), std::move(__v)) 1816 1815 ); 1817 1816 } 1818 1817 1819 1818 template<typename _Type,typename ... _Types> 1820 constexpr std::add_pointer_t<_Type> get_if( variant<_Types...>& __v){1819 constexpr std::add_pointer_t<_Type> get_if(Variant<_Types...>& __v){ 1821 1820 return (__type_index<_Type,_Types...>::__value!=__v.index())?nullptr:&get<_Type>(__v); 1822 1821 } 1823 1822 1824 1823 template<typename _Type,typename ... _Types> 1825 constexpr std::add_pointer_t<_Type const> get_if( variant<_Types...> const& __v){1824 constexpr std::add_pointer_t<_Type const> get_if(Variant<_Types...> const& __v){ 1826 1825 return (__type_index<_Type,_Types...>::__value!=__v.index())?nullptr:&get<_Type>(__v); 1827 1826 } 1828 1827 1829 1828 template<ptrdiff_t _Index,typename ... _Types> 1830 constexpr std::add_pointer_t<typename __indexed_type<_Index,_Types...>::__type> get_if( variant<_Types...>& __v){1829 constexpr std::add_pointer_t<typename __indexed_type<_Index,_Types...>::__type> get_if(Variant<_Types...>& __v){ 1831 1830 return ((_Index!=__v.index())?nullptr: 1832 1831 &__variant_accessor<_Index,_Types...>::get(__v)); … … 1835 1834 template<ptrdiff_t _Index,typename ... _Types> 1836 1835 constexpr std::add_pointer_t<typename __indexed_type<_Index,_Types...>::__type const> get_if( 1837 variant<_Types...> const& __v){1836 Variant<_Types...> const& __v){ 1838 1837 return ((_Index!=__v.index())?nullptr: 1839 1838 &__variant_accessor<_Index,_Types...>::get(__v)); … … 1841 1840 1842 1841 template<typename _Type,typename ... _Types> 1843 constexpr bool holds_alternative( variant<_Types...> const& __v) __NOEXCEPT{1842 constexpr bool holds_alternative(Variant<_Types...> const& __v) __NOEXCEPT{ 1844 1843 return __v.index()==__type_index<_Type,_Types...>::__value; 1845 1844 } … … 1860 1859 template<typename _Visitor,typename ... _Types> 1861 1860 struct __visitor_table{ 1862 typedef variant<_Types...> __variant_type;1861 typedef Variant<_Types...> __variant_type; 1863 1862 typedef typename __visitor_return_type<_Visitor,_Types...>::__type __return_type; 1864 1863 typedef __return_type (*__func_type)(_Visitor&,__variant_type&); … … 1879 1878 template<typename _Visitor,typename ... _Types> 1880 1879 constexpr typename __visitor_return_type<_Visitor,_Types...>::__type 1881 visit(_Visitor&& __visitor, variant<_Types...>& __v){1880 visit(_Visitor&& __visitor,Variant<_Types...>& __v){ 1882 1881 return (__v.valueless_by_exception()) 1883 ? __throw_bad_variant_access<typename __visitor_return_type<_Visitor,_Types...>::__type>("Visiting of empty variant")1882 ? __throw_bad_variant_access<typename __visitor_return_type<_Visitor,_Types...>::__type>("Visiting of empty Variant") 1884 1883 : __visitor_table<_Visitor,_Types...>::__trampoline[__v.index()](__visitor,__v); 1885 1884 } … … 1945 1944 static constexpr typename __multi_visitor_return_type<_Visitor,_Variants...>::__type 1946 1945 __visit(_Visitor&,_Variants&& ...){ 1947 return __throw_bad_variant_access<typename __multi_visitor_return_type<_Visitor,_Variants...>::__type>("Visiting of empty variant");1946 return __throw_bad_variant_access<typename __multi_visitor_return_type<_Visitor,_Variants...>::__type>("Visiting of empty Variant"); 1948 1947 } 1949 1948 }; … … 1953 1952 1954 1953 template<typename ... _Types> 1955 struct __variant_type_count< variant<_Types...>>{1954 struct __variant_type_count<Variant<_Types...>>{ 1956 1955 static constexpr size_t __value=sizeof...(_Types); 1957 1956 }; … … 1990 1989 1991 1990 template<typename ... _Types> 1992 constexpr bool operator==( variant<_Types...> const& __lhs,variant<_Types...> const& __rhs){1991 constexpr bool operator==(Variant<_Types...> const& __lhs,Variant<_Types...> const& __rhs){ 1993 1992 return (__lhs.index()==__rhs.index()) && 1994 1993 ((__lhs.index()==-1) || 1995 __equality_op_table< variant<_Types...>>::__equality_compare[__lhs.index()](1994 __equality_op_table<Variant<_Types...>>::__equality_compare[__lhs.index()]( 1996 1995 __lhs,__rhs)); 1997 1996 } 1998 1997 1999 1998 template<typename ... _Types> 2000 constexpr bool operator!=( variant<_Types...> const& __lhs,variant<_Types...> const& __rhs){1999 constexpr bool operator!=(Variant<_Types...> const& __lhs,Variant<_Types...> const& __rhs){ 2001 2000 return !(__lhs==__rhs); 2002 2001 } 2003 2002 2004 2003 template<typename ... _Types> 2005 constexpr bool operator<( variant<_Types...> const& __lhs,variant<_Types...> const& __rhs){2004 constexpr bool operator<(Variant<_Types...> const& __lhs,Variant<_Types...> const& __rhs){ 2006 2005 return (__lhs.index()<__rhs.index()) || 2007 2006 ((__lhs.index()==__rhs.index()) && 2008 2007 ((__lhs.index()!=-1) && 2009 __less_than_op_table< variant<_Types...>>::2008 __less_than_op_table<Variant<_Types...>>:: 2010 2009 __less_than_compare[__lhs.index()](__lhs,__rhs))); 2011 2010 } 2012 2011 2013 2012 template<typename ... _Types> 2014 constexpr bool operator>( variant<_Types...> const& __lhs,variant<_Types...> const& __rhs){2013 constexpr bool operator>(Variant<_Types...> const& __lhs,Variant<_Types...> const& __rhs){ 2015 2014 return __rhs<__lhs; 2016 2015 } 2017 2016 2018 2017 template<typename ... _Types> 2019 constexpr bool operator>=( variant<_Types...> const& __lhs,variant<_Types...> const& __rhs){2018 constexpr bool operator>=(Variant<_Types...> const& __lhs,Variant<_Types...> const& __rhs){ 2020 2019 return !(__lhs<__rhs); 2021 2020 } 2022 2021 2023 2022 template<typename ... _Types> 2024 constexpr bool operator<=( variant<_Types...> const& __lhs,variant<_Types...> const& __rhs){2023 constexpr bool operator<=(Variant<_Types...> const& __lhs,Variant<_Types...> const& __rhs){ 2025 2024 return !(__lhs>__rhs); 2026 2025 } 2027 2026 2028 struct monostate{};2029 2030 constexpr inline bool operator==( monostate const&,monostate const&){ return true;}2031 constexpr inline bool operator!=( monostate const&,monostate const&){ return false;}2032 constexpr inline bool operator>=( monostate const&,monostate const&){ return true;}2033 constexpr inline bool operator<=( monostate const&,monostate const&){ return true;}2034 constexpr inline bool operator>( monostate const&,monostate const&){ return false;}2035 constexpr inline bool operator<( monostate const&,monostate const&){ return false;}2027 struct Monostate{}; 2028 2029 constexpr inline bool operator==(Monostate const&,Monostate const&){ return true;} 2030 constexpr inline bool operator!=(Monostate const&,Monostate const&){ return false;} 2031 constexpr inline bool operator>=(Monostate const&,Monostate const&){ return true;} 2032 constexpr inline bool operator<=(Monostate const&,Monostate const&){ return true;} 2033 constexpr inline bool operator>(Monostate const&,Monostate const&){ return false;} 2034 constexpr inline bool operator<(Monostate const&,Monostate const&){ return false;} 2036 2035 2037 2036 struct __hash_visitor{ … … 2042 2041 }; 2043 2042 2044 } // namespace experimental 2043 } // namespace WTF 2044 2045 namespace std { 2045 2046 2046 2047 template<> 2047 struct hash< experimental::monostate>{2048 size_t operator()( experimental::monostate) __NOEXCEPT{2048 struct hash<WTF::Monostate>{ 2049 size_t operator()(WTF::Monostate) __NOEXCEPT{ 2049 2050 return 42; 2050 2051 } … … 2052 2053 2053 2054 template<typename ... _Types> 2054 struct hash<experimental::variant<_Types...>>{ 2055 size_t operator()(experimental::variant<_Types...> const &v) __NOEXCEPT { 2056 return std::hash<ptrdiff_t>()(v.index()) ^ 2057 experimental::visit(experimental::__hash_visitor(), v); 2055 struct hash<WTF::Variant<_Types...>>{ 2056 size_t operator()(WTF::Variant<_Types...> const &v) __NOEXCEPT { 2057 return std::hash<ptrdiff_t>()(v.index()) ^ WTF::visit(WTF::__hash_visitor(), v); 2058 2058 } 2059 2059 }; 2060 2060 2061 2061 } // namespace std 2062 2063 using WTF::Monostate; 2064 using WTF::Variant; 2062 2065 2063 2066 #endif // !COMPILER(CLANG) || WTF_CPP_STD_VER >= 14 -
trunk/Source/WebCore/ChangeLog
r207516 r207517 1 2016-10-18 Sam Weinig <sam@webkit.org> 2 3 Replace std::experimental::variant with WTF::Variant (or similar) 4 https://bugs.webkit.org/show_bug.cgi?id=163626 5 6 Reviewed by Chris Dumez. 7 8 Rename std::experimental::variant, Variant. Move helpers get/holds_alternative/etc. 9 into the WTF namespace. 10 11 * Modules/fetch/FetchBody.h: 12 (WebCore::FetchBody::isBlob): 13 (WebCore::FetchBody::isFormData): 14 (WebCore::FetchBody::isArrayBuffer): 15 (WebCore::FetchBody::isArrayBufferView): 16 (WebCore::FetchBody::isURLSearchParams): 17 (WebCore::FetchBody::isText): 18 (WebCore::FetchBody::blobBody): 19 (WebCore::FetchBody::formDataBody): 20 (WebCore::FetchBody::arrayBufferBody): 21 (WebCore::FetchBody::arrayBufferViewBody): 22 (WebCore::FetchBody::textBody): 23 (WebCore::FetchBody::urlSearchParamsBody): 24 * bindings/generic/IDLTypes.h: 25 * dom/ExceptionOr.h: 26 (WebCore::ExceptionOr<ReturnType>::hasException): 27 (WebCore::ExceptionOr<ReturnType>::releaseException): 28 (WebCore::ExceptionOr<ReturnType>::releaseReturnValue): 29 * dom/MessageEvent.cpp: 30 (WebCore::MessageEvent::source): 31 * dom/MessageEvent.h: 32 * dom/Node.cpp: 33 (WebCore::nodeSetPreTransformedFromNodeOrStringVector): 34 (WebCore::Node::convertNodesOrStringsIntoNode): 35 * dom/Node.h: 36 * html/HTMLOptionsCollection.h: 37 * html/HTMLSelectElement.cpp: 38 (WebCore::HTMLSelectElement::add): 39 * html/HTMLSelectElement.h: 40 * html/track/TrackEvent.cpp: 41 (WebCore::TrackEvent::TrackEvent): 42 * html/track/TrackEvent.h: 43 1 44 2016-10-18 Chris Dumez <cdumez@apple.com> 2 45 -
trunk/Source/WebCore/Modules/fetch/FetchBody.h
r206737 r207517 66 66 #endif 67 67 68 bool isBlob() const { return std::experimental::holds_alternative<Ref<const Blob>>(m_data); }69 bool isFormData() const { return std::experimental::holds_alternative<Ref<FormData>>(m_data); }70 bool isArrayBuffer() const { return std::experimental::holds_alternative<Ref<const ArrayBuffer>>(m_data); }71 bool isArrayBufferView() const { return std::experimental::holds_alternative<Ref<const ArrayBufferView>>(m_data); }72 bool isURLSearchParams() const { return std::experimental::holds_alternative<Ref<const URLSearchParams>>(m_data); }73 bool isText() const { return std::experimental::holds_alternative<String>(m_data); }68 bool isBlob() const { return WTF::holds_alternative<Ref<const Blob>>(m_data); } 69 bool isFormData() const { return WTF::holds_alternative<Ref<FormData>>(m_data); } 70 bool isArrayBuffer() const { return WTF::holds_alternative<Ref<const ArrayBuffer>>(m_data); } 71 bool isArrayBufferView() const { return WTF::holds_alternative<Ref<const ArrayBufferView>>(m_data); } 72 bool isURLSearchParams() const { return WTF::holds_alternative<Ref<const URLSearchParams>>(m_data); } 73 bool isText() const { return WTF::holds_alternative<String>(m_data); } 74 74 75 75 static Optional<FetchBody> extract(ScriptExecutionContext&, JSC::ExecState&, JSC::JSValue, String&); … … 105 105 void consumeBlob(FetchBodyOwner&, Ref<DeferredPromise>&&); 106 106 107 const Blob& blobBody() const { return std::experimental::get<Ref<const Blob>>(m_data).get(); }108 FormData& formDataBody() { return std::experimental::get<Ref<FormData>>(m_data).get(); }109 const FormData& formDataBody() const { return std::experimental::get<Ref<FormData>>(m_data).get(); }110 const ArrayBuffer& arrayBufferBody() const { return std::experimental::get<Ref<const ArrayBuffer>>(m_data).get(); }111 const ArrayBufferView& arrayBufferViewBody() const { return std::experimental::get<Ref<const ArrayBufferView>>(m_data).get(); }112 String& textBody() { return std::experimental::get<String>(m_data); }113 const String& textBody() const { return std::experimental::get<String>(m_data); }114 const URLSearchParams& urlSearchParamsBody() const { return std::experimental::get<Ref<const URLSearchParams>>(m_data).get(); }107 const Blob& blobBody() const { return WTF::get<Ref<const Blob>>(m_data).get(); } 108 FormData& formDataBody() { return WTF::get<Ref<FormData>>(m_data).get(); } 109 const FormData& formDataBody() const { return WTF::get<Ref<FormData>>(m_data).get(); } 110 const ArrayBuffer& arrayBufferBody() const { return WTF::get<Ref<const ArrayBuffer>>(m_data).get(); } 111 const ArrayBufferView& arrayBufferViewBody() const { return WTF::get<Ref<const ArrayBufferView>>(m_data).get(); } 112 String& textBody() { return WTF::get<String>(m_data); } 113 const String& textBody() const { return WTF::get<String>(m_data); } 114 const URLSearchParams& urlSearchParamsBody() const { return WTF::get<Ref<const URLSearchParams>>(m_data).get(); } 115 115 116 std::experimental::variant<std::nullptr_t, Ref<const Blob>, Ref<FormData>, Ref<const ArrayBuffer>, Ref<const ArrayBufferView>, Ref<const URLSearchParams>, String> m_data { nullptr };116 Variant<std::nullptr_t, Ref<const Blob>, Ref<FormData>, Ref<const ArrayBuffer>, Ref<const ArrayBufferView>, Ref<const URLSearchParams>, String> m_data { nullptr }; 117 117 118 118 FetchBodyConsumer m_consumer { FetchBodyConsumer::Type::None }; -
trunk/Source/WebCore/bindings/generic/IDLTypes.h
r207462 r207517 116 116 117 117 template<typename... Ts> 118 struct IDLUnion : IDLType< std::experimental::variant<typename Ts::ImplementationType...>> {118 struct IDLUnion : IDLType<Variant<typename Ts::ImplementationType...>> { 119 119 using TypeList = brigand::list<Ts...>; 120 120 }; -
trunk/Source/WebCore/dom/ExceptionOr.h
r207384 r207517 44 44 45 45 private: 46 std::experimental::variant<Exception, ReturnType> m_value;46 Variant<Exception, ReturnType> m_value; 47 47 }; 48 48 … … 76 76 template<typename ReturnType> inline bool ExceptionOr<ReturnType>::hasException() const 77 77 { 78 return std::experimental::holds_alternative<Exception>(m_value);78 return WTF::holds_alternative<Exception>(m_value); 79 79 } 80 80 81 81 template<typename ReturnType> inline Exception&& ExceptionOr<ReturnType>::releaseException() 82 82 { 83 return std::experimental::get<Exception>(WTFMove(m_value));83 return WTF::get<Exception>(WTFMove(m_value)); 84 84 } 85 85 86 86 template<typename ReturnType> inline ReturnType&& ExceptionOr<ReturnType>::releaseReturnValue() 87 87 { 88 return std::experimental::get<ReturnType>(WTFMove(m_value));88 return WTF::get<ReturnType>(WTFMove(m_value)); 89 89 } 90 90 -
trunk/Source/WebCore/dom/MessageEvent.cpp
r207505 r207517 178 178 ); 179 179 180 return std::experimental::visit(visitor, m_source.value());180 return WTF::visit(visitor, m_source.value()); 181 181 } 182 182 -
trunk/Source/WebCore/dom/MessageEvent.h
r207505 r207517 39 39 class Blob; 40 40 41 using MessageEventSource = std::experimental::variant<RefPtr<DOMWindow>, RefPtr<MessagePort>>;41 using MessageEventSource = Variant<RefPtr<DOMWindow>, RefPtr<MessagePort>>; 42 42 43 43 class MessageEvent final : public Event { -
trunk/Source/WebCore/dom/Node.cpp
r207458 r207517 446 446 447 447 for (const auto& variant : vector) 448 std::experimental::visit(visitor, variant);448 WTF::visit(visitor, variant); 449 449 450 450 return nodeSet; … … 483 483 484 484 for (auto& variant : nodeOrStringVector) 485 std::experimental::visit(visitor, variant);485 WTF::visit(visitor, variant); 486 486 487 487 if (nodes.size() == 1) -
trunk/Source/WebCore/dom/Node.h
r207458 r207517 63 63 class UIRequestEvent; 64 64 65 using NodeOrString = std::experimental::variant<RefPtr<Node>, String>;65 using NodeOrString = Variant<RefPtr<Node>, String>; 66 66 67 67 class NodeRareDataBase { -
trunk/Source/WebCore/html/HTMLOptionsCollection.h
r207497 r207517 42 42 HTMLOptionElement* namedItem(const AtomicString& name) const final; 43 43 44 using OptionOrOptGroupElement = std::experimental::variant<RefPtr<HTMLOptionElement>, RefPtr<HTMLOptGroupElement>>;45 using HTMLElementOrInt = std::experimental::variant<RefPtr<HTMLElement>, int>;44 using OptionOrOptGroupElement = Variant<RefPtr<HTMLOptionElement>, RefPtr<HTMLOptGroupElement>>; 45 using HTMLElementOrInt = Variant<RefPtr<HTMLElement>, int>; 46 46 WEBCORE_EXPORT ExceptionOr<void> add(const OptionOrOptGroupElement&, Optional<HTMLElementOrInt> before); 47 47 WEBCORE_EXPORT void remove(int index); -
trunk/Source/WebCore/html/HTMLSelectElement.cpp
r207497 r207517 231 231 ); 232 232 233 beforeElement = std::experimental::visit(visitor, before.value());234 } 235 HTMLElement& toInsert = std::experimental::visit([](const auto& htmlElement) -> HTMLElement& {233 beforeElement = WTF::visit(visitor, before.value()); 234 } 235 HTMLElement& toInsert = WTF::visit([](const auto& htmlElement) -> HTMLElement& { 236 236 return *htmlElement; 237 237 }, element); -
trunk/Source/WebCore/html/HTMLSelectElement.h
r207497 r207517 52 52 bool usesMenuList() const; 53 53 54 using OptionOrOptGroupElement = std::experimental::variant<RefPtr<HTMLOptionElement>, RefPtr<HTMLOptGroupElement>>;55 using HTMLElementOrInt = std::experimental::variant<RefPtr<HTMLElement>, int>;54 using OptionOrOptGroupElement = Variant<RefPtr<HTMLOptionElement>, RefPtr<HTMLOptGroupElement>>; 55 using HTMLElementOrInt = Variant<RefPtr<HTMLElement>, int>; 56 56 WEBCORE_EXPORT ExceptionOr<void> add(const OptionOrOptGroupElement&, Optional<HTMLElementOrInt> before); 57 57 -
trunk/Source/WebCore/html/track/TrackEvent.cpp
r207468 r207517 44 44 { 45 45 if (initializer.track) { 46 m_track = std::experimental::visit([](const auto& trackbase) -> TrackBase* {46 m_track = WTF::visit([](const auto& trackbase) -> TrackBase* { 47 47 return trackbase.get(); 48 48 }, *initializer.track); -
trunk/Source/WebCore/html/track/TrackEvent.h
r207468 r207517 45 45 } 46 46 47 using TrackEventTrack = std::experimental::variant<RefPtr<VideoTrack>, RefPtr<AudioTrack>, RefPtr<TextTrack>>;47 using TrackEventTrack = Variant<RefPtr<VideoTrack>, RefPtr<AudioTrack>, RefPtr<TextTrack>>; 48 48 49 49 struct Init : public EventInit { -
trunk/Source/WebKit/mac/ChangeLog
r207512 r207517 1 2016-10-18 Sam Weinig <sam@webkit.org> 2 3 Replace std::experimental::variant with WTF::Variant (or similar) 4 https://bugs.webkit.org/show_bug.cgi?id=163626 5 6 Reviewed by Chris Dumez. 7 8 Rename std::experimental::variant, Variant. Move helpers get/holds_alternative/etc. 9 into the WTF namespace. 10 11 * DOM/DOMHTMLSelectElement.mm: 12 (-[DOMHTMLSelectElement add:before:]): 13 1 14 2016-10-18 Simon Fraser <simon.fraser@apple.com> 2 15 -
trunk/Source/WebKit/mac/DOM/DOMHTMLSelectElement.mm
r207497 r207517 186 186 187 187 auto& coreElement = *core(element); 188 std::experimental::variant<RefPtr<WebCore::HTMLOptionElement>, RefPtr<WebCore::HTMLOptGroupElement>> variantElement;188 Variant<RefPtr<WebCore::HTMLOptionElement>, RefPtr<WebCore::HTMLOptGroupElement>> variantElement; 189 189 if (is<WebCore::HTMLOptionElement>(coreElement)) 190 190 variantElement = &downcast<WebCore::HTMLOptionElement>(coreElement); -
trunk/Tools/ChangeLog
r207512 r207517 1 2016-10-18 Sam Weinig <sam@webkit.org> 2 3 Replace std::experimental::variant with WTF::Variant (or similar) 4 https://bugs.webkit.org/show_bug.cgi?id=163626 5 6 Reviewed by Chris Dumez. 7 8 Rename std::experimental::variant, Variant. Move helpers get/holds_alternative/etc. 9 into the WTF namespace. 10 11 * TestWebKitAPI/Tests/WTF/Variant.cpp: 12 (TestWebKitAPI::TEST): 13 1 14 2016-10-18 Simon Fraser <simon.fraser@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WTF/Variant.cpp
r204493 r207517 38 38 TEST(WTF_Variant, Initial) 39 39 { 40 std::experimental::variant<int, double> v1;40 Variant<int, double> v1; 41 41 EXPECT_TRUE(v1.index() == 0); 42 EXPECT_TRUE( std::experimental::get<int>(v1) == 0);42 EXPECT_TRUE(WTF::get<int>(v1) == 0); 43 43 44 44 struct T { … … 47 47 }; 48 48 49 std::experimental::variant<T, int> v2;49 Variant<T, int> v2; 50 50 EXPECT_TRUE(v2.index() == 0); 51 EXPECT_TRUE( std::experimental::get<T>(v2).value == 15);51 EXPECT_TRUE(WTF::get<T>(v2).value == 15); 52 52 } 53 53 54 54 TEST(WTF_Variant, Basic) 55 55 { 56 std::experimental::variant<int, double> variant = 1;56 Variant<int, double> variant = 1; 57 57 EXPECT_TRUE(variant.index() == 0); 58 EXPECT_TRUE( std::experimental::get<int>(variant) == 1);59 EXPECT_TRUE(* std::experimental::get_if<int>(variant) == 1);60 EXPECT_TRUE( std::experimental::get_if<double>(variant) == nullptr);61 EXPECT_TRUE( std::experimental::holds_alternative<int>(variant));62 EXPECT_FALSE( std::experimental::holds_alternative<double>(variant));58 EXPECT_TRUE(WTF::get<int>(variant) == 1); 59 EXPECT_TRUE(*WTF::get_if<int>(variant) == 1); 60 EXPECT_TRUE(WTF::get_if<double>(variant) == nullptr); 61 EXPECT_TRUE(WTF::holds_alternative<int>(variant)); 62 EXPECT_FALSE(WTF::holds_alternative<double>(variant)); 63 63 64 64 variant = 1.0; 65 65 EXPECT_TRUE(variant.index() == 1); 66 EXPECT_TRUE( std::experimental::get<double>(variant) == 1);67 EXPECT_TRUE(* std::experimental::get_if<double>(variant) == 1.0);68 EXPECT_TRUE( std::experimental::get_if<int>(variant) == nullptr);69 EXPECT_TRUE( std::experimental::holds_alternative<double>(variant));70 EXPECT_FALSE( std::experimental::holds_alternative<int>(variant));66 EXPECT_TRUE(WTF::get<double>(variant) == 1); 67 EXPECT_TRUE(*WTF::get_if<double>(variant) == 1.0); 68 EXPECT_TRUE(WTF::get_if<int>(variant) == nullptr); 69 EXPECT_TRUE(WTF::holds_alternative<double>(variant)); 70 EXPECT_FALSE(WTF::holds_alternative<int>(variant)); 71 71 } 72 72 … … 95 95 Type type = Type::None; 96 96 97 std::experimental::variant<int, float, String> variant = 8;98 std::experimental::visit(Visitor(type), variant);97 Variant<int, float, String> variant = 8; 98 WTF::visit(Visitor(type), variant); 99 99 EXPECT_TRUE(Type::Int == type); 100 100 101 101 102 102 variant = 1.0f; 103 std::experimental::visit(Visitor(type), variant);103 WTF::visit(Visitor(type), variant); 104 104 EXPECT_TRUE(Type::Float == type); 105 105 106 106 107 107 variant = "hello"; 108 std::experimental::visit(Visitor(type), variant);108 WTF::visit(Visitor(type), variant); 109 109 EXPECT_TRUE(Type::String == type); 110 110 } … … 127 127 ); 128 128 129 std::experimental::variant<int, float, String> variant = 8;130 std::experimental::visit(visitor, variant);129 Variant<int, float, String> variant = 8; 130 WTF::visit(visitor, variant); 131 131 EXPECT_TRUE(Type::Int == type); 132 132 133 133 134 134 variant = 1.0f; 135 std::experimental::visit(visitor, variant);135 WTF::visit(visitor, variant); 136 136 EXPECT_TRUE(Type::Float == type); 137 137 138 138 139 139 variant = "hello"; 140 std::experimental::visit(visitor, variant);140 WTF::visit(visitor, variant); 141 141 EXPECT_TRUE(Type::String == type); 142 142 } … … 148 148 { 149 149 auto uniquePtr = std::make_unique<ConstructorDestructorCounter>(); 150 std::experimental::variant<std::unique_ptr<ConstructorDestructorCounter>, int> v = WTFMove(uniquePtr);150 Variant<std::unique_ptr<ConstructorDestructorCounter>, int> v = WTFMove(uniquePtr); 151 151 152 152 EXPECT_EQ(1u, ConstructorDestructorCounter::constructionCount); … … 163 163 RefLogger a("a"); 164 164 RefPtr<RefLogger> ref(&a); 165 std::experimental::variant<RefPtr<RefLogger>, int> v = ref;165 Variant<RefPtr<RefLogger>, int> v = ref; 166 166 } 167 167 … … 171 171 RefLogger a("a"); 172 172 RefPtr<RefLogger> ref(&a); 173 std::experimental::variant<RefPtr<RefLogger>, int> v = WTFMove(ref);173 Variant<RefPtr<RefLogger>, int> v = WTFMove(ref); 174 174 } 175 175 … … 182 182 RefLogger a("a"); 183 183 Ref<RefLogger> ref(a); 184 std::experimental::variant<Ref<RefLogger>, int> v = WTFMove(ref);184 Variant<Ref<RefLogger>, int> v = WTFMove(ref); 185 185 } 186 186
Note: See TracChangeset
for help on using the changeset viewer.