Boost logo

Boost :

Subject: Re: [boost] New libraries implementing C++11 features in C++03
From: Christopher Jefferson (chris_at_[hidden])
Date: 2011-11-25 08:21:22


On 25 Nov 2011, at 12:24, Joel de Guzman wrote:

> On 11/25/2011 7:16 PM, Christopher Jefferson wrote:
>>
>> You seem simply unwilling to accept that there are people who refuse to use Pheonix,
>> and libraries built on it because:
>>
>> 1) It leads to horribly large compile times.
>> 2) Error messages. I know you hate this, so let me write out my opinion one last time.
>>
>> Phoenix leads to error messages which:
>> * On the compilers I commonly use - I can't change this, there aren't that many
>> compilers around.
>> * Are very, very large
>> * and require different skills to read and understand than any other library.
>
> Ok, let's put that to a test.

Sorry to ask you another problem, but could you try another test?

The following code shows a small example, which comes from a real program of mine. I have changed my old out-of-line code to use boost local. Note that in practice there are many different types which implement my 'vars' interface (getMax/getMin/setMax/setMin).

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include "local/boost/local/function.hpp"

template<typename T>
struct Var
{
    void setMax(int i) {}
    void setMin(int i) {}
    int getMax() { return 0; }
    int getMin() { return 0; }
};

template<typename T>
void squeeze_vars_local(std::vector<T>& vec, int i)
{
  
    void BOOST_LOCAL_FUNCTION_PARAMS_TPL(T& t, bind i)
    {
        t.first.setMax(t.second.getMax() - i);
        t.second.setMin(t.first.getMin() + i);
    } BOOST_LOCAL_FUNCTION_NAME(squeeze);

    std::for_each(vec.begin(), vec.end(), squeeze);
}

int main(void)
{
    std::vector<std::pair<Var<int>, Var<double> > > v;
    squeeze_vars_local(v,2);
}

In the past I tried turning this into phoenix code, and failed. I'd be genuinely interested to know what it would look like as a phoenix function.

Chris


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