Boost logo

Boost Users :

Subject: [Boost-users] flyweight with fusion::map = error C3066
From: Cote, Francois (SGBM) (Francois.Cote_at_[hidden])
Date: 2010-05-04 12:57:57


Dear All,

 

I'm trying to create a composite structure of flyweight inspired by the
example boost_1_41_0\libs\flyweight\example\composite.cpp.

 

However, I need the leaf of my composite pattern to be a
boost::fusion::map type. I'm getting the following error:

 

\boost\variant\variant.hpp(825) : error C3066: there are multiple ways
that an object of this type can be called with these arguments

 

Is there any fundamental reason why the following code generate this
error? The code compile when the leaf is a "struct" type rather than
boost::fusion::map type.

 

Regards

Francois

 

 

 

#include <boost/flyweight.hpp>

#include <boost/functional/hash.hpp>

#include <boost/variant.hpp>

#include <boost/variant/apply_visitor.hpp>

#include <boost/variant/recursive_wrapper.hpp>

#include <boost/fusion/sequence.hpp>

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

#include <iostream>

#include <string>

#include <vector>

 

using namespace boost::flyweights;

using boost::fusion::pair;

using boost::fusion::make_pair;

using boost::fusion::at_key;

 

// using boost::fusion::map

namespace leaf_key

{

    struct label;

}

typedef boost::fusion::map<pair<leaf_key::label,std::string>> leaf;

 

struct portfolio;

 

typedef boost::variant<leaf,boost::recursive_wrapper<portfolio>>
portfolio_variant;

 

typedef boost::flyweights::flyweight<portfolio_variant> portfolio_node;

 

struct portfolio:std::vector<portfolio_node>{};

 

struct portfolio_hasher: boost::static_visitor<std::size_t>

{

   std::size_t operator()(const leaf& f )const

   {

      boost::hash<std::string> h;

      // using boost::fusion::map

      std::string str = at_key<leaf_key::label>(f);

      // using struct

      //std::string str = f.label;

      return h(str);

   }

 

   std::size_t operator()(const boost::recursive_wrapper<portfolio>&
pf_w)const

   {

      const portfolio& pf=pf_w.get();

      std::size_t res=0;

       for(portfolio::const_iterator
it=pf.begin(),it_end=pf.end();it!=it_end;++it)

      {

         const portfolio_variant* p=&it->get();

         boost::hash_combine(res,p);

      }

      return res;

   }

};

 

std::size_t hash_value(const portfolio_variant& node)

{

   return boost::apply_visitor(portfolio_hasher(),node);

}

 

int main()

{

   return 0;

}

Emails aren't always secure, and may be intercepted or changed after they've been sent. Santander Global Banking & Markets doesn't accept liability if this happens. If you think someone may have interfered with this email, please get in touch with the sender another way. This message doesn't create or change any contract. Santander Global Banking & Markets doesn't accept responsibility for damage caused by any viruses contained in this email or its attachments. Emails may be monitored. If you've received this email by mistake, please let the sender know at once that it's gone to the wrong person and then destroy it without copying, using, or telling anyone about its contents.
Abbey National Treasury Services plc Reg. No. 2338548. Registered Office: 2 Triton Square, Regent's Place, London, NW1 3AN. Registered in England. Abbey National Treasury Services plc is authorised and regulated by the Financial Services Authority (FSA Registration Number 146003).
Cater Allen International Limited. Reg No. 2572704. Registered Office: 2 Triton Square, Regent's Place, London, NW1 3AN. Registered in England. Cater Allen International Limited is authorised and regulated by the Financial Services Authority (FSA Registration Number 148467).
Santander Global Banking & Markets is a brand name used by Abbey National Treasury Services plc and Cater Allen International Limited.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net