Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::from_range,std::from_range_t

      From cppreference.com
      <cpp‎ |ranges
       
       
      Ranges library
      Range adaptors
       
      Defined in header<ranges>
      struct from_range_t{explicit from_range_t()=default;};
      (since C++23)
      inlineconstexpr std::from_range_t from_range{};
      (since C++23)

      std::from_range is a disambiguation tag that can be passed to the constructors of the suitable containers to indicate that the contained member is range constructed.

      The corresponding typestd::from_range_t can be used in the constructor's parameter list to match the intended tag.

      Contents

      [edit]Standard library

      The following standard library types usestd::from_range_t type in their constructors:

      Containers library
      constructs thevector from a range
      (public member function ofstd::vector<T,Allocator>)
      constructs theinplace_vector from a range
      (public member function ofstd::inplace_vector<T,N>)
      constructs thehive from a range
      (public member function ofTemplate:cpp/container/hive/title)
      constructs thedeque from a range
      (public member function ofstd::deque<T,Allocator>)
      constructs theforward_list from a range
      (public member function ofstd::forward_list<T,Allocator>)
      constructs thelist from a range
      (public member function ofstd::list<T,Allocator>)
      constructs theset from a range
      (public member function ofstd::set<Key,Compare,Allocator>)
      constructs themap from a range
      (public member function ofstd::map<Key,T,Compare,Allocator>)
      constructs themultiset from a range
      (public member function ofstd::multiset<Key,Compare,Allocator>)
      constructs themultimap from a range
      (public member function ofstd::multimap<Key,T,Compare,Allocator>)
      constructs theunordered_set from a range
      (public member function ofstd::unordered_set<Key,Hash,KeyEqual,Allocator>)
      constructs theunordered_map from a range
      (public member function ofstd::unordered_map<Key,T,Hash,KeyEqual,Allocator>)
      constructs theunordered_multiset from a range
      (public member function ofstd::unordered_multiset<Key,Hash,KeyEqual,Allocator>)
      constructs theunordered_multimap from a range
      (public member function ofstd::unordered_multimap<Key,T,Hash,KeyEqual,Allocator>)
      constructs thepriority_queue from a range
      (public member function ofstd::priority_queue<T,Container,Compare>)
      constructs thequeue from a range
      (public member function ofstd::queue<T,Container>)
      constructs thestack from a range
      (public member function ofstd::stack<T,Container>)
      constructs theflat_set from a range
      (public member function ofstd::flat_set<Key,Compare,KeyContainer>)
      constructs theflat_map from a range
      (public member function ofstd::flat_map<Key,T,Compare,KeyContainer,MappedContainer>)
      constructs theflat_multiset from a range
      (public member function ofstd::flat_multiset<Key,Compare,KeyContainer>)
      constructs theflat_multimap from a range
      (public member function ofstd::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>)
      Strings library
      constructs thebasic_string from a range
      (public member function ofstd::basic_string<CharT,Traits,Allocator>)

      [edit]Notes

      Feature-test macroValueStdFeature
      __cpp_lib_containers_ranges202202L(C++23)Tagged constructors to construct fromcontainer compatible range

      [edit]Example

      Run this code
      #include <cassert>#include <string> int main(){#ifdef __cpp_lib_containers_rangesautoconst range={0x43,43,43};std::string str{std::from_range, range};// uses tagged constructorassert(str=="C++");#endif}

      [edit]See also

      in-place construction tag
      (tag)[edit]
      indicates that elements of a range are sorted (uniqueness is not required)
      (tag)[edit]
      indicates that elements of a range are sorted and unique
      (tag)[edit]
      (C++23)
      constructs a new non-view object from an input range
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/from_range&oldid=182042"

      [8]ページ先頭

      ©2009-2025 Movatter.jp