Thanks, added ticket 3322

Mike

On Wed, Aug 5, 2009 at 11:47 PM, Christopher Schmidt <mr.chr.schmidt@online.de> wrote:
I am pretty sure this is a bug. The cv-ness of a certain fusion type should not be relevant in this particular case.

You can identify adapted structs by their fusion::struct_tag - tag.

-C.

Mike Tegtmeyer schrieb:
I seem to have found an inconsistency in how fusion::find works with fusion::vector and an adapted struct. Basically, attempting to find a non-const type on a const vector with a non-const member works but requires a const-member find for an adapted struct. (See code below). Is this something that was just overlooked or there a technical reason for this behavior. In any case is there some way to identify a adapted struct in the general case (as apposed to the tag of the specific type) that can be used for a workaround?

Thanks in advance,
Mike

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

#include <boost/fusion/container/vector/vector.hpp>

#include <boost/fusion/algorithm/query/find.hpp>


#include <boost/type_traits.hpp>


#include <string>

#include <iostream>


namespace b = boost;

namespace bf = boost::fusion;


namespace demo

{

   struct employee

   {

       std::string name;

       int age;

   };

}


// demo::employee is now a Fusion sequence

BOOST_FUSION_ADAPT_STRUCT(

   demo::employee,

   (std::string, name)

   (int, age))


int main(void)

{

 typedef bf::vector<int,float> V1;

 
 // Find against non-const V1

 V1 v1(1,2.0);


 BOOST_MPL_ASSERT_NOT(( b::is_same<bf::result_of::find<V1,int>::type,bf::result_of::end<V1>::type> ));


 assert(*bf::find<int>(v1) == 1);



 // Find against const V1

 const V1 const_v1(3,4.0);


 BOOST_MPL_ASSERT_NOT(( b::is_same<bf::result_of::find<const V1,int>::type,bf::result_of::end<const V1>::type> ));


 assert(*bf::find<int>(const_v1) == 3);


 // Find against non-const employee

 demo::employee e1 = {"Foo",18};


 BOOST_MPL_ASSERT_NOT(( b::is_same<bf::result_of::find<demo::employee,int>::type,bf::result_of::end<demo::employee>::type> ));


 assert(*bf::find<int>(e1) == 18);


 // Find against const employee

 const demo::employee const_e1 = {"Bar",21};


#if 0

 BOOST_MPL_ASSERT_NOT(( b::is_same<bf::result_of::find<const demo::employee,int>::type,bf::result_of::end<const demo::employee>::type> ));


 assert(*bf::find<int>(const_e1) == 21);

#else

 // note that the find key is a const int for this to work and is inconsistent with fusion::vector

 BOOST_MPL_ASSERT_NOT(( b::is_same<bf::result_of::find<const demo::employee,const int>::type,bf::result_of::end<const demo::employee>::type> ));


 assert(*bf::find<const int>(const_e1) == 21);

#endif


 return 0;

}


------------------------------------------------------------------------

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users