Many thanks lon, Just before your reply I spotted a conflict between my original use of 'animals' and the new usage. Sorry for the noise! John On 07/09/2021 16:33, Ion GaztaƱaga via Boost-users wrote:
But when I try that here, VS2019 throws up this compiler error:-
error C2039: 'default_list_hook': is not a member of 'animal'
Can anyone explain what I'm doing wrong??
John
It's difficult to see what's wrong without a full compilable example but the following snippet works perfectly for me in Visual 2019:
#include
#include <string> #include <iostream> using namespace std;
class animal { public: animal (string n, int l) : name{move(n)}, legs{l} {}
string name; int legs; boost::intrusive::list_member_hook<> _animal_hook; };
typedef boost::intrusive::member_hook
, &animal::_animal_hook> AnimalHookOption; typedef boost::intrusive::list
Animals; void print_list (const Animals& elem) { for (const Animals::value_type& a : elem) cout << "A " << a.name << " has " << a.legs << " legs" << '\n'; }
int main() { animal a1{"dog", 4}; animal a2{"spider", 6}; animal a3{"budgie", 2}; Animals animals;
animals.push_back(a1); animals.push_back(a2); animals.push_back(a3); print_list (animals);
return 0; } _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users