Changeset 7e7c1aac in mainline


Ignore:
Timestamp:
2018-07-05T21:41:20Z (6 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
40340461
Parents:
9283830
git-author:
Dzejrou <dzejrou@…> (2018-03-28 14:22:16)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:20)
Message:

cpp: added more type traits

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/impl/type_traits.hpp

    r9283830 r7e7c1aac  
    3636namespace std
    3737{
     38    template<class T>
     39    struct add_rvalue_reference;
     40
     41    template<class T>
     42    using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
     43
     44    template<class T>
     45    add_rvalue_reference_t<T> declval() noexcept;
     46
    3847    /**
    3948     * 20.10.3, helper class:
     
    6170    using true_type = integral_constant<bool, true>;
    6271    using false_type = integral_constant<bool, false>;
     72
     73    template<class...>
     74    using void_t = void;
    6375
    6476    template<class>
     
    782794    inline constexpr bool is_base_of_v = is_base_of<Base, Derived>::value;
    783795
     796    template<class From, class To, class = void>
     797    struct is_convertible: false_type
     798    { /* DUMMY BODY */ };
     799
    784800    template<class From, class To>
    785     struct is_convertible;
     801    struct is_convertible<From, To, void_t<decltype((To)declval<From>())>>
     802        : true_type
     803    { /* DUMMY BODY */ };
     804
     805    template<class From, class To>
     806    inline constexpr bool is_convertible_v = is_convertible<From, To>::value;
    786807
    787808    /**
     
    867888    { /* DUMMY BODY */ };
    868889
    869     template<class T>
    870     struct add_lvalue_reference;
     890    // TODO: is this good?
     891    template<class T>
     892    struct add_lvalue_reference: aux::type_is<T&>
     893    { /* DUMMY BODY */ };
    871894
    872895    // TODO: Special case when T is not referencable!
     
    909932
    910933    template<class T>
    911     struct remove_extent;
     934    struct remove_extent: aux::type_is<T>
     935    { /* DUMMY BODY */ };
     936
     937    template<class T>
     938    struct remove_extent<T[]>: aux::type_is<T>
     939    { /* DUMMY BODY */ };
     940
     941    template<class T, size_t N>
     942    struct remove_extent<T[N]>: aux::type_is<T>
     943    { /* DUMMY BODY */ };
    912944
    913945    template<class T>
     
    925957
    926958    template<class T>
    927     struct remove_pointer;
     959    struct remove_pointer: aux::type_is<T>
     960    { /* DUMMY BODY */ };
     961
     962    template<class T>
     963    struct remove_pointer<T*>: aux::type_is<T>
     964    { /* DUMMY BODY */ };
     965
     966    template<class T>
     967    struct remove_pointer<T* const>: aux::type_is<T>
     968    { /* DUMMY BODY */ };
     969
     970    template<class T>
     971    struct remove_pointer<T* volatile>: aux::type_is<T>
     972    { /* DUMMY BODY */ };
     973
     974    template<class T>
     975    struct remove_pointer<T* const volatile>: aux::type_is<T>
     976    { /* DUMMY BODY */ };
    928977
    929978    template<class T>
     
    939988     * 20.10.7.6, other transformations:
    940989     */
    941 
    942     template<class...>
    943     using void_t = void;
    944990
    945991    // TODO: consult standard on the default value of align
Note: See TracChangeset for help on using the changeset viewer.