Boost logo

Boost :

Subject: [boost] [fusion] Trouble using BOOST_FUSION_ADAPT_ADT with boost::fusion::operator<
From: GOODHART, TAYLOR (TAYLOR_GOODHART_at_[hidden])
Date: 2012-01-17 13:28:47


Hi all,

 

  I'm attempting to adapt a third-party struct into a fusion sequence
using BOOST_FUSION_ADAPT_ADT to get access to a nice operator<.
Unfortunately compilation fails and I'm not sure if it's a bug or me
using the library incorrectly. As best I can read the error message, it
looks like the code is attempting to compare adt_attribute_proxy structs
instead of the values represented by these. Below is some code that
demonstrates the problem. Can anybody help me out?

 

Thanks,

Taylor

 

#include <boost/fusion/adapted/adt/adapt_adt.hpp>

#include <boost/fusion/adapted/struct/define_struct.hpp>

#include <boost/fusion/adapted/struct/adapt_struct.hpp>

#include <set>

#include <string>

#include <boost/fusion/sequence/comparison/less.hpp>

 

struct test1

{

    std::string s;

    const std::string & getS() const

    {

        return s;

    }

    void setS(

        const std::string & s_)

    {

        s = s_;

    }

};

 

BOOST_FUSION_ADAPT_ADT(

        test1,

        (const std::string &, const std::string &, obj.getS(),
obj.setS(val))

)

 

BOOST_FUSION_DEFINE_STRUCT(

        , test2,

        (std::string, s)

        (int, a)

)

 

struct test3

{

    std::string s;

};

 

BOOST_FUSION_ADAPT_STRUCT(

        test3,

        (std::string, s)

)

 

using boost::fusion::operator<;

 

int main(

    int argc,

    char * argv[])

{

    //Fails

    /*std::set<test1> destinations1;

     destinations1.insert(test1());*/

 

    std::set<test2> destinations2;

    destinations2.insert(test2());

 

    std::set<test3> destinations3;

    destinations3.insert(test3());

    return 0;

}


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