Changeset 800968b7 in mainline


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

cpp: added support for reference_wrapper to bind

File:
1 edited

Legend:

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

    ra30c04d r800968b7  
    11441144        };
    11451145
     1146        template<class F, class... Args>
     1147        class bind_t;
     1148
    11461149        template<class... Args>
    11471150        class bind_arg_filter
     
    11521155                { /* DUMMY BODY */ }
    11531156
    1154                 // TODO: enable if T != ref_wrapper
    11551157                template<class T>
    11561158                constexpr decltype(auto) operator[](T&& t)
     
    11611163                template<int N>
    11621164                constexpr decltype(auto) operator[](const placeholder_t<N>)
    1163                 {
     1165                { // Since placeholders are constexpr, this is the best match for them.
    11641166                    /**
    11651167                     * Come on, it's int! Why not use -1 as not placeholder
    11661168                     * and start them at 0? -.-
    11671169                     */
    1168                     /* return get<is_placeholder_v<decay_t<T>> - 1>(args_); */
    11691170                    return get<N - 1>(args_);
    11701171                }
    11711172
    1172                 // TODO: overload the operator for reference_wrapper
     1173                template<class T>
     1174                constexpr T& operator[](reference_wrapper<T> ref)
     1175                {
     1176                    return ref.get();
     1177                }
     1178
     1179                template<class F, class... BindArgs>
     1180                constexpr decltype(auto) operator[](const bind_t<F, BindArgs...> b)
     1181                {
     1182                    return b; // TODO: bind subexpressions
     1183                }
     1184
    11731185
    11741186            private:
     
    11811193            // TODO: conditional typedefs
    11821194            public:
     1195                // TODO: T& gets captured by ref, should be by value :/
    11831196                template<class... BoundArgs>
    11841197                constexpr bind_t(F&& f, BoundArgs&&... args)
     
    11861199                      bound_args_{forward<BoundArgs>(args)...}
    11871200                { /* DUMMY BODY */ }
     1201
     1202                constexpr bind_t(const bind_t& other) = default;
     1203                constexpr bind_t(bind_t&& other) = default;
    11881204
    11891205                template<class... ActualArgs>
Note: See TracChangeset for help on using the changeset viewer.