Changeset 207517 in webkit


Ignore:
Timestamp:
Oct 18, 2016 7:43:44 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Replace std::experimental::variant with WTF::Variant (or similar)
https://bugs.webkit.org/show_bug.cgi?id=163626

Patch by Sam Weinig <sam@webkit.org> on 2016-10-18
Reviewed by Chris Dumez.

Rename std::experimental::variant, Variant. Move helpers get/holds_alternative/etc.
into the WTF namespace.

Source/JavaScriptCore:

  • domjit/DOMJITReg.h:

(JSC::DOMJIT::Reg::gpr):
(JSC::DOMJIT::Reg::fpr):
(JSC::DOMJIT::Reg::jsValueRegs):

Source/WebCore:

  • Modules/fetch/FetchBody.h:

(WebCore::FetchBody::isBlob):
(WebCore::FetchBody::isFormData):
(WebCore::FetchBody::isArrayBuffer):
(WebCore::FetchBody::isArrayBufferView):
(WebCore::FetchBody::isURLSearchParams):
(WebCore::FetchBody::isText):
(WebCore::FetchBody::blobBody):
(WebCore::FetchBody::formDataBody):
(WebCore::FetchBody::arrayBufferBody):
(WebCore::FetchBody::arrayBufferViewBody):
(WebCore::FetchBody::textBody):
(WebCore::FetchBody::urlSearchParamsBody):

  • bindings/generic/IDLTypes.h:
  • dom/ExceptionOr.h:

(WebCore::ExceptionOr<ReturnType>::hasException):
(WebCore::ExceptionOr<ReturnType>::releaseException):
(WebCore::ExceptionOr<ReturnType>::releaseReturnValue):

  • dom/MessageEvent.cpp:

(WebCore::MessageEvent::source):

  • dom/MessageEvent.h:
  • dom/Node.cpp:

(WebCore::nodeSetPreTransformedFromNodeOrStringVector):
(WebCore::Node::convertNodesOrStringsIntoNode):

  • dom/Node.h:
  • html/HTMLOptionsCollection.h:
  • html/HTMLSelectElement.cpp:

(WebCore::HTMLSelectElement::add):

  • html/HTMLSelectElement.h:
  • html/track/TrackEvent.cpp:

(WebCore::TrackEvent::TrackEvent):

  • html/track/TrackEvent.h:

Source/WebKit/mac:

  • DOM/DOMHTMLSelectElement.mm:

(-[DOMHTMLSelectElement add:before:]):

Source/WTF:

  • wtf/Forward.h:
  • wtf/Variant.h:

Tools:

  • TestWebKitAPI/Tests/WTF/Variant.cpp:

(TestWebKitAPI::TEST):

Location:
trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r207500 r207517  
     12016-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
    1162016-10-18  Keith Miller  <keith_miller@apple.com>
    217
  • trunk/Source/JavaScriptCore/domjit/DOMJITReg.h

    r206846 r207517  
    7272    {
    7373        ASSERT(isGPR());
    74         return std::experimental::get<GPRReg>(m_variant);
     74        return WTF::get<GPRReg>(m_variant);
    7575    }
    7676    FPRReg fpr() const
    7777    {
    7878        ASSERT(isFPR());
    79         return std::experimental::get<FPRReg>(m_variant);
     79        return WTF::get<FPRReg>(m_variant);
    8080    }
    8181    JSValueRegs jsValueRegs() const
    8282    {
    8383        ASSERT(isJSValueRegs());
    84         return std::experimental::get<JSValueRegs>(m_variant);
     84        return WTF::get<JSValueRegs>(m_variant);
    8585    }
    8686
    8787private:
    88     std::experimental::variant<GPRReg, FPRReg, JSValueRegs> m_variant;
     88    Variant<GPRReg, FPRReg, JSValueRegs> m_variant;
    8989};
    9090
  • trunk/Source/WTF/ChangeLog

    r207480 r207517  
     12016-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
    1142016-10-18  Filip Pizlo  <fpizlo@apple.com>
    215
  • trunk/Source/WTF/wtf/Forward.h

    r204977 r207517  
    3535template<typename T> class StringBuffer;
    3636
     37template<typename... T> class Variant;
    3738template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity> class Vector;
    3839
     
    4950class StringView;
    5051class 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...>;
    6352
    6453}
     
    8574using WTF::StringView;
    8675using WTF::TextPosition;
     76using WTF::Variant;
    8777using WTF::Vector;
  • trunk/Source/WTF/wtf/Variant.h

    r207381 r207517  
    6060#if !COMPILER(CLANG) || WTF_CPP_STD_VER >= 14
    6161
    62 namespace std {
    63 namespace experimental {
     62namespace WTF {
    6463
    6564#if COMPILER_SUPPORTS(EXCEPTIONS)
     
    166165
    167166template<typename ... _Types>
    168 class variant;
     167class Variant;
    169168
    170169template<typename>
     
    181180
    182181template <typename... _Types>
    183 struct variant_size<variant<_Types...>>
     182struct variant_size<Variant<_Types...>>
    184183    : std::integral_constant<size_t, sizeof...(_Types)> {};
    185184
     
    206205
    207206template<size_t _Index,typename ... _Types>
    208 struct variant_alternative<_Index,variant<_Types...>>{
     207struct variant_alternative<_Index,Variant<_Types...>>{
    209208    using type=typename __indexed_type<_Index,_Types...>::__type;
    210209};
     
    213212
    214213template<typename _Type,typename ... _Types>
    215 constexpr _Type& get(variant<_Types...>&);
     214constexpr _Type& get(Variant<_Types...>&);
    216215
    217216template<typename _Type,typename ... _Types>
    218 constexpr _Type const& get(variant<_Types...> const&);
     217constexpr _Type const& get(Variant<_Types...> const&);
    219218
    220219template<typename _Type,typename ... _Types>
    221 constexpr _Type&& get(variant<_Types...>&&);
     220constexpr _Type&& get(Variant<_Types...>&&);
    222221
    223222template<typename _Type,typename ... _Types>
    224 constexpr const _Type&& get(variant<_Types...> const&&);
     223constexpr const _Type&& get(Variant<_Types...> const&&);
    225224
    226225template<ptrdiff_t _Index,typename ... _Types>
    227 constexpr typename __indexed_type<_Index,_Types...>::__type& get(variant<_Types...>&);
     226constexpr typename __indexed_type<_Index,_Types...>::__type& get(Variant<_Types...>&);
    228227
    229228template<ptrdiff_t _Index,typename ... _Types>
    230 constexpr typename __indexed_type<_Index,_Types...>::__type&& get(variant<_Types...>&&);
     229constexpr typename __indexed_type<_Index,_Types...>::__type&& get(Variant<_Types...>&&);
    231230
    232231template<ptrdiff_t _Index,typename ... _Types>
    233232constexpr typename __indexed_type<_Index,_Types...>::__type const& get(
    234     variant<_Types...> const&);
     233    Variant<_Types...> const&);
    235234
    236235template <ptrdiff_t _Index, typename... _Types>
    237236constexpr const typename __indexed_type<_Index, _Types...>::__type &&
    238 get(variant<_Types...> const &&);
     237get(Variant<_Types...> const &&);
    239238
    240239template<typename _Type,typename ... _Types>
    241 constexpr std::add_pointer_t<_Type> get_if(variant<_Types...>&);
     240constexpr std::add_pointer_t<_Type> get_if(Variant<_Types...>&);
    242241
    243242template<typename _Type,typename ... _Types>
    244 constexpr std::add_pointer_t<_Type const> get_if(variant<_Types...> const&);
     243constexpr std::add_pointer_t<_Type const> get_if(Variant<_Types...> const&);
    245244
    246245template<ptrdiff_t _Index,typename ... _Types>
    247 constexpr std::add_pointer_t<typename __indexed_type<_Index,_Types...>::__type> get_if(variant<_Types...>&);
     246constexpr std::add_pointer_t<typename __indexed_type<_Index,_Types...>::__type> get_if(Variant<_Types...>&);
    248247
    249248template<ptrdiff_t _Index,typename ... _Types>
    250249constexpr std::add_pointer_t<typename __indexed_type<_Index,_Types...>::__type const> get_if(
    251     variant<_Types...> const&);
     250    Variant<_Types...> const&);
    252251
    253252template<ptrdiff_t _Index,typename ... _Types>
     
    380379
    381380template<typename ... _Types>
    382 struct __any_backup_storage_required<variant<_Types...> >{
     381struct __any_backup_storage_required<Variant<_Types...> >{
    383382    static const bool __value=
    384383        __any_backup_storage_required_impl<0,sizeof...(_Types),_Types...>::__value;
     
    705704
    706705template<typename ... _Types>
    707 struct __variant_indices<variant<_Types...>>{
     706struct __variant_indices<Variant<_Types...>>{
    708707    typedef typename __type_indices<_Types...>::__type __type;
    709708};
     
    14371436
    14381437template<typename ... _Types>
    1439 class variant:
     1438class Variant:
    14401439        private __variant_base<
    1441     variant<_Types...>,__all_trivially_destructible<_Types...>::__value>
     1440    Variant<_Types...>,__all_trivially_destructible<_Types...>::__value>
    14421441{
    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;
    14441443    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>;
    14501449   
    14511450    template<ptrdiff_t _Index,typename ... _Types2>
     
    14681467        if(valueless_by_exception())
    14691468            return;
    1470         __destroy_op_table<variant>::__apply[index()](this);
     1469        __destroy_op_table<Variant>::__apply[index()](this);
    14711470        __index=-1;
    14721471    }
    14731472   
    1474     ptrdiff_t __move_construct(variant& __other){
     1473    ptrdiff_t __move_construct(Variant& __other){
    14751474        ptrdiff_t const __other_index=__other.index();
    14761475        if(__other_index==-1)
    14771476            return -1;
    1478         __move_construct_op_table<variant>::__apply[__other_index](this,__other);
     1477        __move_construct_op_table<Variant>::__apply[__other_index](this,__other);
    14791478        __other.__destroy_self();
    14801479        return __other_index;
    14811480    }
    14821481
    1483     ptrdiff_t __copy_construct(variant const& __other){
     1482    ptrdiff_t __copy_construct(Variant const& __other){
    14841483        ptrdiff_t const __other_index=__other.index();
    14851484        if(__other_index==-1)
    14861485            return -1;
    1487         __copy_construct_op_table<variant>::__apply[__other_index](this,__other);
     1486        __copy_construct_op_table<Variant>::__apply[__other_index](this,__other);
    14881487        return __other_index;
    14891488    }
     
    15321531
    15331532public:
    1534     constexpr variant()
     1533    constexpr Variant()
    15351534        __NOEXCEPT_(noexcept(typename __indexed_type<0,_Types...>::__type())):
    15361535        __storage(in_place<0>),
     
    15381537    {}
    15391538
    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)
    15411540    __NOEXCEPT_(__noexcept_variant_move_construct<_Types...>::value):
    15421541        __index(__move_construct(__other))
    15431542    {}
    15441543
    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)
    15481547    __NOEXCEPT_(__noexcept_variant_non_const_copy_construct<_Types...>::value):
    15491548        __index(__copy_construct(__other))
    15501549    {}
    15511550
    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)
    15551554    __NOEXCEPT_(__noexcept_variant_const_copy_construct<_Types...>::value):
    15561555        __index(__copy_construct(__other))
    15571556    {}
    15581557
    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;
    15601559   
    15611560    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):
    15631562        __storage(
    15641563            in_place<__type_index<_Type,_Types...>::__value>,
     
    15701569
    15711570    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):
    15731572        __storage(in_place<_Index>,std::forward<_Args>(__args)...),
    15741573        __index(_Index)
     
    15781577   
    15791578    template<typename _Type>
    1580     constexpr variant(_Type&& __x):
     1579    constexpr Variant(_Type&& __x):
    15811580        __storage(
    15821581            in_place<
     
    15911590                 (__constructible_matches<std::initializer_list<_Type>,_Types...>::__type::__length>0)
    15921591             >::type>
    1593     constexpr variant(std::initializer_list<_Type> __x):
     1592    constexpr Variant(std::initializer_list<_Type> __x):
    15941593        __storage(
    15951594            in_place<
     
    16001599   
    16011600    template<typename _Type>
    1602     variant& operator=(_Type&& __x){
     1601    Variant& operator=(_Type&& __x){
    16031602        constexpr size_t _Index=
    16041603            __type_index_to_construct<_Type,_Types...>::__value;
     
    16121611    }
    16131612
    1614     variant &operator=(
     1613    Variant &operator=(
    16151614        typename std::conditional<
    16161615            !(__all_copy_constructible<_Types...>::value &&
    16171616              __all_move_constructible<_Types...>::value &&
    16181617              __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=(
    16221621        typename std::conditional<
    16231622            __all_copy_constructible<_Types...>::value &&
    16241623                __all_move_constructible<_Types...>::value &&
    16251624                __all_copy_assignable<_Types...>::value,
    1626             variant, __private_type>::type const &__other) {
     1625            Variant, __private_type>::type const &__other) {
    16271626        if (__other.valueless_by_exception()) {
    16281627            __destroy_self();
    16291628        }
    16301629        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);
    16321631        }
    16331632        else{
    1634             __replace_construct_helper::__op_table<variant>::__copy_assign[
     1633            __replace_construct_helper::__op_table<Variant>::__copy_assign[
    16351634                __other.index()](this,__other);
    16361635        }
    16371636        return *this;
    16381637    }
    1639     variant &operator=(
     1638    Variant &operator=(
    16401639        typename std::conditional<
    16411640            !(__all_copy_constructible<_Types...>::value &&
    16421641              __all_move_constructible<_Types...>::value &&
    16431642              __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=(
    16471646        typename std::conditional<
    16481647            __all_copy_constructible<_Types...>::value &&
    16491648                __all_move_constructible<_Types...>::value &&
    16501649                __all_copy_assignable<_Types...>::value,
    1651             variant, __private_type>::type &__other) {
     1650            Variant, __private_type>::type &__other) {
    16521651        if(__other.valueless_by_exception()){
    16531652            __destroy_self();
    16541653        }
    16551654        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);
    16571656        }
    16581657        else{
    1659             __replace_construct_helper::__op_table<variant>::__copy_assign[
     1658            __replace_construct_helper::__op_table<Variant>::__copy_assign[
    16601659                __other.index()](this,__other);
    16611660        }
    16621661        return *this;
    16631662    }
    1664     variant &operator=(
     1663    Variant &operator=(
    16651664        typename std::conditional<
    16661665            !(__all_move_constructible<_Types...>::value &&
    16671666              __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=(
    16711670        typename std::conditional<__all_move_constructible<_Types...>::value &&
    16721671                                      __all_move_assignable<_Types...>::value,
    1673                                   variant, __private_type>::type &&
     1672                                  Variant, __private_type>::type &&
    16741673            __other) __NOEXCEPT_(__noexcept_variant_move_assign<_Types...>::value) {
    16751674        if (__other.valueless_by_exception()) {
     
    16771676        }
    16781677        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);
    16801679            __other.__destroy_self();
    16811680        }
    16821681        else{
    1683             __replace_construct_helper::__op_table<variant>::__move_assign[
     1682            __replace_construct_helper::__op_table<Variant>::__move_assign[
    16841683                __other.index()](this,__other);
    16851684        }
     
    17091708            __all_swappable<_Types...>::value &&
    17101709                __all_move_constructible<_Types...>::value,
    1711             variant, __private_type>::type
     1710            Variant, __private_type>::type
    17121711            &__other) __NOEXCEPT_(__noexcept_variant_swap<_Types...>::value) {
    17131712        if (__other.index() == index()) {
    17141713            if(!valueless_by_exception())
    1715                 __swap_op_table<variant>::__apply[index()](*this,__other);
     1714                __swap_op_table<Variant>::__apply[index()](*this,__other);
    17161715        }
    17171716        else{
    1718             variant __temp(std::move(__other));
     1717            Variant __temp(std::move(__other));
    17191718            __other.__index=__other.__move_construct(*this);
    17201719            __index=__move_construct(__temp);
     
    17241723
    17251724template<>
    1726 class variant<>{
     1725class Variant<>{
    17271726public:
    1728     variant()=delete;
     1727    Variant()=delete;
    17291728   
    17301729    constexpr bool valueless_by_exception() const __NOEXCEPT{
     
    17351734    }
    17361735
    1737     void swap(variant&){}
     1736    void swap(Variant&){}
    17381737};
    17391738
     
    17421741                            __all_move_constructible<_Types...>::value,
    17431742                        void>::type
    1744 swap(variant<_Types...> &__lhs, variant<_Types...> &__rhs) __NOEXCEPT_(
     1743swap(Variant<_Types...> &__lhs, Variant<_Types...> &__rhs) __NOEXCEPT_(
    17451744    __noexcept_variant_swap<_Types...>::value) {
    17461745    __lhs.swap(__rhs);
     
    17501749struct __variant_accessor{
    17511750    typedef typename __indexed_type<_Index,_Types...>::__type __type;
    1752     static constexpr __type& get(variant<_Types...>& __v){
     1751    static constexpr __type& get(Variant<_Types...>& __v){
    17531752        return __v.__storage.__get(in_place<_Index>);
    17541753    }
    1755     static constexpr __type const& get(variant<_Types...> const& __v){
     1754    static constexpr __type const& get(Variant<_Types...> const& __v){
    17561755        return __v.__storage.__get(in_place<_Index>);
    17571756    }
    1758     static constexpr __type&& get(variant<_Types...>&& __v){
     1757    static constexpr __type&& get(Variant<_Types...>&& __v){
    17591758        return __v.__storage.__get_rref(in_place<_Index>);
    17601759    }
    1761     static constexpr const __type&& get(variant<_Types...> const&& __v){
     1760    static constexpr const __type&& get(Variant<_Types...> const&& __v){
    17621761        return __v.__storage.__get_rref(in_place<_Index>);
    17631762    }
     
    17651764
    17661765template<typename _Type,typename ... _Types>
    1767 constexpr _Type& get(variant<_Types...>& __v){
     1766constexpr _Type& get(Variant<_Types...>& __v){
    17681767    return get<__type_index<_Type,_Types...>::__value>(__v);
    17691768}
    17701769
    17711770template<typename _Type,typename ... _Types>
    1772 constexpr _Type&& get(variant<_Types...>&& __v){
     1771constexpr _Type&& get(Variant<_Types...>&& __v){
    17731772    return get<__type_index<_Type,_Types...>::__value>(std::move(__v));
    17741773}
    17751774
    17761775template<typename _Type,typename ... _Types>
    1777 constexpr _Type const& get(variant<_Types...> const& __v){
     1776constexpr _Type const& get(Variant<_Types...> const& __v){
    17781777    return get<__type_index<_Type,_Types...>::__value>(__v);
    17791778}
    17801779
    17811780template<typename _Type,typename ... _Types>
    1782 constexpr const _Type&& get(variant<_Types...> const&& __v){
     1781constexpr const _Type&& get(Variant<_Types...> const&& __v){
    17831782    return get<__type_index<_Type,_Types...>::__value>(std::move(__v));
    17841783}
     
    17861785
    17871786template<ptrdiff_t _Index,typename ... _Types>
    1788 constexpr typename __indexed_type<_Index,_Types...>::__type const& get(variant<_Types...> const& __v){
     1787constexpr typename __indexed_type<_Index,_Types...>::__type const& get(Variant<_Types...> const& __v){
    17891788    return *(
    17901789        (_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")
    17921791            : &__variant_accessor<_Index,_Types...>::get(__v)
    17931792    );
     
    17951794
    17961795template<ptrdiff_t _Index,typename ... _Types>
    1797 constexpr typename __indexed_type<_Index,_Types...>::__type& get(variant<_Types...>& __v){
     1796constexpr typename __indexed_type<_Index,_Types...>::__type& get(Variant<_Types...>& __v){
    17981797    return *(
    17991798        (_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")
    18011800            : &__variant_accessor<_Index,_Types...>::get(__v)
    18021801    );
     
    18041803
    18051804template<ptrdiff_t _Index,typename ... _Types>
    1806 constexpr typename __indexed_type<_Index,_Types...>::__type&& get(variant<_Types...>&& __v){
     1805constexpr typename __indexed_type<_Index,_Types...>::__type&& get(Variant<_Types...>&& __v){
    18071806    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))
    18091808    );
    18101809}
    18111810
    18121811template<ptrdiff_t _Index,typename ... _Types>
    1813 constexpr const typename __indexed_type<_Index,_Types...>::__type&& get(variant<_Types...> const&& __v){
     1812constexpr const typename __indexed_type<_Index,_Types...>::__type&& get(Variant<_Types...> const&& __v){
    18141813    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))
    18161815    );
    18171816}
    18181817
    18191818template<typename _Type,typename ... _Types>
    1820 constexpr std::add_pointer_t<_Type> get_if(variant<_Types...>& __v){
     1819constexpr std::add_pointer_t<_Type> get_if(Variant<_Types...>& __v){
    18211820    return (__type_index<_Type,_Types...>::__value!=__v.index())?nullptr:&get<_Type>(__v);
    18221821}
    18231822
    18241823template<typename _Type,typename ... _Types>
    1825 constexpr std::add_pointer_t<_Type const> get_if(variant<_Types...> const& __v){
     1824constexpr std::add_pointer_t<_Type const> get_if(Variant<_Types...> const& __v){
    18261825    return (__type_index<_Type,_Types...>::__value!=__v.index())?nullptr:&get<_Type>(__v);
    18271826}
    18281827
    18291828template<ptrdiff_t _Index,typename ... _Types>
    1830 constexpr std::add_pointer_t<typename __indexed_type<_Index,_Types...>::__type> get_if(variant<_Types...>& __v){
     1829constexpr std::add_pointer_t<typename __indexed_type<_Index,_Types...>::__type> get_if(Variant<_Types...>& __v){
    18311830    return ((_Index!=__v.index())?nullptr:
    18321831        &__variant_accessor<_Index,_Types...>::get(__v));
     
    18351834template<ptrdiff_t _Index,typename ... _Types>
    18361835constexpr std::add_pointer_t<typename __indexed_type<_Index,_Types...>::__type const> get_if(
    1837     variant<_Types...> const& __v){
     1836    Variant<_Types...> const& __v){
    18381837    return ((_Index!=__v.index())?nullptr:
    18391838        &__variant_accessor<_Index,_Types...>::get(__v));
     
    18411840
    18421841template<typename _Type,typename ... _Types>
    1843 constexpr bool holds_alternative(variant<_Types...> const& __v) __NOEXCEPT{
     1842constexpr bool holds_alternative(Variant<_Types...> const& __v) __NOEXCEPT{
    18441843    return __v.index()==__type_index<_Type,_Types...>::__value;
    18451844}
     
    18601859template<typename _Visitor,typename ... _Types>
    18611860struct __visitor_table{
    1862     typedef variant<_Types...> __variant_type;
     1861    typedef Variant<_Types...> __variant_type;
    18631862    typedef typename __visitor_return_type<_Visitor,_Types...>::__type __return_type;
    18641863    typedef __return_type (*__func_type)(_Visitor&,__variant_type&);
     
    18791878template<typename _Visitor,typename ... _Types>
    18801879constexpr typename __visitor_return_type<_Visitor,_Types...>::__type
    1881 visit(_Visitor&& __visitor,variant<_Types...>& __v){
     1880visit(_Visitor&& __visitor,Variant<_Types...>& __v){
    18821881    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")
    18841883        : __visitor_table<_Visitor,_Types...>::__trampoline[__v.index()](__visitor,__v);
    18851884}
     
    19451944    static constexpr typename __multi_visitor_return_type<_Visitor,_Variants...>::__type
    19461945    __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");
    19481947    }
    19491948};
     
    19531952
    19541953template<typename ... _Types>
    1955 struct __variant_type_count<variant<_Types...>>{
     1954struct __variant_type_count<Variant<_Types...>>{
    19561955    static constexpr size_t __value=sizeof...(_Types);
    19571956};
     
    19901989
    19911990template<typename ... _Types>
    1992 constexpr bool operator==(variant<_Types...> const& __lhs,variant<_Types...> const& __rhs){
     1991constexpr bool operator==(Variant<_Types...> const& __lhs,Variant<_Types...> const& __rhs){
    19931992    return (__lhs.index()==__rhs.index()) &&
    19941993        ((__lhs.index()==-1) ||
    1995          __equality_op_table<variant<_Types...>>::__equality_compare[__lhs.index()](
     1994         __equality_op_table<Variant<_Types...>>::__equality_compare[__lhs.index()](
    19961995             __lhs,__rhs));
    19971996}
    19981997
    19991998template<typename ... _Types>
    2000 constexpr bool operator!=(variant<_Types...> const& __lhs,variant<_Types...> const& __rhs){
     1999constexpr bool operator!=(Variant<_Types...> const& __lhs,Variant<_Types...> const& __rhs){
    20012000    return !(__lhs==__rhs);
    20022001}
    20032002
    20042003template<typename ... _Types>
    2005 constexpr bool operator<(variant<_Types...> const& __lhs,variant<_Types...> const& __rhs){
     2004constexpr bool operator<(Variant<_Types...> const& __lhs,Variant<_Types...> const& __rhs){
    20062005    return (__lhs.index()<__rhs.index()) ||
    20072006        ((__lhs.index()==__rhs.index()) &&
    20082007         ((__lhs.index()!=-1) &&
    2009           __less_than_op_table<variant<_Types...>>::
     2008          __less_than_op_table<Variant<_Types...>>::
    20102009          __less_than_compare[__lhs.index()](__lhs,__rhs)));
    20112010}
    20122011
    20132012template<typename ... _Types>
    2014 constexpr bool operator>(variant<_Types...> const& __lhs,variant<_Types...> const& __rhs){
     2013constexpr bool operator>(Variant<_Types...> const& __lhs,Variant<_Types...> const& __rhs){
    20152014    return __rhs<__lhs;
    20162015}
    20172016
    20182017template<typename ... _Types>
    2019 constexpr bool operator>=(variant<_Types...> const& __lhs,variant<_Types...> const& __rhs){
     2018constexpr bool operator>=(Variant<_Types...> const& __lhs,Variant<_Types...> const& __rhs){
    20202019    return !(__lhs<__rhs);
    20212020}
    20222021
    20232022template<typename ... _Types>
    2024 constexpr bool operator<=(variant<_Types...> const& __lhs,variant<_Types...> const& __rhs){
     2023constexpr bool operator<=(Variant<_Types...> const& __lhs,Variant<_Types...> const& __rhs){
    20252024    return !(__lhs>__rhs);
    20262025}
    20272026
    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;}
     2027struct Monostate{};
     2028
     2029constexpr inline bool operator==(Monostate const&,Monostate const&){ return true;}
     2030constexpr inline bool operator!=(Monostate const&,Monostate const&){ return false;}
     2031constexpr inline bool operator>=(Monostate const&,Monostate const&){ return true;}
     2032constexpr inline bool operator<=(Monostate const&,Monostate const&){ return true;}
     2033constexpr inline bool operator>(Monostate const&,Monostate const&){ return false;}
     2034constexpr inline bool operator<(Monostate const&,Monostate const&){ return false;}
    20362035
    20372036struct __hash_visitor{
     
    20422041};
    20432042
    2044 } // namespace experimental
     2043} // namespace WTF
     2044
     2045namespace std {
    20452046
    20462047template<>
    2047 struct hash<experimental::monostate>{
    2048     size_t operator()(experimental::monostate) __NOEXCEPT{
     2048struct hash<WTF::Monostate>{
     2049    size_t operator()(WTF::Monostate) __NOEXCEPT{
    20492050        return 42;
    20502051    }
     
    20522053
    20532054template<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);
     2055struct 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);
    20582058    }
    20592059};
    20602060
    20612061} // namespace std
     2062
     2063using WTF::Monostate;
     2064using WTF::Variant;
    20622065
    20632066#endif // !COMPILER(CLANG) || WTF_CPP_STD_VER >= 14
  • trunk/Source/WebCore/ChangeLog

    r207516 r207517  
     12016-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
    1442016-10-18  Chris Dumez  <cdumez@apple.com>
    245
  • trunk/Source/WebCore/Modules/fetch/FetchBody.h

    r206737 r207517  
    6666#endif
    6767
    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); }
    7474
    7575    static Optional<FetchBody> extract(ScriptExecutionContext&, JSC::ExecState&, JSC::JSValue, String&);
     
    105105    void consumeBlob(FetchBodyOwner&, Ref<DeferredPromise>&&);
    106106
    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(); }
    115115
    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 };
    117117
    118118    FetchBodyConsumer m_consumer { FetchBodyConsumer::Type::None };
  • trunk/Source/WebCore/bindings/generic/IDLTypes.h

    r207462 r207517  
    116116
    117117template<typename... Ts>
    118 struct IDLUnion : IDLType<std::experimental::variant<typename Ts::ImplementationType...>> {
     118struct IDLUnion : IDLType<Variant<typename Ts::ImplementationType...>> {
    119119    using TypeList = brigand::list<Ts...>;
    120120};
  • trunk/Source/WebCore/dom/ExceptionOr.h

    r207384 r207517  
    4444
    4545private:
    46     std::experimental::variant<Exception, ReturnType> m_value;
     46    Variant<Exception, ReturnType> m_value;
    4747};
    4848
     
    7676template<typename ReturnType> inline bool ExceptionOr<ReturnType>::hasException() const
    7777{
    78     return std::experimental::holds_alternative<Exception>(m_value);
     78    return WTF::holds_alternative<Exception>(m_value);
    7979}
    8080
    8181template<typename ReturnType> inline Exception&& ExceptionOr<ReturnType>::releaseException()
    8282{
    83     return std::experimental::get<Exception>(WTFMove(m_value));
     83    return WTF::get<Exception>(WTFMove(m_value));
    8484}
    8585
    8686template<typename ReturnType> inline ReturnType&& ExceptionOr<ReturnType>::releaseReturnValue()
    8787{
    88     return std::experimental::get<ReturnType>(WTFMove(m_value));
     88    return WTF::get<ReturnType>(WTFMove(m_value));
    8989}
    9090
  • trunk/Source/WebCore/dom/MessageEvent.cpp

    r207505 r207517  
    178178    );
    179179
    180     return std::experimental::visit(visitor, m_source.value());
     180    return WTF::visit(visitor, m_source.value());
    181181}
    182182
  • trunk/Source/WebCore/dom/MessageEvent.h

    r207505 r207517  
    3939class Blob;
    4040
    41 using MessageEventSource = std::experimental::variant<RefPtr<DOMWindow>, RefPtr<MessagePort>>;
     41using MessageEventSource = Variant<RefPtr<DOMWindow>, RefPtr<MessagePort>>;
    4242
    4343class MessageEvent final : public Event {
  • trunk/Source/WebCore/dom/Node.cpp

    r207458 r207517  
    446446
    447447    for (const auto& variant : vector)
    448         std::experimental::visit(visitor, variant);
     448        WTF::visit(visitor, variant);
    449449
    450450    return nodeSet;
     
    483483
    484484    for (auto& variant : nodeOrStringVector)
    485         std::experimental::visit(visitor, variant);
     485        WTF::visit(visitor, variant);
    486486
    487487    if (nodes.size() == 1)
  • trunk/Source/WebCore/dom/Node.h

    r207458 r207517  
    6363class UIRequestEvent;
    6464
    65 using NodeOrString = std::experimental::variant<RefPtr<Node>, String>;
     65using NodeOrString = Variant<RefPtr<Node>, String>;
    6666
    6767class NodeRareDataBase {
  • trunk/Source/WebCore/html/HTMLOptionsCollection.h

    r207497 r207517  
    4242    HTMLOptionElement* namedItem(const AtomicString& name) const final;
    4343
    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>;
    4646    WEBCORE_EXPORT ExceptionOr<void> add(const OptionOrOptGroupElement&, Optional<HTMLElementOrInt> before);
    4747    WEBCORE_EXPORT void remove(int index);
  • trunk/Source/WebCore/html/HTMLSelectElement.cpp

    r207497 r207517  
    231231        );
    232232
    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& {
    236236        return *htmlElement;
    237237    }, element);
  • trunk/Source/WebCore/html/HTMLSelectElement.h

    r207497 r207517  
    5252    bool usesMenuList() const;
    5353
    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>;
    5656    WEBCORE_EXPORT ExceptionOr<void> add(const OptionOrOptGroupElement&, Optional<HTMLElementOrInt> before);
    5757
  • trunk/Source/WebCore/html/track/TrackEvent.cpp

    r207468 r207517  
    4444{
    4545    if (initializer.track) {
    46         m_track = std::experimental::visit([](const auto& trackbase) -> TrackBase* {
     46        m_track = WTF::visit([](const auto& trackbase) -> TrackBase* {
    4747            return trackbase.get();
    4848        }, *initializer.track);
  • trunk/Source/WebCore/html/track/TrackEvent.h

    r207468 r207517  
    4545    }
    4646
    47     using TrackEventTrack = std::experimental::variant<RefPtr<VideoTrack>, RefPtr<AudioTrack>, RefPtr<TextTrack>>;
     47    using TrackEventTrack = Variant<RefPtr<VideoTrack>, RefPtr<AudioTrack>, RefPtr<TextTrack>>;
    4848
    4949    struct Init : public EventInit {
  • trunk/Source/WebKit/mac/ChangeLog

    r207512 r207517  
     12016-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
    1142016-10-18  Simon Fraser  <simon.fraser@apple.com>
    215
  • trunk/Source/WebKit/mac/DOM/DOMHTMLSelectElement.mm

    r207497 r207517  
    186186
    187187    auto& coreElement = *core(element);
    188     std::experimental::variant<RefPtr<WebCore::HTMLOptionElement>, RefPtr<WebCore::HTMLOptGroupElement>> variantElement;
     188    Variant<RefPtr<WebCore::HTMLOptionElement>, RefPtr<WebCore::HTMLOptGroupElement>> variantElement;
    189189    if (is<WebCore::HTMLOptionElement>(coreElement))
    190190        variantElement = &downcast<WebCore::HTMLOptionElement>(coreElement);
  • trunk/Tools/ChangeLog

    r207512 r207517  
     12016-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
    1142016-10-18  Simon Fraser  <simon.fraser@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WTF/Variant.cpp

    r204493 r207517  
    3838TEST(WTF_Variant, Initial)
    3939{
    40     std::experimental::variant<int, double> v1;
     40    Variant<int, double> v1;
    4141    EXPECT_TRUE(v1.index() == 0);
    42     EXPECT_TRUE(std::experimental::get<int>(v1) == 0);
     42    EXPECT_TRUE(WTF::get<int>(v1) == 0);
    4343
    4444    struct T {
     
    4747    };
    4848
    49     std::experimental::variant<T, int> v2;
     49    Variant<T, int> v2;
    5050    EXPECT_TRUE(v2.index() == 0);
    51     EXPECT_TRUE(std::experimental::get<T>(v2).value == 15);
     51    EXPECT_TRUE(WTF::get<T>(v2).value == 15);
    5252}
    5353
    5454TEST(WTF_Variant, Basic)
    5555{
    56     std::experimental::variant<int, double> variant = 1;
     56    Variant<int, double> variant = 1;
    5757    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));
    6363
    6464    variant = 1.0;
    6565    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));
    7171}
    7272
     
    9595    Type type = Type::None;
    9696
    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);
    9999    EXPECT_TRUE(Type::Int == type);
    100100
    101101
    102102    variant = 1.0f;
    103     std::experimental::visit(Visitor(type), variant);
     103    WTF::visit(Visitor(type), variant);
    104104    EXPECT_TRUE(Type::Float == type);
    105105
    106106
    107107    variant = "hello";
    108     std::experimental::visit(Visitor(type), variant);
     108    WTF::visit(Visitor(type), variant);
    109109    EXPECT_TRUE(Type::String == type);
    110110}
     
    127127    );
    128128
    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);
    131131    EXPECT_TRUE(Type::Int == type);
    132132
    133133
    134134    variant = 1.0f;
    135     std::experimental::visit(visitor, variant);
     135    WTF::visit(visitor, variant);
    136136    EXPECT_TRUE(Type::Float == type);
    137137
    138138
    139139    variant = "hello";
    140     std::experimental::visit(visitor, variant);
     140    WTF::visit(visitor, variant);
    141141    EXPECT_TRUE(Type::String == type);
    142142}
     
    148148    {
    149149        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);
    151151
    152152        EXPECT_EQ(1u, ConstructorDestructorCounter::constructionCount);
     
    163163        RefLogger a("a");
    164164        RefPtr<RefLogger> ref(&a);
    165         std::experimental::variant<RefPtr<RefLogger>, int> v = ref;
     165        Variant<RefPtr<RefLogger>, int> v = ref;
    166166    }
    167167
     
    171171        RefLogger a("a");
    172172        RefPtr<RefLogger> ref(&a);
    173         std::experimental::variant<RefPtr<RefLogger>, int> v = WTFMove(ref);
     173        Variant<RefPtr<RefLogger>, int> v = WTFMove(ref);
    174174    }
    175175
     
    182182        RefLogger a("a");
    183183        Ref<RefLogger> ref(a);
    184         std::experimental::variant<Ref<RefLogger>, int> v = WTFMove(ref);
     184        Variant<Ref<RefLogger>, int> v = WTFMove(ref);
    185185    }
    186186
Note: See TracChangeset for help on using the changeset viewer.