Exemplo n.º 1
0
void InsertString(std::forward_list<std::string> &s, const std::string &s1, const std::string &s2)
{
    std::forward_list<std::string>::iterator a, prev = s.before_begin();

    for (a = s.begin(); a != s.end(); ++a, ++prev) {
        if (*a == s1) {
            s.insert_after(a, s2);
            return;
        }
    }
    s.insert_after(prev, s2);
}
Exemplo n.º 2
0
typename boost::disable_if<
    typename detail::is_default_constructible<
        typename std::forward_list<T, Allocator>::value_type
    >,
    void
>::type
collection_load_impl(
    Archive & ar,
    std::forward_list<T, Allocator> &t,
    collection_size_type count,
    item_version_type item_version
){
    t.clear();
    boost::serialization::detail::stack_construct<Archive, T> u(ar, item_version);
    ar >> boost::serialization::make_nvp("item", u.reference());
    t.push_front(u.reference());
    typename std::forward_list<T, Allocator>::iterator last;
    last = t.begin();
    ar.reset_object_address(&(*t.begin()) , & u.reference());
    while(--count > 0){
        detail::stack_construct<Archive, T> u(ar, item_version);
        ar >> boost::serialization::make_nvp("item", u.reference());
        last = t.insert_after(last, u.reference());
        ar.reset_object_address(&(*last) , & u.reference());
    }
}
Exemplo n.º 3
0
 inline connection_type connect(long priority, Slot&& f) // O(n)
 {
     auto prev = slots.cbefore_begin(),
             next = slots.cbegin(),
             end = slots.cend();
     while(next != end)
     {
         // <=
         if(priority < next->first)
         {
             return slots.insert_after(prev, std::make_pair(priority, std::move(f)));
         }
         prev = next;
         ++next;
     }
     return slots.insert_after(prev, std::make_pair(priority, std::move(f)));
 }