Changeset ca8d393 in mainline


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

cpp: aux::value_is is now an alias to integral_constant for compatibility, added naive implementations of the last two typetraits make_signed and make_unsigned

Location:
uspace/lib/cpp/include
Files:
2 edited

Legend:

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

    rbfc972e rca8d393  
    4747    add_rvalue_reference_t<T> declval() noexcept;
    4848
    49     /**
    50      * 20.10.3, helper class:
    51      */
    52 
    53     template<class T, T v>
    54     struct integral_constant
    55     {
    56         static constexpr T value = v;
    57 
    58         using value_type = T;
    59         using type       = integral_constant<T, v>;
    60 
    61         constexpr operator value_type() const noexcept
    62         {
    63             return value;
    64         }
    65 
    66         constexpr value_type operator()() const noexcept
    67         {
    68             return value;
    69         }
    70     };
    71 
    72     using true_type = integral_constant<bool, true>;
    73     using false_type = integral_constant<bool, false>;
    74 
    7549    template<class...>
    7650    using void_t = void;
     
    959933    /**
    960934     * 20.10.7.3, sign modifications:
     935     * Note: These are fairly naive implementations that
     936     *       are meant to keep our code going (i.e. they work
     937     *       for the most common types, but I'm not sure
     938     *       if there are any intricacies required by
     939     *       the standard).
    961940     */
    962941
    963942    template<class T>
    964     struct make_signed;
    965 
    966     template<class T>
    967     struct make_unsigned;
     943    struct make_signed: aux::type_is<T>
     944    { /* DUMMY BODY */ };
     945
     946    template<>
     947    struct make_signed<unsigned char>: aux::type_is<signed char>
     948    { /* DUMMY BODY */ };
     949
     950    template<>
     951    struct make_signed<unsigned short>: aux::type_is<short>
     952    { /* DUMMY BODY */ };
     953
     954    template<>
     955    struct make_signed<unsigned int>: aux::type_is<int>
     956    { /* DUMMY BODY */ };
     957
     958    template<>
     959    struct make_signed<unsigned long>: aux::type_is<long>
     960    { /* DUMMY BODY */ };
     961
     962    template<>
     963    struct make_signed<unsigned long long>: aux::type_is<long long>
     964    { /* DUMMY BODY */ };
     965
     966    template<class T>
     967    struct make_unsigned: aux::type_is<T>
     968    { /* DUMMY BODY */ };
     969
     970    template<>
     971    struct make_unsigned<signed char>: aux::type_is<unsigned char>
     972    { /* DUMMY BODY */ };
     973
     974    template<>
     975    struct make_unsigned<short>: aux::type_is<unsigned short>
     976    { /* DUMMY BODY */ };
     977
     978    template<>
     979    struct make_unsigned<int>: aux::type_is<unsigned int>
     980    { /* DUMMY BODY */ };
     981
     982    template<>
     983    struct make_unsigned<long>: aux::type_is<unsigned long>
     984    { /* DUMMY BODY */ };
     985
     986    template<>
     987    struct make_unsigned<long long>: aux::type_is<unsigned long long>
     988    { /* DUMMY BODY */ };
    968989
    969990    template<class T>
  • uspace/lib/cpp/include/internal/aux.hpp

    rbfc972e rca8d393  
    3030#define LIBCPP_AUX
    3131
     32namespace std
     33{
     34    /**
     35     * 20.10.3, helper class:
     36     */
     37
     38    template<class T, T v>
     39    struct integral_constant
     40    {
     41        static constexpr T value = v;
     42
     43        using value_type = T;
     44        using type       = integral_constant<T, v>;
     45
     46        constexpr operator value_type() const noexcept
     47        {
     48            return value;
     49        }
     50
     51        constexpr value_type operator()() const noexcept
     52        {
     53            return value;
     54        }
     55    };
     56
     57    using true_type = integral_constant<bool, true>;
     58    using false_type = integral_constant<bool, false>;
     59}
     60
    3261namespace std::aux
    3362{
     
    5584    };
    5685
     86    // For compatibility with integral_constant.
    5787    template<class T, T v>
    58     struct value_is
    59     {
    60         static constexpr T value = v;
    61     };
     88    using value_is = std::integral_constant<T, v>;
    6289}
    6390
Note: See TracChangeset for help on using the changeset viewer.