コード例 #1
0
inline void
remove_placeholders (ContainerT &replacement_list)
{
    using namespace boost::wave;

// strip leading whitespace
    if (replacement_list.size() > 0) {
    typename ContainerT::iterator end = replacement_list.end();
    typename ContainerT::iterator it = replacement_list.begin();

        while (it != end) {
            if (T_PLACEHOLDER == token_id(*it)) {
                typename ContainerT::iterator next = it;
                ++next;
                replacement_list.erase(it);
                it = next;
            }
            else {
                ++it;
            }
        }

    // remove all 'new' leading and trailing whitespace 
        trim_replacement_list(replacement_list);
    }
}
コード例 #2
0
inline void
trim_replacement_list (ContainerT &replacement_list)
{
    using namespace boost::wave;

// strip leading whitespace
    if (replacement_list.size() > 0) {
    typename ContainerT::iterator end = replacement_list.end();
    typename ContainerT::iterator it = replacement_list.begin();

        while (it != end && IS_CATEGORY(*it, WhiteSpaceTokenType)) { 
            if (T_PLACEHOLDER != token_id(*it)) {
                typename ContainerT::iterator next = it;
                ++next;
                replacement_list.erase(it);
                it = next;
            }
            else {
                ++it;
            }
        }
    }

// strip trailing whitespace
    if (replacement_list.size() > 0) {
    typename ContainerT::reverse_iterator rend = replacement_list.rend();
    typename ContainerT::reverse_iterator rit = replacement_list.rbegin();

        while (rit != rend && IS_CATEGORY(*rit, WhiteSpaceTokenType)) 
            ++rit;

    typename ContainerT::iterator end = replacement_list.end();
    typename ContainerT::iterator it = rit.base();

        while (it != end && IS_CATEGORY(*it, WhiteSpaceTokenType)) { 
            if (T_PLACEHOLDER != token_id(*it)) {
                typename ContainerT::iterator next = it;
                ++next;
                replacement_list.erase(it);
                it = next;
            }
            else {
                ++it;
            }
        }
    }
}
コード例 #3
0
ファイル: graph_manager.cpp プロジェクト: bduvenhage/flitr
void eraseElementsIf(ContainerT& container, const PredicateT& predicate)
{
    auto iter = container.begin();
    while(iter != container.end()) {
        if(predicate(*iter) == true)  {
            iter = container.erase(iter);
        } else {
            ++iter;
        }
    }
}
コード例 #4
0
ファイル: mathutil.hpp プロジェクト: Ircher/CBoE
void erase_if(ContainerT& items, const PredicateT& predicate) {
    for(auto it = items.begin(); it != items.end();) {
		if(predicate(*it)) it = items.erase(it);
		else ++it;
    }
};