C++ åèæå
- C++11
- C++14
- C++17
- C++20
- C++ ç¼è¯å¨æ¯ææ åµè¡¨
- ç¬ç«ä¸å®¿ä¸»å®ç°
- C++ è¯è¨
- C++ å ³é®è¯
- é¢å¤çå¨
- C++ æ ååºå¤´æä»¶
- å ·åè¦æ±
- åè½ç¹æ§æµè¯ (C++20)
- å·¥å ·åº
- ç±»åæ¯æï¼åºæ¬ç±»åãRTTIãç±»åç¹æ§ï¼
- æ¦å¿µåº (C++20)
- std::common_reference_with
- std::convertible_to
- std::same_as
- std::derived_from
- std::common_with
- std::integral
- std::signed_integral
- std::unsigned_integral
- std::floating_point
- std::swappable, std::swappable_with
- std::destructible
- std::constructible_from
- std::default_initializable
- std::move_constructible
- std::copy_constructible
- std::assignable_from
- std::equality_comparable, std::equality_comparable_with
- std::totally_ordered, std::totally_ordered_with
- std::movable
- std::copyable
- std::semiregular
- std::regular
- std::invocable, std::regular_invocable
- std::predicate
- std::relation
- std::equivalence_relation
- std::strict_weak_order
- boolean-testable
- 注é
- é误å¤ç
- 卿å å管ç
- æ¥æåæ¶é´å·¥å ·
- å符串åº
- 容å¨åº
- è¿ä»£å¨åº
- èå´åº (C++20)
- ç®æ³åº
- æ°å¼åº
- è¾å ¥/è¾åºåº
- æä»¶ç³»ç»åº
- æ¬å°ååº
- æ£å表达å¼åº
- ååæä½åº
- çº¿ç¨æ¯æåº
- å®éªæ§ C++ ç¹æ§
- æç¨çèµæº
- ç´¢å¼
- std 符å·ç´¢å¼
- åç¨æ¯æ (C++20)
- C++ å ³é®è¯
ä½ç½®ï¼é¦é¡µ > C++ åèæå >æ¦å¿µåº (C++20) > std::semiregular
std::semiregular
| å®ä¹äºå¤´æä»¶ <concepts>
|
||
| template <class T> concept semiregular = std::copyable<T> && std::default_initializable<T>; |
(C++20 èµ·) | |
semiregular æ¦å¿µæå®ç±»åæ¢ä¸ºå¯å¤å¶äº¦ä¸ºå¯é»è®¤æé ã表ç°ç±»ä¼¼å¦ int çå
建类åçç±»åæ»¡è¶³å®ï¼é¤äºå®ä»¬ä¸éè¦æ¯æä»¥ == æ¯è¾ã
示ä¾
è¿è¡æ¤ä»£ç
#include <concepts> #include <iostream> Â template<std::semiregular T> struct Single { T value; }; Â int main() { Single<int> myInt1{4}; Single<int> myInt2; myInt2 = myInt1; Â std::cout << myInt1.value << ' ' << myInt2.value << '\n'; }
è¾åºï¼
4 4