Puzzled: compiler can't find a match for function call

In the code below, the compiler complains with q.cc:39: error: no matching function for call to `inc2(boost::fusion::map<boost: :fusion::pair<detail::KEY, int>, boost::fusion::void_, boost::fusion::void_, boo st::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::vo id_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_>&)' id_t<K> is the SAME type as the expanded BF::map type in inc1; it even works as the return type of inc1, yet I can't use it as an argument to inc2. What am I missing? This happens both on gcc 3.4 and SunCC 12. #include <boost/fusion/include/at_key.hpp> #include <boost/fusion/include/comparison.hpp> #include <boost/fusion/include/erase_key.hpp> #include <boost/fusion/include/io.hpp> #include <boost/fusion/include/joint_view.hpp> #include <boost/fusion/include/map.hpp> #include <boost/fusion/sequence/intrinsic/at_key.hpp> #include <boost/fusion/sequence/intrinsic/value_at_key.hpp> namespace detail { namespace BF = boost::fusion; struct KEY; template<typename K> struct id_t { typedef BF::map<BF::pair<K, int> > type; }; template<typename K> inline typename id_t<K>::type& inc1(BF::map<BF::pair<K, int> > &id) { ++BF::at_key<K>(id); return id; } template<typename K> inline typename id_t<K>::type& inc2(typename id_t<K>::type &id) { ++BF::at_key<K>(id); return id; } void f() { BF::map<BF::pair<KEY, int> > m(12); inc1(m); inc2(m); } }

Zeljko Vrba wrote:
In the code below, the compiler complains with
q.cc:39: error: no matching function for call to `inc2(boost::fusion::map<boost: :fusion::pair<detail::KEY, int>, boost::fusion::void_, boost::fusion::void_, boo st::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::vo id_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_>&)'
id_t<K> is the SAME type as the expanded BF::map type in inc1; it even works as the return type of inc1, yet I can't use it as an argument to inc2. What am I missing? This happens both on gcc 3.4 and SunCC 12. ...
namespace detail { namespace BF = boost::fusion; struct KEY;
Just a cursory glance, is KEY ever fully defined... the above is just a forwarded name. Jeff Flinn

On Thu, Sep 11, 2008 at 07:53:26AM -0700, Steven Watanabe wrote:
AMDG
Zeljko Vrba wrote:
template<typename K> inline typename id_t<K>::type& inc2(typename id_t<K>::type &id
The compiler cannot deduce K. If you call inc2<KEY>(m) it should work.
Indeed it works. Could you please explain why the compiler can deduce K in BF::map<BF::pair<K, int> > , but not in typename id_t<K>::type?

Zeljko Vrba wrote:
On Thu, Sep 11, 2008 at 07:53:26AM -0700, Steven Watanabe wrote:
AMDG
Zeljko Vrba wrote:
template<typename K> inline typename id_t<K>::type& inc2(typename id_t<K>::type &id The compiler cannot deduce K. If you call inc2<KEY>(m) it should work.
Indeed it works. Could you please explain why the compiler can deduce K in BF::map<BF::pair<K, int> > , but not in typename id_t<K>::type?
This thread has a good explanation: http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/... David
participants (4)
-
David Walthall
-
Jeff Flinn
-
Steven Watanabe
-
Zeljko Vrba