C++ åèæå
- C++11
- C++14
- C++17
- C++20
- C++ ç¼è¯å¨æ¯ææ åµè¡¨
- ç¬ç«ä¸å®¿ä¸»å®ç°
- C++ è¯è¨
- C++ å ³é®è¯
- é¢å¤çå¨
- C++ æ ååºå¤´æä»¶
- å ·åè¦æ±
- åè½ç¹æ§æµè¯ (C++20)
- å·¥å ·åº
- ç±»åæ¯æï¼åºæ¬ç±»åãRTTIãç±»åç¹æ§ï¼
- æ¦å¿µåº (C++20)
- é误å¤ç
- 卿å å管ç
- æ¥æåæ¶é´å·¥å ·
- å符串åº
- std::basic_string
- std::basic_string<CharT,Traits,Allocator>::npos
- std::basic_string<CharT,Traits,Allocator>::at
- std::hash (std::string, std::wstring, std::u16string, std::u32string, std::pmr::string, std::pmr::wstring, std::pmr::u16string, std::pmr::u32string)
- std::basic_string<CharT,Traits,Allocator>::assign
- std::basic_string<CharT,Traits,Allocator>::get_allocator
- std::basic_string<CharT,Traits,Allocator>::substr
- std::basic_string<CharT,Traits,Allocator>::basic_string
- std::basic_string<CharT,Traits,Allocator>::operator=
- std::basic_string<CharT,Traits,Allocator>::operator[]
- std::basic_string<CharT,Traits,Allocator>::front
- std::basic_string<CharT,Traits,Allocator>::back
- std::basic_string<CharT,Traits,Allocator>::data
- std::basic_string<CharT,Traits,Allocator>::c_str
- std::basic_string<CharT,Traits,Allocator>::operator basic_string_view
- std::basic_string<CharT,Traits,Allocator>::begin, std::basic_string<CharT,Traits,Allocator>::cbegin
- std::basic_string<CharT,Traits,Allocator>::end, std::basic_string<CharT,Traits,Allocator>::cend
- std::basic_string<CharT,Traits,Allocator>::rbegin, std::basic_string<CharT,Traits,Allocator>::crbegin
- std::basic_string<CharT,Traits,Allocator>::rend, std::basic_string<CharT,Traits,Allocator>::crend
- std::basic_string<CharT,Traits,Allocator>::empty
- std::basic_string<CharT,Traits,Allocator>::size, std::basic_string<CharT,Traits,Allocator>::length
- std::basic_string<CharT,Traits,Allocator>::max_size
- std::basic_string<CharT,Traits,Allocator>::reserve
- std::basic_string<CharT,Traits,Allocator>::capacity
- std::basic_string<CharT,Traits,Allocator>::shrink_to_fit
- std::basic_string<CharT,Traits,Allocator>::clear
- std::basic_string<CharT,Traits,Allocator>::insert
- std::basic_string<CharT,Traits,Allocator>::erase
- std::basic_string<CharT,Traits,Allocator>::push_back
- std::basic_string<CharT,Traits,Allocator>::pop_back
- std::basic_string<CharT,Traits,Allocator>::append
- std::basic_string<CharT,Traits,Allocator>::operator+=
- std::basic_string<CharT,Traits,Allocator>::compare
- std::basic_string<CharT,Traits,Allocator>::starts_with
- std::basic_string<CharT,Traits,Allocator>::ends_with
- std::basic_string<CharT,Traits,Allocator>::replace
- std::basic_string<CharT,Traits,Allocator>::copy
- std::basic_string<CharT,Traits,Allocator>::resize
- std::basic_string<CharT,Traits,Allocator>::swap
- std::basic_string<CharT,Traits,Allocator>::find
- std::basic_string<CharT,Traits,Allocator>::rfind
- std::basic_string<CharT,Traits,Allocator>::find_first_of
- std::basic_string<CharT,Traits,Allocator>::find_first_not_of
- std::basic_string<CharT,Traits,Allocator>::find_last_of
- std::basic_string<CharT,Traits,Allocator>::find_last_not_of
- std::operator+(std::basic_string)
- std::swap(std::basic_string)
- std::literals::string_literals::operator""s
- std::erase, std::erase_if (std::basic_string)
- operator<<,>>(std::basic_string)
- std::getline
- operator==,!=,<,<=,>,>=,<=>(std::basic_string)
- std::stoi, std::stol, std::stoll
- std::stoul, std::stoull
- std::stof, std::stod, std::stold
- std::to_string
- std::to_wstring
- std::basic_string çæ¨å¯¼æå¼
- std::basic_string_view
- ç©ºç»æ¢åèå符串
- ç©ºç»æ¢å¤åèå符串
- ç©ºç»æ¢å®½å符串
- std::char_traits
- 注é
- 容å¨åº
- è¿ä»£å¨åº
- èå´åº (C++20)
- ç®æ³åº
- æ°å¼åº
- è¾å ¥/è¾åºåº
- æä»¶ç³»ç»åº
- æ¬å°ååº
- æ£å表达å¼åº
- ååæä½åº
- çº¿ç¨æ¯æåº
- å®éªæ§ C++ ç¹æ§
- æç¨çèµæº
- ç´¢å¼
- std 符å·ç´¢å¼
- åç¨æ¯æ (C++20)
- C++ å ³é®è¯
ä½ç½®ï¼é¦é¡µ > C++ åèæå >åç¬¦ä¸²åº >std::basic_string > std::stof, std::stod, std::stold
std::stof, std::stod, std::stold
| å®ä¹äºå¤´æä»¶ <string>
|
||
| float    stof( const std::string& str, std::size_t* pos = 0 ); float    stof( const std::wstring& str, std::size_t* pos = 0 ); |
(1) | (C++11 èµ·) |
| double    stod( const std::string& str, std::size_t* pos = 0 ); double    stod( const std::wstring& str, std::size_t* pos = 0 ); |
(2) | (C++11 èµ·) |
| long double stold( const std::string& str, std::size_t* pos = 0 ); long double stold( const std::wstring& str, std::size_t* pos = 0 ); |
(3) | (C++11 èµ·) |
è½¬è¯ string str ä¸çæµ®ç¹å¼ã
| (C++17 å) | |
| (C++17 èµ·) |
彿°ä¼èå¼ä»»ä½ç©ºç½ç¬¦ï¼ç± std::isspace() ç¡®å®ï¼ï¼ç´è³æ¾å°é¦ä¸ªé空ç½ç¬¦ãç¶åå®ä¼åç¨å°½å¯è½å¤çå符ï¼ä»¥ææåæ³çæµ®ç¹æ°è¡¨ç¤ºï¼å¹¶å°å®ä»¬è½¬æ¢ææµ®ç¹å¼ãåæ³çæµ®ç¹å¼å¯ä»¥ä¸ºä¸åä¹ä¸ï¼
- åè¿å¶æµ®ç¹æ°è¡¨è¾¾å¼ãå®ç±ä¸åé¨åç»æï¼
- (å¯é) æ£æè´å·
- é空çåè¿å¶æ°ååºåï¼å¯éå°å å«ä¸ä¸ªå°æ°ç¹å符ï¼ç±å½åç C æ¬å°ç¯å¢ç¡®å®ï¼ï¼å®ä¹æææ°åï¼
- (å¯é)
eæEï¼å¹¶è·éå¯éçæ£æè´å·ï¼ä»¥åé空åè¿å¶æ°ååºåï¼ä»¥ 10 为åºå®ä¹ææ°ï¼
- äºè¿å¶æµ®ç¹æ°è¡¨è¾¾å¼ãå®ç±ä¸åé¨åç»æï¼
- (å¯é) æ£æè´å·
-
0xæ0X - é空çåå è¿å¶æ°ååºåï¼éå°å å«ä¸ä¸ªå°æ°ç¹å符ï¼ç±å½åç C æ¬å°ç¯å¢ç¡®å®ï¼ï¼å®ä¹æææ°åï¼
- (å¯é)
pæPï¼å¹¶è·éå¯éçæ£æè´å·ï¼ä»¥åé空åè¿å¶æ°ååºåï¼ä»¥ 2 为åºå®ä¹ææ°ï¼
- æ 穷大表达å¼ãå®ç±ä¸åé¨åç»æï¼
- (å¯é) æ£æè´å·
-
INFæINFINITYï¼å¿½ç¥å¤§å°å
- éæ°ï¼NaNï¼è¡¨è¾¾å¼ãå®ç±ä¸åé¨åç»æï¼
- (å¯é) æ£æè´å·
-
NANæNAN(char_sequence)ï¼å¿½ç¥NANé¨åç大å°åã char_sequence åªè½ç±æ°åãæä¸åæ¯åä¸å线ææãç»ææ¯ä¸ä¸ªå®éç NaN æµ®ç¹å¼ã
- ä»»ä½å ¶ä»å¯ç±å½å C æ¬å°ç¯å¢æ¥åç表达å¼
è¥ pos 䏿¯ç©ºæéï¼å对äºè½¬æ¢å½æ°ä¸ºå
é¨çæé ptr å°æ¥å str.c_str() ä¸é¦ä¸ªæªè½¬æ¢å符çå°åï¼ç¶å计ç®è¯¥å符ç䏿 å¹¶åå¨ä¹äº *pos ï¼ç»åºè½¬æ¢å¤ççå符æ°ã
åæ°
| str | - | è¦è½¬æ¢ç string |
| pos | - | åå¨å·²å¤çå符æ°çæ´æ°çå°å |
è¿åå¼
转æ¢ä¸ºæå®æµ®ç¹ç±»åçå符串ã
å¼å¸¸
è¥ä¸è½è¿è¡è½¬æ¢å为 std::invalid_argument ã
è¥è½¬æ¢åçå¼ä¼è½å¨ç»æç±»åçèå´å¤ï¼æè¥åºå±å½æ°ï¼ strtof ã (C++17 èµ·)strtod æ strtold ï¼è®¾ç½® errno 为 ERANGE å为 std::out_of_range ã
åé
| (C++11)(C++11)(C++11) |
转æ¢å符串为æç¬¦å·æ´æ° (彿°) |
| (C++11)(C++11) |
转æ¢å符串为æ ç¬¦å·æ´æ° (彿°) |
| (C++17) |
转æ¢å符åºåå°æ´æ°ææµ®ç¹å¼ (彿°) |