In boost::multi_index I try to insert value at specific location, how ever I did not find any example how to accomplish this task in boost documentation https://www.boost.org/doc/libs/1_59_0/libs/multi_index/doc/tutorial/indices.html or elsewhere.
This is a code which allows to insert at the beginning or the end of the collection.
struct animal {
std::string name;
int legs;
};
typedef multi_index_container<
animal,
indexed_by<
sequenced<>,
ordered_non_unique<member<animal, std::string, &animal::name>>,
ordered_non_unique<member<animal, int, &animal::legs>>,
random_access<>
>
> animal_multi;
int main() {
animal_multi animals;
animals.push_back({"shark", 0});
animals.push_back({"spider", 8});
animals.push_front({"dog", 4});
auto it = animals.begin();
auto end = animals.end();
for (; it != end; ++it)
std::cout << it->name + " ";
return 0;
}
Current output is: dog shark spider
How can I adjust the code in order to pass something, for example, between shark and spider?