RE: ICE ICE BABY! (my MPL code is ICEing)

HAHAHAHA Nevermind. copy_col_if_in_dest<boost::mpl::at<src::typelist, boost::mpl::int_<0>
::type,src::typelist>();
-----Original Message----- From: Brian Braatz Sent: Saturday, June 04, 2005 2:38 PM To: 'boost@lists.boost.org' Subject: ICE ICE BABY! (my MPL code is ICEing)
Sitting in the backyard.
Beautiful day, got up at 3am to get something figured out (for
instead of being src::typelist (which is a ref to the param of type src_t) it needs to be src_t::typelist. it was indeed something stupid- I am undecided as to which is more stupid. The fact that I didn't catch that or the fact that MSVC ICE'd on it...... sorry for bugging you guys proposed
boost profiler \ introspection library).
Good news is I figured out the MPL code needed to accomplish my goal. After typing in an incremental version of the code, I got the dreaded internal compiler error (ICE).
I am chewing on this- and thought I would post it so to provide an opportunity for someone to show how incredibly stupid I am because I did something that was obviously wrong. (you can even rub my nose in it if you like :) )
here is the code:
I am tearing it apart\deconstructing to try to figure out what is kicking in the ICE. (I am also going to try it with an eval_if (which I should be using anyway) just to see what happens)
I am using boost 1.32 and vc7.1
struct do_copy_col { typedef do_copy_col type; do_copy_col() { std::cout << "do_copy_col" << std::endl; } // todo- implement operator()(dest,src) }; struct do_not_copy_col { typedef do_not_copy_col type; do_not_copy_col() { std::cout << "do_not_copy_col" << std::endl; }
// todo- implement operator()(dest,src) };
template <class type_t, class sequence_t> struct copy_col_if_in_dest : public if_< typename is_same< typename deref<typename boost::mpl::find<sequence_t, type_t>::type >::type, type_t>, do_copy_col, do_not_copy_col>::type { };
template <class src_t, class dest_t> void copy_union(src_t & src, dest_t & dest) { copy_col_if_in_dest<boost::mpl::at<src::typelist, boost::mpl::int_<0>
::type,src::typelist>(); }

Brian Braatz wrote:
HAHAHAHA
Nevermind.
Just when I was about to post? Anyways, concerning your original message:
template <class type_t, class sequence_t> struct copy_col_if_in_dest : public if_< typename is_same< typename deref<typename boost::mpl::find<sequence_t, type_t>::type >::type, type_t>,
do_copy_col,
do_not_copy_col>::type { };
This code has a problem when type_t is not in sequence_t: the past-the-end iterator gets dereferenced. I wrote a short program to do what you want (it's more explicit, it uses mpl::contains<>): #include <boost/mpl/vector.hpp> #include <boost/mpl/if.hpp> #include <boost/mpl/contains.hpp> namespace mpl = boost::mpl; struct do_copy_col {}; struct dont_copy_col {}; template<typename T, typename Seq> struct copy_col_if_in_dest : mpl::if_< mpl::contains<Seq, T>, do_copy_col, dont_copy_col >::type { }; int main() { typedef mpl::vector<char, short, int, long> v; do_copy_col do_copy = copy_col_if_in_dest<int, v>(); dont_copy_col dont_copy = copy_col_if_in_dest<bool, v>(); return 0; }
participants (2)
-
Ariel Badichi
-
Brian Braatz