вот вам моя задачка. есть класс с перегруженным оператором <. есть вектор, который хранит shared_ptr'ы на объекты этого класса. задача - поюзать std::sort не создавая левые функции, только при помощи stl b boost::bind. второй день не могу понять в чем дело =\ был бы вектор чистых объектов - можно было отсортировать строкой
Код:
std::sort(state_lines.begin(), state_lines.end());
а я уже опустился до дублирования сравнения в статик методе less
Код:
std::sort(state_lines.begin(), state_lines.end(),
boost::bind<bool>(&HorizontalStateLine::less, _1, _2));
все равно не компилится =\
Код:
e:\Program Files\boost\boost_1_38\boost\bind.hpp(282): error C2664: 'bool (const geometry::HorizontalStateLine &,const geometry::HorizontalStateLine &)' : cannot convert parameter 2 from 'std::allocator<_Ty>::value_type' to 'const geometry::HorizontalStateLine &'
with
[
_Ty=geometry::HORIZONTALSTATELINE_PTR
]
e:\Program Files\boost\boost_1_38\boost\bind.hpp(282): error C2664: 'bool (const geometry::HorizontalStateLine &,const geometry::HorizontalStateLine &)' : cannot convert parameter 1 from 'std::allocator<_Ty>::value_type' to 'const geometry::HorizontalStateLine &'
with
[
_Ty=geometry::HORIZONTALSTATELINE_PTR
]
Reason: cannot convert from 'std::allocator<_Ty>::value_type' to 'const geometry::HorizontalStateLine'
with
[
_Ty=geometry::HORIZONTALSTATELINE_PTR
]
No constructor could take the source type, or constructor overload resolution was ambiguous
люто бешено не понимаю почему от простого изменения типа элемента с объекта на указатель творится такая жопа
[ADDED]
сцуко скомпилелось =\\\ пришлось сделать внутри класса такое вот
static bool less (const HORIZONTALSTATELINE_PTR& left, const HORIZONTALSTATELINE_PTR& right);