Using Boost 1_33_1 and Visual Studio 8. Any and all help appreciated.....
Working with "The FlySwapper" example in the "C++ Template Metaprogramming" book. Pages 22-24. It crashes when I do this:
std::vector<bool>::iterator i1;
std::vector<bool>::iterator i2;
use_swap( &i1, &i2 ) // crash here
All other types I try work fine. But doing <bool> crashes on this line:
iter_swap_impl::do_it(*i1,*i2); // ouch!!!
Debug looks like it stopped somewere within vector debug during boost::apply processing.
// Fly Swapper code .....
<snip>
template <bool use_swap> struct iter_swap_impl;
template < class ForwardIterator1, class ForwardIterator2 >
void iter_swap(ForwardIterator1 i1, ForwardIterator2 i2 )
{
typedef std::iterator_traits< ForwardIterator1 > traits1;
typedef typename traits1::value_type v1;
typedef typename traits1::reference r1;
typedef std::iterator_traits< ForwardIterator2 > traits2;
typedef typename traits2::value_type v2;
typedef typename traits2::reference r2;
bool const use_swap = boost::is_same::value
&& boost::is_reference<r1>::value
&& boost::is_reference<r2>::value;
iter_swap_impl::do_it(*i1,*i2); //***** CRASH CRASH here
}
template <>
struct iter_swap_impl<true> // fast one
{
template < class ForwardIterator1, class ForwardIterator2 >
static void do_it( ForwardIterator1 i1, ForwardIterator2 i2 )
{
std::cout << "use_swap is TRUE" << std::endl;
}
};
template<>
struct iter_swap_impl<false>
{
template < class ForwardIterator1, class ForwardIterator2 >
static void do_it( ForwardIterator1 i1, ForwardIterator2 i2 )
{
std::cout << "use_swap is FALSE" << std::endl;
}
};
</snip>