HippoMocks - mocking methods with std::vector fail to compile - c++

While trying out HippoMocks (Cygwin, GCC 4.5.3, CppUnit) to mock an interface, one of the methods is causing compilation to fail. Further triage shows that only mocking methods with std::vector as arguments would fail.
e.g.
m_Mocks.ExpectCall(m_EmpSvcMock.get(), IEmployeeServiceProxy::GetEmployees); // compile error!
m_Mocks.ExpectCall(m_EmpSvcMock.get(), IEmployeeServiceProxy::AddEmployee); // compile OK!
where
class IEmployeeServiceProxy
{
public:
virtual ~IEmployeeServiceProxy() { }
virtual void AddEmployee(const Employee&) = 0;
virtual void GetEmployees(std::vector<Employee>&) = 0;
};
struct Employee
{
boost::uuids::uuid Id;
std::string Name;
};
Compiler error:
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stream_iterator.h: In member function ‘std::ostream_iterator<_Tp, _CharT, _Traits>& std::ostream_iterator<_Tp, _CharT, _Traits>::operator=(const _Tp&) [with _Tp = EmployeeServiceLib::Employee, _CharT = char, _Traits = std::char_traits<char>, std::ostream_iterator<_Tp, _CharT, _Traits> = std::ostream_iterator<EmployeeServiceLib::Employee, char, std::char_traits<char> >]’:
In file included from /usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/iterator:67:0,
from /usr/include/boost/uuid/string_generator.hpp:14,
from /usr/include/boost/uuid/uuid_generators.hpp:15,
from tests/../../RcfTestShared/IEmployeeService.hpp:7,
from tests/../IEmployeeServiceProxy.h:11,
from tests/ClientTest.h:13,
from tests/ClientTest.cpp:8:
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_algobase.h:349:8: instantiated from ‘static _OI std::__copy_move<false, false, std::random_access_iterator_tag>::__copy_m(_II, _II, _OI) [with _II = const EmployeeServiceLib::Employee*, _OI = std::ostream_iterator<EmployeeServiceLib::Employee, char, std::char_traits<char> >]’
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_algobase.h:404:70: instantiated from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false, _II = const EmployeeServiceLib::Employee*, _OI = std::ostream_iterator<EmployeeServiceLib::Employee, char, std::char_traits<char> >]’
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_algobase.h:442:39: instantiated from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false, _II = __gnu_cxx::__normal_iterator<const EmployeeServiceLib::Employee*, std::vector<EmployeeServiceLib::Employee> >, _OI = std::ostream_iterator<EmployeeServiceLib::Employee, char, std::char_traits<char> >]’
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_algobase.h:474:18: instantiated from ‘_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator<const EmployeeServiceLib::Employee*, std::vector<EmployeeServiceLib::Employee> >, _OI = std::ostream_iterator<EmployeeServiceLib::Employee, char, std::char_traits<char> >]’
../../RCF/RCF-1.3.1/include/RCF/Tools.hpp:116:9: instantiated from ‘std::ostream& std::operator<<(std::ostream&, const std::vector<_RealType>&) [with T = EmployeeServiceLib::Employee, std::ostream = std::basic_ostream<char>]’
../../hippomocks/HippoMocks/hippomocks.h:94:5: instantiated from ‘static void printArg<T>::print(std::ostream&, T, bool) [with T = std::vector<EmployeeServiceLib::Employee>&, std::ostream = std::basic_ostream<char>]’
../../hippomocks/HippoMocks/hippomocks.h:170:5: instantiated from ‘void ref_tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>::printTo(std::ostream&) const [with A = std::vector<EmployeeServiceLib::Employee>&, B = NullType, C = NullType, D = NullType, E = NullType, F = NullType, G = NullType, H = NullType, I = NullType, J = NullType, K = NullType, L = NullType, M = NullType, N = NullType, O = NullType, P = NullType, std::ostream = std::basic_ostream<char>]’
tests/ClientTest.cpp:47:1: instantiated from here
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stream_iterator.h:196:2: error: cannot bind ‘std::ostream_iterator<EmployeeServiceLib::Employee, char, std::char_traits<char> >::ostream_type’ lvalue to ‘std::basic_ostream<char>&&’
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/ostream:579:5: error: initializing argument 1 of ‘std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char, _Traits = std::char_traits<char>, _Tp = EmployeeServiceLib::Employee]’

Possibly it's complaining that you don't have operator<< defined for Employee, but I'm not certain. I think you've missed the last line of your error messages? In any case I would read the documentation and see what requirements they have for the class being tested.
Requiring you to define operator== and operator<< and maybe others is pretty standard for a unit testing framework. If you think about it a unit testing framework is going to need to compare objects of the types you are testing and maybe going to try and output those objects when things go wrong.

Related

How to insert elements of Enum type into vector of type uint8_t?

I am very new to C++ programming. I want to insert elements of type enum into a vector<uint8_t> ? ie append all elements of std::vector <ValType> call to std::vector<uint8_t> bravo .Is there any way to do so?
#include <stdio.h>
#include <vector>
#include <cstdint>
enum class ValType : uint8_t
{
Working = 1,
Failed = 0,
Freezed = 0
};
int main()
{
std::vector<uint8_t> bravo = {23, 23, 23, 22, 5};
std::vector<ValType> call;
bravo.insert(bravo.end(), call.begin(), call.end());
return 0;
}
Live Here
I am getting an error while compiling :
In file included from c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\vector:66,
from custom.cpp:2:
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\stl_uninitialized.h: In instantiation of '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<ValType*, std::vector<ValType> >; _ForwardIterator = unsigned char*]':
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\stl_uninitialized.h:333:37: required from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<ValType*, std::vector<ValType> >; _ForwardIterator = unsigned char*; _Tp = unsigned char]'
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\vector.tcc:751:34: required from 'void std::vector<_Tp, _Alloc>::_M_range_insert(std::vector<_Tp, _Alloc>::iterator, _ForwardIterator, _ForwardIterator, std::forward_iterator_tag) [with _ForwardIterator = __gnu_cxx::__normal_iterator<ValType*, std::vector<ValType> >; _Tp = unsigned char; _Alloc = std::allocator<unsigned char>; std::vector<_Tp, _Alloc>::iterator = std::vector<unsigned char>::iterator]'
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\stl_vector.h:1665:19: required from 'void std::vector<_Tp, _Alloc>::_M_insert_dispatch(std::vector<_Tp, _Alloc>::iterator, _InputIterator, _InputIterator, std::__false_type) [with _InputIterator = __gnu_cxx::__normal_iterator<ValType*, std::vector<ValType> >; _Tp = unsigned char; _Alloc = std::allocator<unsigned char>; std::vector<_Tp, _Alloc>::iterator = std::vector<unsigned char>::iterator]'
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\stl_vector.h:1383:22: required from 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, _InputIterator, _InputIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<ValType*, std::vector<ValType> >; <template-parameter-2-2> = void; _Tp = unsigned char; _Alloc = std::allocator<unsigned char>; std::vector<_Tp, _Alloc>::iterator = std::vector<unsigned char>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<unsigned char>::const_iterator]'
custom.cpp:18:17: required from here
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\stl_uninitialized.h:138:72: error: static assertion failed: result type must be constructible from value type of input range
138 | static_assert(is_constructible<_ValueType2, decltype(*__first)>::value,
| ^~~~~
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\stl_uninitialized.h:138:72: note: 'std::integral_constant<bool, false>::value' evaluates to false
In file included from c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\vector:60,
from custom.cpp:2:
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\stl_algobase.h: In instantiation of 'static _OI std::__copy_move<false, false, std::random_access_iterator_tag>::__copy_m(_II, _II, _OI) [with _II = ValType*; _OI = unsigned char*]':
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\stl_algobase.h:495:30: required from '_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = ValType*; _OI = unsigned char*]'
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\stl_algobase.h:522:42: required from '_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = ValType*; _OI = unsigned char*]'
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\stl_algobase.h:530:31: required from '_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = __gnu_cxx::__normal_iterator<ValType*, std::vector<ValType> >; _OI = __gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char> >]'
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\stl_algobase.h:620:7: required from '_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator<ValType*, std::vector<ValType> >; _OI = __gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char> >]'
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\vector.tcc:744:16: required from 'void std::vector<_Tp, _Alloc>::_M_range_insert(std::vector<_Tp, _Alloc>::iterator, _ForwardIterator, _ForwardIterator, std::forward_iterator_tag) [with _ForwardIterator = __gnu_cxx::__normal_iterator<ValType*, std::vector<ValType> >; _Tp = unsigned char; _Alloc = std::allocator<unsigned char>; std::vector<_Tp, _Alloc>::iterator = std::vector<unsigned char>::iterator]'
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\stl_vector.h:1665:19: required from 'void std::vector<_Tp, _Alloc>::_M_insert_dispatch(std::vector<_Tp, _Alloc>::iterator, _InputIterator, _InputIterator, std::__false_type) [with _InputIterator = __gnu_cxx::__normal_iterator<ValType*, std::vector<ValType> >; _Tp = unsigned char; _Alloc = std::allocator<unsigned char>; std::vector<_Tp, _Alloc>::iterator = std::vector<unsigned char>::iterator]'
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\stl_vector.h:1383:22: required from 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, _InputIterator, _InputIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<ValType*, std::vector<ValType> >; <template-parameter-2-2> = void; _Tp = unsigned char; _Alloc = std::allocator<unsigned char>; std::vector<_Tp, _Alloc>::iterator = std::vector<unsigned char>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<unsigned char>::const_iterator]'
custom.cpp:18:17: required from here
c:\program files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\include\c++\11.2.0\bits\stl_algobase.h:385:25: error: cannot convert 'ValType' to 'unsigned char' in assignment
385 | *__result = *__first;
| ~~~~~~~~~~^~~~~~~~~~
Can someone please show me the correct way of doing this?
You can use std::transform with your own conversion function.
std::vector<uint8_t> bravo = {23, 23, 23, 22, 5};
std::vector<ValType> call;
std::transform(bravo.cbegin(), bravo.cend(), std::back_inserter(call),
[](uint8_t a) { return static_cast<ValType>(a); });
This is explained in e.g. this scope enumeration reference:
There are no implicit conversions from the values of a scoped enumerator to integral types, although static_cast may be used to obtain the numeric value of the enumerator.
[Emphasis mine]
So while it might look like inheritance when defining the enumeration, it's not. The type ValType is a completely separate type, which can't be converted to or from any other plain integer type, not even the one used as the enumeration base-type.
That means you can't simply copy from a vector of ValType elements to a vector of uint8_t elements. If you need to do such a copy you must implement your own conversion (using e.g. static_cast), perhaps using std::transform and an back insert iterator.

copying between instances of different variant template classes

Why does one variant assignment compile while the other does not? The template instances do not share any types and char could be converted to int, say. What is boost::variant trying to do, that it cannot do in the case of the first assignment and that it can do in the case of the second assignment? Error is below.
#include <string>
#include "boost/variant.hpp"
int main()
{
boost::variant<char> v1;
boost::variant<std::string, int, double> v2;
v1 = v2; // compile error
v2 = v1; // compiles fine
return 0;
}
In file included from /usr/include/boost/variant.hpp:17:0,
from v.cpp:3:
/usr/include/boost/variant/variant.hpp: In instantiation of 'int boost::variant<T0, TN>::convert_copy_into::internal_visit(T&, int) const [with T = const std::basic_string<char>; T0_ = char; TN = {}]':
/usr/include/boost/variant/detail/visitation_impl.hpp:113:9: required from 'typename Visitor::result_type boost::detail::variant::visitation_impl_invoke_impl(int, Visitor&, VoidPtrCV, T*, mpl_::true_) [with Visitor = boost::variant<char>::convert_copy_into; VoidPtrCV = const void*; T = std::basic_string<char>; typename Visitor::result_type = int; mpl_::true_ = mpl_::bool_<true>]'
/usr/include/boost/variant/detail/visitation_impl.hpp:156:9: required from 'typename Visitor::result_type boost::detail::variant::visitation_impl_invoke(int, Visitor&, VoidPtrCV, T*, NoBackupFlag, int) [with Visitor = boost::variant<char>::convert_copy_into; VoidPtrCV = const void*; T = std::basic_string<char>; NoBackupFlag = boost::variant<std::basic_string<char>, int, double>::has_fallback_type_; typename Visitor::result_type = int]'
/usr/include/boost/variant/detail/visitation_impl.hpp:237:5: required from 'typename Visitor::result_type boost::detail::variant::visitation_impl(int, int, Visitor&, VoidPtrCV, mpl_::false_, NoBackupFlag, Which*, step0*) [with Which = mpl_::int_<0>; step0 = boost::detail::variant::visitation_impl_step<boost::mpl::l_iter<boost::mpl::l_item<mpl_::long_<3l>, std::basic_string<char>, boost::mpl::l_item<mpl_::long_<2l>, int, boost::mpl::l_item<mpl_::long_<1l>, double, boost::mpl::l_end> > > >, boost::mpl::l_iter<boost::mpl::l_end> >; Visitor = boost::variant<char>::convert_copy_into; VoidPtrCV = const void*; NoBackupFlag = boost::variant<std::basic_string<char>, int, double>::has_fallback_type_; typename Visitor::result_type = int; mpl_::false_ = mpl_::bool_<false>]'
/usr/include/boost/variant/variant.hpp:2245:13: required from 'static typename Visitor::result_type boost::variant<T0, TN>::internal_apply_visitor_impl(int, int, Visitor&, VoidPtrCV) [with Visitor = boost::variant<char>::convert_copy_into; VoidPtrCV = const void*; T0_ = std::basic_string<char>; TN = {int, double}; typename Visitor::result_type = int]'
/usr/include/boost/variant/variant.hpp:2267:13: [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/usr/include/boost/variant/variant.hpp:1581:13: required from 'void boost::variant<T0, TN>::convert_construct_variant(Variant&) [with Variant = const boost::variant<std::basic_string<char>, int, double>; T0_ = char; TN = {}]'
/usr/include/boost/variant/variant.hpp:1628:42: required from 'void boost::variant<T0, TN>::convert_construct(const boost::variant<U0, UN ...>&, long int) [with U0 = std::basic_string<char>; UN = {int, double}; T0_ = char; TN = {}]'
/usr/include/boost/variant/variant.hpp:1649:38: required from 'boost::variant<T0, TN>::variant(const T&) [with T = boost::variant<std::basic_string<char>, int, double>; T0_ = char; TN = {}]'
/usr/include/boost/variant/variant.hpp:2059:29: required from 'void boost::variant<T0, TN>::assign(const T&) [with T = boost::variant<std::basic_string<char>, int, double>; T0_ = char; TN = {}]'
/usr/include/boost/variant/variant.hpp:2099:19: required from 'boost::variant<T0, TN>& boost::variant<T0, TN>::operator=(const T&) [with T = boost::variant<std::basic_string<char>, int, double>; T0_ = char; TN = {}]'
v.cpp:10:6: required from here
/usr/include/boost/variant/variant.hpp:1366:61: error: no matching function for call to 'boost::variant<char>::initializer::initialize(void* const&, const std::basic_string<char>&)'
return initializer::initialize(storage_, operand);
^
/usr/include/boost/variant/variant.hpp:1366:61: note: candidates are:
In file included from /usr/include/boost/variant/variant.hpp:32:0,
from /usr/include/boost/variant.hpp:17,
from v.cpp:3:
/usr/include/boost/variant/detail/initializer.hpp:104:24: note: static int boost::detail::variant::make_initializer_node::apply<BaseIndexPair, Iterator>::initializer_node::initialize(void*, boost::detail::variant::make_initializer_node::apply<BaseIndexPair, Iterator>::initializer_node::param_T) [with BaseIndexPair = boost::mpl::pair<boost::detail::variant::initializer_root, mpl_::int_<0> >; Iterator = boost::mpl::l_iter<boost::mpl::list1<char> >; boost::detail::variant::make_initializer_node::apply<BaseIndexPair, Iterator>::initializer_node::param_T = const char&]
static int initialize(void* dest, param_T operand)
^
/usr/include/boost/variant/detail/initializer.hpp:104:24: note: no known conversion for argument 2 from 'const std::basic_string<char>' to 'boost::detail::variant::make_initializer_node::apply<boost::mpl::pair<boost::detail::variant::initializer_root, mpl_::int_<0> >, boost::mpl::l_iter<boost::mpl::list1<char> > >::initializer_node::param_T {aka const char&}'
/usr/include/boost/variant/detail/initializer.hpp:115:24: note: static int boost::detail::variant::make_initializer_node::apply<BaseIndexPair, Iterator>::initializer_node::initialize(void*, boost::detail::variant::make_initializer_node::apply<BaseIndexPair, Iterator>::initializer_node::param2_T) [with BaseIndexPair = boost::mpl::pair<boost::detail::variant::initializer_root, mpl_::int_<0> >; Iterator = boost::mpl::l_iter<boost::mpl::list1<char> >; boost::detail::variant::make_initializer_node::apply<BaseIndexPair, Iterator>::initializer_node::param2_T = char&&]
static int initialize(void* dest, param2_T operand)
^
/usr/include/boost/variant/detail/initializer.hpp:115:24: note: no known conversion for argument 2 from 'const std::basic_string<char>' to 'boost::detail::variant::make_initializer_node::apply<boost::mpl::pair<boost::detail::variant::initializer_root, mpl_::int_<0> >, boost::mpl::l_iter<boost::mpl::list1<char> > >::initializer_node::param2_T {aka char&&}'
/usr/include/boost/variant/detail/initializer.hpp:149:17: note: static void boost::detail::variant::initializer_root::initialize()
static void initialize();
^
/usr/include/boost/variant/detail/initializer.hpp:149:17: note: candidate expects 0 arguments, 2 provided
A char definitely can be stored in an int but the converse is not always true. Therefore the one that fails to compile would be unsafe at runtime, so you're probably better off with it failing. Cast the int to a char if you must.

Why const member caused error?

#include <vector>
class B {
};
class A {
const std::vector<B> m_v;
public:
A(const std::vector<B>& v) : m_v(v) {}
void doSomething() {}
};
void foo(void* bar) {
A* a = (A*)bar;
a->doSomething();
}
int main() {
std::vector<B> v;
std::vector<A > l;
for (auto i = 0; i < 10; i++) {
A a(v);
l.push_back(std::move(a));
foo((void*)&l[i]);
}
return 0;
}
$ g++ -Wall initList.cpp -o initList -lrt -O3 -std=c++0x
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/vector:70:0,
from initList.cpp:1:
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/vector.tcc: In member function \u2018void std::vector::_M_insert_aux(std::vector::iterator, _Args&& ...) [with _Args = {A}, _Tp = A, _Alloc = std::allocator, std::vector::iterator = __gnu_cxx::__normal_iterator >, typename std::_Vector_base::_Tp_alloc_type::pointer = A*]`:
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/vector.tcc:102:4: instantiated from \u2018void std::vector::emplace_back(_Args&& ...) [with _Args = {A}, _Tp = A, _Alloc = std::allocator]`
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_vector.h:840:9: instantiated from \u2018void std::vector::push_back(std::vector::value_type&&) [with _Tp = A, _Alloc = std::allocator, std::vector::value_type = A]`
initList.cpp:23:27: instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/vector.tcc:319:4: error: use of deleted function '& A::operator=(const A&)`
initList.cpp:6:7: error: '& A::operator=(const A&)` is implicitly deleted because the default definition would be ill-formed:
initList.cpp:6:7: error: passing \u2018const std::vector` as \u2018this` argument of \u2018std::vector& std::vector::operator=(const std::vector&) [with _Tp = B, _Alloc = std::allocator]` discards qualifiers [-fpermissive]
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/vector:61:0,
from initList.cpp:1:
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_algobase.h: In static member function \u2018static _BI2 std::__copy_move_backward::__copy_move_b(_BI1, _BI1, _BI2) [with _BI1 = A*, _BI2 = A*]`:
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_algobase.h:581:18: instantiated from \u2018_BI2 std::__copy_move_backward_a(_BI1, _BI1, _BI2) [with bool _IsMove = true, _BI1 = A*, _BI2 = A*]`
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_algobase.h:590:34: instantiated from \u2018_BI2 std::__copy_move_backward_a2(_BI1, _BI1, _BI2) [with bool _IsMove = true, _BI1 = A*, _BI2 = A*]`
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_algobase.h:661:15: instantiated from \u2018_BI2 std::move_backward(_BI1, _BI1, _BI2) [with _BI1 = A*, _BI2 = A*]`
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/vector.tcc:313:4: instantiated from \u2018void std::vector::_M_insert_aux(std::vector::iterator, _Args&& ...) [with _Args = {A}, _Tp = A, _Alloc = std::allocator, std::vector::iterator = __gnu_cxx::__normal_iterator >, typename std::_Vector_base::_Tp_alloc_type::pointer = A*]`
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/vector.tcc:102:4: instantiated from \u2018void std::vector::emplace_back(_Args&& ...) [with _Args = {A}, _Tp = A, _Alloc = std::allocator]`
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_vector.h:840:9: instantiated from \u2018void std::vector::push_back(std::vector::value_type&&) [with _Tp = A, _Alloc = std::allocator, std::vector::value_type = A]`
initList.cpp:23:27: instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/bits/stl_algobase.h:546:6: error: use of deleted function '& A::operator=(const A&)`
If I don't specify const for m_v. It compiles fine.
The error suggests something with assign operator, which I don't see how it is invoked.
Any idea?
Thanks in advance.
It's a bug in older versions of GCC/libstdc++, your code compiles fine with GCC 4.8.1. Live example. The bug is triggered by
l.push_back(std::move(a));
as older versions of GCC tried to create a default-constructed element in the vector and assigned the parameter std::move(a) to it in a second step instead of using the in-place copy/move-ctor.

boost::iostreams::bzip2_compressor fails only with c++0x

The bare-bones minimal example:
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
int main() {
boost::iostreams::filtering_istream in;
in.push(boost::iostreams::bzip2_compressor());
return 0;
}
Compiles fine on my machine with:
g++ -lboost_iostreams simple.cpp
But fails when c++0x is included in either instance of :
g++ -lboost_iostreams simple.cpp -std=c++0x
g++ -lboost_iostreams simple.cpp -std=gnu++0x
The insanely long error message is below. What in the code is causing c++0x to fail? How can this be fixed? I've run this three machines, each with different configurations - it fails on two, but runs correctly on a stock Ubuntu install.
In file included from /usr/local/include/boost/iostreams/traits.hpp:31:0,
from /usr/local/include/boost/iostreams/pipeline.hpp:18,
from /usr/local/include/boost/iostreams/detail/push.hpp:22,
from /usr/local/include/boost/iostreams/filtering_stream.hpp:19,
from simple.cpp:1:
/usr/local/include/boost/iostreams/detail/wrap_unwrap.hpp: In instantiation of ‘T boost::iostreams::detail::wrap(const T&, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’:
/usr/local/include/boost/iostreams/stream_buffer.hpp:94:5: required from ‘boost::iostreams::stream_buffer<T, Tr, Alloc, Mode>::stream_buffer(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:257:60: required from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:216:1: required from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push(const T&, std::streamsize, std::streamsize, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’
/usr/local/include/boost/iostreams/chain.hpp:496:7: required from ‘void boost::iostreams::detail::chain_client<Chain>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Chain = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:484:1: required from ‘void boost::iostreams::detail::chain_client<Chain>::push(const T&, std::streamsize, std::streamsize, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; Chain = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; std::streamsize = long int; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’
simple.cpp:6:47: required from here
/usr/local/include/boost/iostreams/detail/wrap_unwrap.hpp:53:14: error: use of deleted function ‘boost::iostreams::basic_bzip2_compressor<>::basic_bzip2_compressor(const boost::iostreams::basic_bzip2_compressor<>&)’
In file included from simple.cpp:2:0:
/usr/local/include/boost/iostreams/filter/bzip2.hpp:239:8: note: ‘boost::iostreams::basic_bzip2_compressor<>::basic_bzip2_compressor(const boost::iostreams::basic_bzip2_compressor<>&)’ is implicitly deleted because the default definition would be ill-formed:
/usr/local/include/boost/iostreams/filter/bzip2.hpp:239:8: error: use of deleted function ‘boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >::symmetric_filter(const boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >&)’
In file included from /usr/local/include/boost/iostreams/filter/bzip2.hpp:29:0,
from simple.cpp:2:
/usr/local/include/boost/iostreams/filter/symmetric.hpp:72:7: note: ‘boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >::symmetric_filter(const boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >&)’ is implicitly deleted because the default definition would be ill-formed:
/usr/local/include/boost/iostreams/filter/symmetric.hpp:72:7: error: use of deleted function ‘boost::shared_ptr<boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >::impl>::shared_ptr(const boost::shared_ptr<boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >::impl>&)’
In file included from /usr/local/include/boost/shared_ptr.hpp:17:0,
from /usr/local/include/boost/iostreams/chain.hpp:37,
from /usr/local/include/boost/iostreams/filtering_streambuf.hpp:17,
from /usr/local/include/boost/iostreams/filtering_stream.hpp:22,
from simple.cpp:1:
/usr/local/include/boost/smart_ptr/shared_ptr.hpp:168:25: note: ‘boost::shared_ptr<boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >::impl>::shared_ptr(const boost::shared_ptr<boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >::impl>&)’ is implicitly declared as deleted because ‘boost::shared_ptr<boost::iostreams::symmetric_filter<boost::iostreams::detail::bzip2_compressor_impl<std::allocator<char> >, std::allocator<char> >::impl>’ declares a move constructor or move assignment operator
In file included from /usr/local/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:23:0,
from /usr/local/include/boost/iostreams/stream_buffer.hpp:22,
from /usr/local/include/boost/iostreams/chain.hpp:35,
from /usr/local/include/boost/iostreams/filtering_streambuf.hpp:17,
from /usr/local/include/boost/iostreams/filtering_stream.hpp:22,
from simple.cpp:1:
/usr/local/include/boost/iostreams/detail/adapter/concept_adapter.hpp: In instantiation of ‘boost::iostreams::detail::concept_adapter<T>::concept_adapter(const T&) [with T = boost::iostreams::basic_bzip2_compressor<>]’:
/usr/local/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:187:5: required from ‘void boost::iostreams::detail::indirect_streambuf<T, Tr, Alloc, Mode>::open(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/stream_buffer.hpp:106:13: required from ‘void boost::iostreams::stream_buffer<T, Tr, Alloc, Mode>::open_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/stream_buffer.hpp:94:5: required from ‘boost::iostreams::stream_buffer<T, Tr, Alloc, Mode>::stream_buffer(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:257:60: required from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:216:1: required from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push(const T&, std::streamsize, std::streamsize, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’
/usr/local/include/boost/iostreams/chain.hpp:496:7: required from ‘void boost::iostreams::detail::chain_client<Chain>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Chain = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:484:1: required from ‘void boost::iostreams::detail::chain_client<Chain>::push(const T&, std::streamsize, std::streamsize, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; Chain = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; std::streamsize = long int; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’
simple.cpp:6:47: required from here
/usr/local/include/boost/iostreams/detail/adapter/concept_adapter.hpp:67:48: error: use of deleted function ‘boost::iostreams::basic_bzip2_compressor<>::basic_bzip2_compressor(const boost::iostreams::basic_bzip2_compressor<>&)’
In file included from /usr/local/include/boost/iostreams/detail/streambuf/direct_streambuf.hpp:26:0,
from /usr/local/include/boost/iostreams/stream_buffer.hpp:21,
from /usr/local/include/boost/iostreams/chain.hpp:35,
from /usr/local/include/boost/iostreams/filtering_streambuf.hpp:17,
from /usr/local/include/boost/iostreams/filtering_stream.hpp:22,
from simple.cpp:1:
/usr/local/include/boost/iostreams/detail/optional.hpp: In instantiation of ‘void boost::iostreams::detail::optional<T>::reset(const T&) [with T = boost::iostreams::detail::concept_adapter<boost::iostreams::basic_bzip2_compressor<> >]’:
/usr/local/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:187:5: required from ‘void boost::iostreams::detail::indirect_streambuf<T, Tr, Alloc, Mode>::open(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/stream_buffer.hpp:106:13: required from ‘void boost::iostreams::stream_buffer<T, Tr, Alloc, Mode>::open_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/stream_buffer.hpp:94:5: required from ‘boost::iostreams::stream_buffer<T, Tr, Alloc, Mode>::stream_buffer(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:257:60: required from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:216:1: required from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push(const T&, std::streamsize, std::streamsize, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’
/usr/local/include/boost/iostreams/chain.hpp:496:7: required from ‘void boost::iostreams::detail::chain_client<Chain>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Chain = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:484:1: required from ‘void boost::iostreams::detail::chain_client<Chain>::push(const T&, std::streamsize, std::streamsize, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; Chain = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; std::streamsize = long int; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’
simple.cpp:6:47: required from here
/usr/local/include/boost/iostreams/detail/optional.hpp:100:9: error: use of deleted function ‘boost::iostreams::detail::concept_adapter<boost::iostreams::basic_bzip2_compressor<> >::concept_adapter(const boost::iostreams::detail::concept_adapter<boost::iostreams::basic_bzip2_compressor<> >&)’
In file included from /usr/local/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:23:0,
from /usr/local/include/boost/iostreams/stream_buffer.hpp:22,
from /usr/local/include/boost/iostreams/chain.hpp:35,
from /usr/local/include/boost/iostreams/filtering_streambuf.hpp:17,
from /usr/local/include/boost/iostreams/filtering_stream.hpp:22,
from simple.cpp:1:
/usr/local/include/boost/iostreams/detail/adapter/concept_adapter.hpp:38:7: note: ‘boost::iostreams::detail::concept_adapter<boost::iostreams::basic_bzip2_compressor<> >::concept_adapter(const boost::iostreams::detail::concept_adapter<boost::iostreams::basic_bzip2_compressor<> >&)’ is implicitly deleted because the default definition would be ill-formed:
/usr/local/include/boost/iostreams/detail/adapter/concept_adapter.hpp:38:7: error: use of deleted function ‘boost::iostreams::basic_bzip2_compressor<>::basic_bzip2_compressor(const boost::iostreams::basic_bzip2_compressor<>&)’
In file included from /usr/local/include/boost/iostreams/traits.hpp:31:0,
from /usr/local/include/boost/iostreams/pipeline.hpp:18,
from /usr/local/include/boost/iostreams/detail/push.hpp:22,
from /usr/local/include/boost/iostreams/filtering_stream.hpp:19,
from simple.cpp:1:
/usr/local/include/boost/iostreams/detail/wrap_unwrap.hpp: In instantiation of ‘T boost::iostreams::detail::wrap(const T&, typename boost::disable_if<boost::iostreams::is_std_io<T> >::type*) [with T = boost::iostreams::basic_bzip2_compressor<>; typename boost::disable_if<boost::iostreams::is_std_io<T> >::type = void]’:
/usr/local/include/boost/iostreams/stream_buffer.hpp:94:5: required from ‘boost::iostreams::stream_buffer<T, Tr, Alloc, Mode>::stream_buffer(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
/usr/local/include/boost/iostreams/chain.hpp:257:60: required from ‘void boost::iostreams::detail::chain_base<Self, Ch, Tr, Alloc, Mode>::push_impl(const T&, std::streamsize, std::streamsize) [with T = boost::iostreams::basic_bzip2_compressor<>; Self = boost::iostreams::chain<boost::iostreams::input, char, std::char_traits<char>, std::allocator<char> >; Ch = char; Tr = std::char_traits<char>; Alloc = std::allocator<char>; Mode = boost::iostreams::input; std::streamsize = long int]’
Code compiled with -std=c++0x is not going to be ABI compatible with code compiled without -std=c++0x. You'll need to build Boost yourself with -std=c++0x enabled; this can be done by passing the cxxflags argument to bjam/b2.

bind() for using member function as STL comparison function

Could someone tell me why the following won't compile?
#include "a.h"
#include <list>
#include <algorithm>
#include <tr1/functional>
using namespace std;
class B {
public:
B() {
list< A* > aList;
A* a = new A();
lower_bound( aList.begin(), aList.end(), a, tr1::bind( &B::aComp, tr1::placeholders::_1, tr1::placeholders::_2 ) );
}
private:
bool aComp( A* a1, A* a2 );
};
Compile output:
In file included from c:\qt\2010.04\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/tr1/functional:56,
from ..\bindTest\/b.h:4,
from ..\bindTest\b.cpp:1:
c:\qt\2010.04\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/tr1_impl/functional: In member function 'typename std::tr1::result_of<_Functor(typename std::tr1::result_of<std::tr1::_Mu<_Bound_args, std::tr1::is_bind_expression::value, (std::tr1::is_placeholder::value > 0)>(_Bound_args, std::tr1::tuple<_UElements ...>)>::type ...)>::type std::tr1::_Bind<_Functor(_Bound_args ...)>::__call(const std::tr1::tuple<_UElements ...>&, std::tr1::_Index_tuple<_Indexes ...>) [with _Args = A*&, A* const&, int ..._Indexes = 0, 1, _Functor = std::tr1::_Mem_fn<bool (B::*)(A*, A*)>, _Bound_args = std::tr1::_Placeholder<1>, std::tr1::_Placeholder<2>]':
c:\qt\2010.04\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/tr1_impl/functional:1191: instantiated from 'typename std::tr1::result_of<_Functor(typename std::tr1::result_of<std::tr1::_Mu<_Bound_args, std::tr1::is_bind_expression::value, (std::tr1::is_placeholder::value > 0)>(_Bound_args, std::tr1::tuple<_UElements ...>)>::type ...)>::type std::tr1::_Bind<_Functor(_Bound_args ...)>::operator()(_Args& ...) [with _Args = A*, A* const, _Functor = std::tr1::_Mem_fn<bool (B::*)(A*, A*)>, _Bound_args = std::tr1::_Placeholder<1>, std::tr1::_Placeholder<2>]'
c:\qt\2010.04\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/stl_algo.h:2495: instantiated from '_FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare) [with _FIter = std::_List_iterator<A*>, _Tp = A*, _Compare = std::tr1::_Bind<std::tr1::_Mem_fn<bool (B::*)(A*, A*)>(std::tr1::_Placeholder<1>, std::tr1::_Placeholder<2>)>]'
..\bindTest\/b.h:13: instantiated from here
c:\qt\2010.04\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/tr1_impl/functional:1137: error: no match for call to '(std::tr1::_Mem_fn<bool (B::*)(A*, A*)>) (A*&, A* const&)'
c:\qt\2010.04\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/tr1_impl/functional:546: note: candidates are: _Res std::tr1::_Mem_fn<_Res (_Class::*)(_ArgTypes ...)>::operator()(_Class&, _ArgTypes ...) const [with _Res = bool, _Class = B, _ArgTypes = A*, A*]
c:\qt\2010.04\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/tr1_impl/functional:551: note: _Res std::tr1::_Mem_fn<_Res (_Class::*)(_ArgTypes ...)>::operator()(_Class*, _ArgTypes ...) const [with _Res = bool, _Class = B, _ArgTypes = A*, A*]
aComp is a nonstatic member function of B, so you need to bind to the this pointer as well:
tr1::bind(&B::aComp, this, tr1::placeholders::_1, tr1::placeholders::_2)