I'm having a problem using Boost.Phoenix. I'm currently building against
Boost 1.41 using gcc 4.3.2.
I've simplified my use case quite a bit, so please forgive the obtuseness of
the example. The following code fails to compile:
~~~~~~~~~~~~~~~~~~~~
#include
#include
#include
#include
#include
<vector>
#include
<map>
#include <algorithm>
namespace phx = boost::phoenix;
using namespace phx::arg_names;
using phx::at_c;
using std::map;
using std::multimap;
using std::vector;
int main()
{
typedef map
char_int_map_t;
typedef multimap
int_iter_map_t;
typedef map
char_iter_map_t;
int int_key =
5;
char_int_map_t
int_map;
int_iter_map_t
int_iter_map;
char_iter_map_t char_iter_map1,
char_iter_map_t2;
int_iter_map_t::iterator
start,stop;
std::pair
er = int_iter_map.equal_range(int_key);
std::set_intersection(
char_iter_map1.begin(), char_iter_map1.end(),
er.first,er.second,
inserter(char_iter_map_t2,char_iter_map_t2.begin()),
phx::at_c<0>(arg1) < phx::at_c<0>(*phx::at_c<1>(arg2)) // <-
COMPILE FAILURE
);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here is the information I can offer,
1) When the key in char_int_map_t and char_iter_map_t is a char rather than
a vector<char> this compiles without problems.
2) The gcc error shows that the arguments to the generated function object
are being switched (I think, see below)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
.../comparison.hpp:29:5: error: no match for ‘operator<’ in
‘result_of_less::x < result_of_less::y’
.../comparison.hpp: In instantiation of ‘const int result_of_less::index’:
.../comparison.hpp:29: instantiated from ‘result_of_less’
.../mpl/eval_if.hpp:38: instantiated from ‘eval_if, is_actor, mpl_::bool_<false>,
mpl_::bool_<false>, mpl_::bool_<false> >, re_curry, result_of_less&> >’
.../comparison.hpp:39: instantiated from ‘
boost::phoenix::less_eval::result<
boost::phoenix::basic_environment<
std::pair<
// This should be the second argument, no?
const
int,
std::_Rb_tree_iterator, int>>
>,
std::pair<
const std::vector< char, std::allocator<char> >,
std::_Rb_tree_iterator, int>>
>
>,
boost::phoenix::composite<
boost::phoenix::at_eval<0>,
boost::fusion::vector<
boost::phoenix::argument<0>
>
>,
boost::phoenix::composite<
boost::phoenix::at_eval<0>,
boost::fusion::vector<
boost::phoenix::composite<
boost::phoenix::dereference_eval,
boost::fusion::vector<
boost::phoenix::composite<
boost::phoenix::at_eval<1>,
boost::fusion::vector<
boost::phoenix::argument<1>
>
>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3) Finally, if I use the expression
phx::at_c<0>(arg1) < *phx::at_c<1>(arg2)
the code still fails to compile (obviously), but does seem to get the
arguments in the correct order.
Any ideas?
Thanks
Nate