Changeset 08c1df0 in mainline for uspace/lib/cpp/include/internal


Ignore:
Timestamp:
2018-07-05T21:41:24Z (7 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f31ea60
Parents:
ca8d393
git-author:
Dzejrou <dzejrou@…> (2018-05-16 17:20:56)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:24)
Message:

cpp: fixed typedefs in allocator_traits, finished type getters and implemented conditional calls in allocator_traits

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/internal/memory/type_getters.hpp

    rca8d393 r08c1df0  
    9898
    9999    template<class T, class = void>
    100     struct get_pointer: aux::type_is<typename T::value_type*>
    101     { /* DUMMY BODY */ };
    102 
    103     template<class T>
    104     struct get_pointer<T, void_t<typename T::pointer>>
     100    struct alloc_get_pointer: aux::type_is<typename T::value_type*>
     101    { /* DUMMY BODY */ };
     102
     103    template<class T>
     104    struct alloc_get_pointer<T, void_t<typename T::pointer>>
    105105        : aux::type_is<typename T::pointer>
    106106    { /* DUMMY BODY */ };
    107107
    108108    template<class T, class Ptr, class = void>
    109     struct get_const_pointer
     109    struct alloc_get_const_pointer
    110110        : aux::type_is<typename pointer_traits<Ptr>::template rebind<const typename T::value_type>>
    111111    { /* DUMMY BODY */ };
    112112
    113113    template<class T, class Ptr>
    114     struct get_const_pointer<T, Ptr, void_t<typename T::const_pointer>>
     114    struct alloc_get_const_pointer<T, Ptr, void_t<typename T::const_pointer>>
    115115        : aux::type_is<typename T::const_pointer>
    116116    { /* DUMMY BODY */ };
    117117
    118118    template<class T, class Ptr, class = void>
    119     struct get_void_pointer
     119    struct alloc_get_void_pointer
    120120        : aux::type_is<typename pointer_traits<Ptr>::template rebind<void>>
    121121    { /* DUMMY BODY */ };
    122122
    123123    template<class T, class Ptr>
    124     struct get_void_pointer<T, Ptr, void_t<typename T::void_pointer>>
     124    struct alloc_get_void_pointer<T, Ptr, void_t<typename T::void_pointer>>
    125125        : aux::type_is<typename T::void_pointer>
    126126    { /* DUMMY BODY */ };
    127127
    128128    template<class T, class Ptr, class = void>
    129     struct get_const_void_pointer
     129    struct alloc_get_const_void_pointer
    130130        : aux::type_is<typename pointer_traits<Ptr>::template rebind<const void>>
    131131    { /* DUMMY BODY */ };
    132132
    133133    template<class T, class Ptr>
    134     struct get_const_void_pointer<T, Ptr, void_t<typename T::const_void_pointer>>
     134    struct alloc_get_const_void_pointer<T, Ptr, void_t<typename T::const_void_pointer>>
    135135        : aux::type_is<typename T::const_void_pointer>
    136136    { /* DUMMY BODY */ };
    137137
    138138    template<class T, class Ptr, class = void>
    139     struct get_difference_type
     139    struct alloc_get_difference_type
    140140        : aux::type_is<typename pointer_traits<Ptr>::difference_type>
    141141    { /* DUMMY BODY */ };
    142142
    143143    template<class T, class Ptr>
    144     struct get_difference_type<T, Ptr, void_t<typename T::difference_type>>
     144    struct alloc_get_difference_type<T, Ptr, void_t<typename T::difference_type>>
    145145        : aux::type_is<typename T::difference_type>
    146146    { /* DUMMY BODY */ };
    147147
    148148    template<class T, class Difference, class = void>
    149     struct get_size_type: aux::type_is<make_unsigned_t<Difference>>
     149    struct alloc_get_size_type: aux::type_is<make_unsigned_t<Difference>>
    150150    { /* DUMMY BODY */ };
    151151
    152152    template<class T, class Difference>
    153     struct get_size_type<T, Difference, void_t<typename T::size_type>>
     153    struct alloc_get_size_type<T, Difference, void_t<typename T::size_type>>
    154154        : aux::type_is<typename T::size_type>
    155155    { /* DUMMY BODY */ };
    156156
    157157    template<class T, class = void>
    158     struct get_copy_propagate: aux::type_is<false_type>
    159     { /* DUMMY BODY */ };
    160 
    161     template<class T>
    162     struct get_copy_propagate<T, void_t<typename T::propagate_on_container_copy_assignment>>
     158    struct alloc_get_copy_propagate: aux::type_is<false_type>
     159    { /* DUMMY BODY */ };
     160
     161    template<class T>
     162    struct alloc_get_copy_propagate<T, void_t<typename T::propagate_on_container_copy_assignment>>
    163163        : aux::type_is<typename T::propagate_on_container_copy_assignment>
    164164    { /* DUMMY BODY */ };
    165165
    166166    template<class T, class = void>
    167     struct get_move_propagate: aux::type_is<false_type>
    168     { /* DUMMY BODY */ };
    169 
    170     template<class T>
    171     struct get_move_propagate<T, void_t<typename T::propagate_on_container_move_assignment>>
     167    struct alloc_get_move_propagate: aux::type_is<false_type>
     168    { /* DUMMY BODY */ };
     169
     170    template<class T>
     171    struct alloc_get_move_propagate<T, void_t<typename T::propagate_on_container_move_assignment>>
    172172        : aux::type_is<typename T::propagate_on_container_move_assignment>
    173173    { /* DUMMY BODY */ };
    174174
    175175    template<class T, class = void>
    176     struct get_swap_propagate: aux::type_is<false_type>
    177     { /* DUMMY BODY */ };
    178 
    179     template<class T>
    180     struct get_swap_propagate<T, void_t<typename T::propagate_on_container_swap>>
     176    struct alloc_get_swap_propagate: aux::type_is<false_type>
     177    { /* DUMMY BODY */ };
     178
     179    template<class T>
     180    struct alloc_get_swap_propagate<T, void_t<typename T::propagate_on_container_swap>>
    181181        : aux::type_is<typename T::propagate_on_container_swap>
    182182    { /* DUMMY BODY */ };
    183183
    184184    template<class T, class = void>
    185     struct get_always_equal: aux::type_is<typename is_empty<T>::type>
    186     { /* DUMMY BODY */ };
    187 
    188     template<class T>
    189     struct get_always_equal<T, void_t<typename T::is_always_equal>>
     185    struct alloc_get_always_equal: aux::type_is<typename is_empty<T>::type>
     186    { /* DUMMY BODY */ };
     187
     188    template<class T>
     189    struct alloc_get_always_equal<T, void_t<typename T::is_always_equal>>
    190190        : aux::type_is<typename T::is_always_equal>
    191191    { /* DUMMY BODY */ };
    192192
    193193    template<class Alloc, class T, class = void>
    194     struct get_rebind_other
     194    struct alloc_get_rebind_alloc
    195195    { /* DUMMY BODY */ };
    196196
    197197    template<class Alloc, class T>
    198     struct get_rebind_other<Alloc, T, void_t<typename Alloc::template rebind<T>::other>>
     198    struct alloc_get_rebind_alloc<Alloc, T, void_t<typename Alloc::template rebind<T>::other>>
    199199        : aux::type_is<typename Alloc::template rebind<T>::other>
    200200    { /* DUMMY BODY */ };
    201201
    202     /* TODO: How am I suppose to do this?!
    203     template<template<class T, class... Args> class Alloc>
    204     struct get_rebind_args;
    205     */
     202    template<template <class, class...> class Alloc, class U, class... Args, class T>
     203    struct alloc_get_rebind_alloc<Alloc<U, Args...>, T>
     204        : aux::type_is<Alloc<T, Args...>>
     205    { /* DUMMY BODY */ };
     206
     207    /**
     208     * These metafunctions are used to check whether an expression
     209     * is well-formed for the static functions of allocator_traits:
     210     */
     211
     212    template<class Alloc, class Size, class ConstVoidPointer, class = void>
     213    struct alloc_has_hint_allocate: false_type
     214    { /* DUMMY BODY */ };
     215
     216    template<class Alloc, class Size, class ConstVoidPointer>
     217    struct alloc_has_hint_allocate<
     218        Alloc, Size, ConstVoidPointer, void_t<
     219            decltype(declval<Alloc>().alloc(declval<Size>(), declval<ConstVoidPointer>()))
     220        >
     221    >: true_type
     222    { /* DUMMY BODY */ };
     223
     224    template<class, class Alloc, class T, class... Args>
     225    struct alloc_has_construct_impl: false_type
     226    { /* DUMMY BODY */ };
     227
     228    template<class Alloc, class T, class... Args>
     229    struct alloc_has_construct_impl<
     230        void_t<decltype(declval<Alloc>().construct(declval<T*>(), forward<Args>(declval<Args>())...))>,
     231        Alloc, T, Args...
     232    >: true_type
     233    { /* DUMMY BODY */ };
     234
     235    template<class Alloc, class T, class = void>
     236    struct alloc_has_destroy: false_type
     237    { /* DUMMY BODY */ };
    206238
    207239    template<class Alloc, class T>
    208     struct get_rebind_args: aux::type_is<typename get_rebind_other<Alloc, T>::type>
     240    struct alloc_has_destroy<Alloc, T, void_t<decltype(declval<Alloc>().destroy(declval<T>()))>>
     241        : true_type
     242    { /* DUMMY BODY */ };
     243
     244    template<class Alloc, class T, class... Args>
     245    struct alloc_has_construct
     246        : alloc_has_construct_impl<void_t<>, Alloc, T, Args...>
     247    { /* DUMMY BODY */ };
     248
     249    template<class Alloc, class = void>
     250    struct alloc_has_max_size: false_type
     251    { /* DUMMY BODY */ };
     252
     253    template<class Alloc>
     254    struct alloc_has_max_size<Alloc, void_t<decltype(declval<Alloc>().max_size())>>
     255        : true_type
     256    { /* DUMMY BODY */ };
     257
     258    template<class Alloc, class = void>
     259    struct alloc_has_select: false_type
     260    { /* DUMMY BODY */ };
     261
     262    template<class Alloc>
     263    struct alloc_has_select<
     264        Alloc, void_t<
     265            decltype(declval<Alloc>().select_on_container_copy_construction())
     266        >
     267    >: true_type
    209268    { /* DUMMY BODY */ };
    210269}
Note: See TracChangeset for help on using the changeset viewer.