C++ åèæå
- C++11
- C++14
- C++17
- C++20
- C++ ç¼è¯å¨æ¯ææ åµè¡¨
- ç¬ç«ä¸å®¿ä¸»å®ç°
- C++ è¯è¨
- C++ å ³é®è¯
- é¢å¤çå¨
- C++ æ ååºå¤´æä»¶
- å ·åè¦æ±
- åè½ç¹æ§æµè¯ (C++20)
- å·¥å ·åº
- ç±»åæ¯æï¼åºæ¬ç±»åãRTTIãç±»åç¹æ§ï¼
- æ¦å¿µåº (C++20)
- é误å¤ç
- 卿å å管ç
- æ¥æåæ¶é´å·¥å ·
- å符串åº
- 容å¨åº
- std::array
- std::vector
- std::map
- std::unordered_map
- std::priority_queue
- std::span
- std::forward_list
- std::forward_list<T,Allocator>::forward_list
- std::forward_list<T,Allocator>::~forward_list
- std::forward_list<T,Allocator>::operator=
- std::forward_list<T,Allocator>::unique
- std::forward_list<T,Allocator>::reverse
- std::forward_list<T,Allocator>::sort
- std::forward_list çæ¨å¯¼æå¼
- std::forward_list<T,Allocator>::merge
- std::forward_list<T,Allocator>::splice_after
- std::forward_list<T,Allocator>::remove, remove_if
- operator==,!=,<,<=,>,>=,<=>(std::forward_list)
- std::swap(std::forward_list)
- std::erase, std::erase_if (std::forward_list)
- std::forward_list<T,Allocator>::swap
- std::forward_list<T,Allocator>::erase_after
- std::forward_list<T,Allocator>::push_front
- std::forward_list<T,Allocator>::emplace_front
- std::forward_list<T,Allocator>::pop_front
- std::forward_list<T,Allocator>::resize
- std::forward_list<T,Allocator>::empty
- std::forward_list<T,Allocator>::max_size
- std::forward_list<T,Allocator>::clear
- std::forward_list<T,Allocator>::insert_after
- std::forward_list<T,Allocator>::emplace_after
- std::forward_list<T,Allocator>::begin, std::forward_list<T,Allocator>::cbegin
- std::forward_list<T,Allocator>::end, std::forward_list<T,Allocator>::cend
- std::forward_list<T,Allocator>::assign
- std::forward_list<T,Allocator>::get_allocator
- std::forward_list<T,Allocator>::front
- std::forward_list<T,Allocator>::before_begin, cbefore_begin
- std::deque
- std::list
- std::set
- std::multiset
- std::multimap
- std::unordered_set
- std::unordered_multiset
- std::unordered_multimap
- std::stack
- std::queue
- std::vector<bool>
- ç»ç¹ææ (C++17)
- 注é
- è¿ä»£å¨åº
- èå´åº (C++20)
- ç®æ³åº
- æ°å¼åº
- è¾å ¥/è¾åºåº
- æä»¶ç³»ç»åº
- æ¬å°ååº
- æ£å表达å¼åº
- ååæä½åº
- çº¿ç¨æ¯æåº
- å®éªæ§ C++ ç¹æ§
- æç¨çèµæº
- ç´¢å¼
- std 符å·ç´¢å¼
- åç¨æ¯æ (C++20)
- C++ å ³é®è¯
ä½ç½®ï¼é¦é¡µ > C++ åèæå >容å¨åº >std::forward_list > std::forward_list<T,Allocator>::empty
std::forward_list<T,Allocator>::empty
| bool empty() const noexcept; |
(C++11 èµ·) (C++20 å) |
|
| [[nodiscard]] bool empty() const noexcept; |
(C++20 èµ·) | |
æ£æ¥å®¹å¨æ¯å¦æ å ç´ ï¼å³æ¯å¦ begin() == end() ã
åæ°
ï¼æ ï¼
è¿åå¼
è¥å®¹å¨ä¸ºç©ºå为 true ï¼å¦å为 false
å¤æåº¦
常æ°ã
示ä¾
ä¸å代ç ç¨ empty æ£æ¥ std::forward_list<int> æ¯å¦å«ä»»ä½å
ç´ ï¼
è¿è¡æ¤ä»£ç
#include <forward_list> #include <iostream> Â int main() { std::forward_list<int> numbers; std::cout << "Initially, numbers.empty(): " << numbers.empty() << '\n'; Â numbers.push_front(42); numbers.push_front(13317); std::cout << "After adding elements, numbers.empty(): " << numbers.empty() << '\n'; }
è¾åºï¼
Initially, numbers.empty(): 1 After adding elements, numbers.empty(): 0