Boost logo

Boost :

Subject: Re: [boost] Visual Studio 2015 Update 3 has removed std::unary_function and std::binary_function
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2016-11-05 17:56:37


On Sat, Nov 5, 2016 at 1:00 PM, Robert Ramey <ramey_at_[hidden]> wrote:

> On 11/5/16 12:44 PM, Зайцев Александр wrote:
>
>> For Boost.Algorithm we can remove all std::unary_function and
>> std::binary_function. I think, we can rewrite sources without these
>> functions.
>>
>>
> I'm guessing that could be done for all the libraries. But would that
> permit the usage of the libraries by those who depend upon C++03 compilers?
>

I don't think there's anything in boost (or the standard library) that
depends specifically on std::unary_function. (except TR1) Here's the
definition:

template <class _Arg, class _Result>
struct unary_function
{
typedef _Arg argument_type;
typedef _Result result_type;
};

template <class _Arg1, class _Arg2, class _Result>
struct binary_function
{
typedef _Arg1 first_argument_type;
typedef _Arg2 second_argument_type;
typedef _Result result_type;
};

However, I am pretty sure that there are parts of boost and/or the standard
library that depend on the presence of (say) result_type:

For example, I found this in
libs/accumulators/include/boost/accumulators/statistics/kurtosis.hpp:

        typedef typename numeric::functional::fdiv<Sample,
Sample>::result_type result_type;

The #2 option I suggested would look like this. change:

template<typename T>
struct plus: binary_function<T, T, T>
{
T operator() (const T& x, const T& y) { return x + y }
};

to:

  template<typename T>
struct plus
{
typedef T first_argument_type;
typedef T second_argument_type;
typedef T result_type;
T operator() (const T& x, const T& y) { return x + y }
};

-- Marshall


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk