Changeset add816c7 in mainline


Ignore:
Timestamp:
2018-07-05T21:41:17Z (6 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7e91e0f
Parents:
2841b4f
git-author:
Jaroslav Jindrak <dzejrou@…> (2017-10-13 19:48:41)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:17)
Message:

cpp: reordered functions to avoid forward declaration, removed redundant std:: specifiers

File:
1 edited

Legend:

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

    r2841b4f radd816c7  
    6262
    6363    /**
     64     * 20.2.4, forward/move helpers:
     65     */
     66
     67    template<class T>
     68    inline constexpr T&& forward(remove_reference_t<T>& t) noexcept
     69    {
     70        return static_cast<T&&>(t);
     71    }
     72
     73    template<class T>
     74    inline constexpr T&& forward(remove_reference_t<T>&& t) noexcept
     75    {
     76        // TODO: check if t is lvalue reference, if it is, the program
     77        //       is ill-formed according to the standard
     78        return static_cast<T&&>(t);
     79    }
     80
     81    template<class T>
     82    inline constexpr remove_reference_t<T>&& move(T&& t) noexcept
     83    {
     84        return static_cast<remove_reference_t<T>&&>(t);
     85    }
     86
     87    /**
    6488     * 20.2.2, swap:
    6589     */
     
    7094                 is_nothrow_move_assignable<T>::value)
    7195    {
    72         T tmp{std::move(x)};
    73         x = std::move(y);
    74         y = std::move(tmp);
     96        T tmp{move(x)};
     97        x = move(y);
     98        y = move(tmp);
    7599    }
    76100
     
    88112    T exchange(T& obj, U&& new_val)
    89113    {
    90         T old_val = std::move(obj);
    91         obj = std::forward<U>(new_val);
     114        T old_val = move(obj);
     115        obj = forward<U>(new_val);
    92116
    93117        return old_val;
    94     }
    95 
    96     /**
    97      * 20.2.4, forward/move helpers:
    98      */
    99 
    100     template<class T>
    101     inline constexpr T&& forward(remove_reference_t<T>& t) noexcept
    102     {
    103         return static_cast<T&&>(t);
    104     }
    105 
    106     template<class T>
    107     inline constexpr T&& forward(remove_reference_t<T>&& t) noexcept
    108     {
    109         // TODO: check if t is lvalue reference, if it is, the program
    110         //       is ill-formed according to the standard
    111         return static_cast<T&&>(t);
    112     }
    113 
    114     template<class T>
    115     inline constexpr remove_reference_t<T>&& move(T&& t) noexcept
    116     {
    117         return static_cast<remove_reference_t<T>&&>(t);
    118118    }
    119119
Note: See TracChangeset for help on using the changeset viewer.