本文整理汇总了C++中std::forward_list::front方法的典型用法代码示例。如果您正苦于以下问题:C++ forward_list::front方法的具体用法?C++ forward_list::front怎么用?C++ forward_list::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::forward_list
的用法示例。
在下文中一共展示了forward_list::front方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: longjmp
void
throw_exception_sjlj (const struct gdb_exception &exception)
{
/* Jump to the nearest CATCH_SJLJ block, communicating REASON to
that call via setjmp's return value. Note that REASON can't be
zero, by definition in common-exceptions.h. */
exceptions_state_mc (CATCH_THROWING);
enum return_reason reason = exception.reason;
catchers.front ().exception = exception;
longjmp (catchers.front ().buf, reason);
}
示例2: get
void get(int k){
termStack.sort(std::greater<node>());
for(int i=0; i<k; i++){
cout<<termStack.front().t<<endl;
termStack.pop_front();
}
}
示例3: foldr_dest
U foldr_dest(std::function< U (U, T)>& op, const U& val, std::forward_list<T>& L)
{
if (L.empty()) return U(val);
T h = L.front();
L.pop_front();
return op (foldr(op, val, L), h);
}
示例4: runDeferred
bool runDeferred() {
__EVENTEMITTER_LOCK_GUARD(mutex);
if(deferredQueue.empty()) {
return false;
}
(deferredQueue.front())();
deferredQueue.pop_front();
return true;
}
示例5:
static ptid_t
fbsd_next_vfork_done (void)
{
if (!fbsd_pending_vfork_done.empty ())
{
ptid_t ptid = fbsd_pending_vfork_done.front ();
fbsd_pending_vfork_done.pop_front ();
return ptid;
}
return null_ptid;
}
示例6: add
void add(string term){
if(terms.find(term) == terms.end()){
node *n = new node;
n->t=term;
n->i=1;
termStack.push_front(*n);
terms[term]=&termStack.front();
}
else{
terms[term]->i++;
}
}
示例7: rReturn
//Using recursion
int rReturn(std::forward_list<int> l, int n){
static int i = 0;
if(i == n)
return l.front();
if(!l.empty())
{
int a = l.front();
l.pop_front();
rReturn(l, n);
l.push_front(a);
i++;
}
}
示例8: rReverse
void rReverse(std::forward_list<int> &l){
if(!l.empty()){
a = l.front();
l.pop_front(); //Remove all elements until empty
rReverse(l);
}else{
l.push_front(a); //Insert elements from the function stack
}
}
示例9:
TEST(std_forward_list, emplace_front) {
std::forward_list<std::pair<int, int>> l1{
std::pair<int, int>{1, 2},
std::pair<int, int>{2, 3},
std::pair<int, int>{3, 4},
};
l1.emplace_front(0, 1);
const std::forward_list<std::pair<int, int>> l2{
std::pair<int, int>{0, 1},
std::pair<int, int>{1, 2},
std::pair<int, int>{2, 3},
std::pair<int, int>{3, 4},
};
ASSERT_TRUE(l1 == l2);
const std::pair<int, int> v1{0, 1};
ASSERT_EQ(v1, l2.front());
}
示例10:
int
exceptions_state_mc_catch (struct gdb_exception *exception,
int mask)
{
*exception = std::move (catchers.front ().exception);
catchers.pop_front ();
if (exception->reason < 0)
{
if (mask & RETURN_MASK (exception->reason))
{
/* Exit normally and let the caller handle the
exception. */
return 1;
}
/* The caller didn't request that the event be caught, relay the
event to the next exception_catch/CATCH_SJLJ. */
throw_exception_sjlj (*exception);
}
/* No exception was thrown. */
return 0;
}
示例12:
list.PushBack(18);
return list.CopyToArray();
}
}//namespace
const std::vector<int> EXPECTED_SORTED_INSERT_ARRAY = { -8, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 15, 18};
SIMPLE_BENCHMARK(testSortedInsert, SAMPLE_ARRAY);
SIMPLE_TEST(testSortedInsert, TestSample, EXPECTED_SORTED_INSERT_ARRAY, SAMPLE_ARRAY);
const std::forward_list<int> EMPTY_LIST = {};
const std::forward_list<int> SINGLE_ITEM_LIST = {5};
const std::forward_list<int> EXPECTED2 = {2, 5};
const std::forward_list<int> EXPECTED3 = {5, 8};
const std::forward_list<int> SAMPLE_LIST = {EXPECTED_SORTED_INSERT_ARRAY.cbegin(), EXPECTED_SORTED_INSERT_ARRAY.cend()};
const std::forward_list<int> EXPECTED4 = { -8, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15, 18};
SIMPLE_BENCHMARK(SortedInsert_STL, SAMPLE_LIST, 10);
SIMPLE_TEST(SortedInsert_STL, TestSample1, SINGLE_ITEM_LIST, EMPTY_LIST, SINGLE_ITEM_LIST.front());
SIMPLE_TEST(SortedInsert_STL, TestSample2, EXPECTED2, SINGLE_ITEM_LIST, EXPECTED2.front());
SIMPLE_TEST(SortedInsert_STL, TestSample3, EXPECTED3, SINGLE_ITEM_LIST, 8);
SIMPLE_TEST(SortedInsert_STL, TestSample4, EXPECTED4, SAMPLE_LIST, 10);
示例13: switch
static int
exceptions_state_mc (enum catcher_action action)
{
switch (catchers.front ().state)
{
case CATCHER_CREATED:
switch (action)
{
case CATCH_ITER:
/* Allow the code to run the catcher. */
catchers.front ().state = CATCHER_RUNNING;
return 1;
default:
internal_error (__FILE__, __LINE__, _("bad state"));
}
case CATCHER_RUNNING:
switch (action)
{
case CATCH_ITER:
/* No error/quit has occured. */
return 0;
case CATCH_ITER_1:
catchers.front ().state = CATCHER_RUNNING_1;
return 1;
case CATCH_THROWING:
catchers.front ().state = CATCHER_ABORTING;
/* See also throw_exception. */
return 1;
default:
internal_error (__FILE__, __LINE__, _("bad switch"));
}
case CATCHER_RUNNING_1:
switch (action)
{
case CATCH_ITER:
/* The did a "break" from the inner while loop. */
return 0;
case CATCH_ITER_1:
catchers.front ().state = CATCHER_RUNNING;
return 0;
case CATCH_THROWING:
catchers.front ().state = CATCHER_ABORTING;
/* See also throw_exception. */
return 1;
default:
internal_error (__FILE__, __LINE__, _("bad switch"));
}
case CATCHER_ABORTING:
switch (action)
{
case CATCH_ITER:
{
/* Exit normally if this catcher can handle this
exception. The caller analyses the func return
values. */
return 0;
}
default:
internal_error (__FILE__, __LINE__, _("bad state"));
}
default:
internal_error (__FILE__, __LINE__, _("bad switch"));
}
}
示例14: add_follower
int add_follower(const std::string& base, const std::string& filter, Object& response)
{
m_following.emplace_front(new PulleySyncRepl(base, filter, m_parser));
m_following.front()->execute(*m_connection, &response);
return 0;
}
示例15: getMin
int getMin() {
return mins_.front();
}