本文整理汇总了C++中std::forward_list::cbefore_begin方法的典型用法代码示例。如果您正苦于以下问题:C++ forward_list::cbefore_begin方法的具体用法?C++ forward_list::cbefore_begin怎么用?C++ forward_list::cbefore_begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::forward_list
的用法示例。
在下文中一共展示了forward_list::cbefore_begin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runDeferred
void runDeferred(DeferredHandler f) {
__EVENTEMITTER_LOCK_GUARD(mutex);
auto it = deferredQueue.cbegin();
auto prevIt = deferredQueue.cbefore_begin();
for(; it != deferredQueue.cend(); prevIt = it, ++it);
deferredQueue.emplace_after(prevIt, std::move(f));
}
示例2: operator
inline int operator () (EArgs&&... args) // O(n)
{
if(slots.empty())
return default_return_value;
auto it = slots.cbegin(), end = slots.cend();
auto prev = slots.cbefore_begin();
while(it != end)
{
try
{
(it->second)(std::forward<EArgs>(args)...);
prev = it;
++it;
}
catch(slot_remove)
{
it = slots.erase_after(prev);
}
catch(signal_return e)
{
return e.get();
}
}
return default_return_value;
}
示例3: disconnect
inline bool disconnect(connection_type con) // O(n)
{
auto it = slots.cbegin(), end = slots.cend();
auto prev = slots.cbefore_begin();
while(it != end)
{
if(it == con)
{
slots.erase_after(prev);
return true;
}
prev = it;
++it;
}
return false;
}
示例4: connect
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)));
}