Ignore:
Timestamp:
2019-07-01T15:33:01Z (5 years ago)
Author:
Jaroslav Jindrak <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8660ad0
Parents:
a552044
Message:

cpp: remove redundant specializations of shared_future using some metaprogramming tricks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/__bits/thread/future_common.hpp

    ra552044 ra6c3bf3  
    3030#define LIBCPP_BITS_THREAD_FUTURE_COMMON
    3131
     32#include <__bits/aux.hpp>
    3233#include <system_error>
    3334#include <stdexcept>
     
    8283            error_code code_;
    8384    };
     85
     86    namespace aux
     87    {
     88        /**
     89         * Auxilliary metafunctions that let us avoid
     90         * specializations in some cases. They represent
     91         * the inner stored type and the return type of
     92         * the get() member function, respectively.
     93         */
     94
     95        template<class T>
     96        struct future_inner: aux::type_is<T>
     97        { /* DUMMY BODY */ };
     98
     99        template<class T>
     100        struct future_inner<T&>: aux::type_is<T*>
     101        { /* DUMMY BODY */ };
     102
     103        template<class T>
     104        using future_inner_t = typename future_inner<T>::type;
     105
     106        template<class T>
     107        struct future_return: aux::type_is<const T&>
     108        { /* DUMMY BODY */ };
     109
     110        template<class T>
     111        struct future_return<T&>: aux::type_is<T&>
     112        { /* DUMMY BODY */ };
     113
     114        template<>
     115        struct future_return<void>: aux::type_is<void>
     116        { /* DUMMY BODY */ };
     117
     118        template<class T>
     119        using future_return_t = typename future_return<T>::type;
     120    }
    84121}
    85122
Note: See TracChangeset for help on using the changeset viewer.