This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Remove algo duplication
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: libstdc++ at gcc dot gnu dot org, Christopher Jefferson <chris at bubblescope dot net>, François Dumont <frs dot dumont at gmail dot com>
- Date: Mon, 16 Sep 2013 22:46:55 +0200 (CEST)
- Subject: Re: Remove algo duplication
- Authentication-results: sourceware.org; auth=none
- References: <52264074 dot 2050502 at gmail dot com> <alpine dot DEB dot 2 dot 10 dot 1309081625460 dot 3536 at laptop-mg dot saclay dot inria dot fr> <522E246F dot 5040608 at gmail dot com> <E2836BBC-F90D-4AE5-AAAB-EB3242BF030D at oracle dot com> <CA+jCFLtpCASpP1NTru=__hOQo5O-uj0m82YDqmB2wBYxspcQxA at mail dot gmail dot com> <alpine dot DEB dot 2 dot 10 dot 1309151125180 dot 3593 at laptop-mg dot saclay dot inria dot fr> <CA+jCFLsgUS3x0AVQDvn1OUgkYt6EJJojUrL4xrtVo9XQwq8J6A at mail dot gmail dot com> <alpine dot DEB dot 2 dot 10 dot 1309161348100 dot 3698 at laptop-mg dot saclay dot inria dot fr> <523706CD dot 5060707 at oracle dot com> <alpine dot DEB dot 2 dot 10 dot 1309161636200 dot 3698 at laptop-mg dot saclay dot inria dot fr> <52371F6F dot 80409 at oracle dot com>
- Reply-to: libstdc++ at gcc dot gnu dot org
On Mon, 16 Sep 2013, Paolo Carlini wrote:
On 09/16/2013 04:54 PM, Marc Glisse wrote:
By the way, I thought someone had contributed less<void> and the others
already, but I can't see them. Did I imagine that patch?
Humm, I guess so :-) Jon has definitely some work in the making but I don't
think he mentioned it. Thus, I suppose we are looking for volunteers ;)
How much do you hate macros? What would you think of something like this
(with better macro names)? Does this C++03 emulation even make sense?
(not sure how to handle doxygen with this)
#if __cplusplus >= 201103L
#define _DECL(OP) \
template <class T, class U> auto operator()(T&& t, U&& u) const \
-> decltype(std::forward<T>(t) OP std::forward<U>(u)) \
{ return std::forward<T>(t) OP std::forward<U>(u); }
#else
#define _HELP(OP, D) \
D(OP,,) D(OP,,const) D(OP,,volatile) D(OP,,const volatile) \
D(OP,const,) D(OP,const,const) \
D(OP,const,volatile) D(OP,const,const volatile) \
D(OP,volatile,) D(OP,volatile,const) \
D(OP,volatile,volatile) D(OP,volatile,const volatile) \
D(OP,const volatile,) D(OP,const volatile,const) \
D(OP,const volatile,volatile) D(OP,const volatile,const volatile)
#define _FUN(OP, CV1, CV2) \
template<class T, class U> bool operator()(T CV1& t, U CV2& u) const \
{ return static_cast<bool>(t OP u); }
#define _DECL(OP) _HELP(OP, _FUN)
#endif
#define _TOT(NAME, OP) \
template<typename _Tp = void> \
struct NAME : public binary_function<_Tp, _Tp, bool> \
{ \
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x OP __y; } \
}; \
template <> struct NAME<void> { \
_DECL(OP) \
typedef void is_transparent; \
};
_TOT(equal_to,==)
_TOT(not_equal_to,!=)
_TOT(greater,>)
_TOT(less,<)
_TOT(greater_equal,>=)
_TOT(less_equal,<=)
#undef _TOT
#undef _FUN
#undef _HELP
#undef _DECL
--
Marc Glisse