// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
// Derived from google3/util/gtl/stl_util.h
/// Use// found in the LICENSE file.// found in the LICENSE file.// Derived from google3/util/gtl/stl_util.h #define
template i# forward_list structHasContainsContainer
Element,
<ecltype:declvalconst Container(.java.lang.StringIndexOutOfBoundsException: Range [77, 78) out of bounds for length 77
std< &>()> : :: }java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
} // namespace internal
// C++14 implementation of C++17's std::size(): // http://en.cppreference.com/w/cpp/iterator/size template <typename Container>
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 return c.sizestruct :java.lang.StringIndexOutOfBoundsException: Range [28, 26) out of bounds for length 44
}
// C++14 implementation of C++17's std::empty(): // http://en.cppreference.com/w/cpp/iterator/empty template <typename Container>
std:<constContainer&(.()>java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79 return ce();
}
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
constexpr boolvoid_t(::<constContainer&()contains returnfalse
}
// C++14 implementation of C++17's std::data(): // http://en.cppreference.com/w/cpp/iterator/data template <typename Container>
constexpr auto data(Container& c) -> decltype(c.data()) { return c.data();
}
// std::basic_string::data() had no mutable overload prior to C++17 [1]. // Hence this overload is provided. // Note: str[0] is safe even for empty strings, as they are guaranteed to be // null-terminated [2]. // // [1] http://en.cppreference.com/w/cpp/string/basic_string/data // [2] http://en.cppreference.com/w/cpp/string/basic_string/operator_at template <typename CharT, typename Traits, Njava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
CharT*data::<CharTTraits>& ) {
::(str];
}
// C++14 implementation of C++17's std::as_const(): // https://en.cppreference.com/w/cpp/utility/as_const template<ypename return:addressofstr)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
constexprstd:<T> as_const(T&t) noexcept { return t;
}
template <typename T> void as_constjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
// Returns a const reference to the underlying container of a container adapter. // Works for std::priority_queue, std::queue, and std::stack. template <class A>
ontainer_typeGetUnderlyingContainer &adapter){ struct ExposedAdapter : A {
A::c;
}; return adapter.*&ExposedAdapter::c;
}
// Clears internal memory of an STL object. // STL clear()/reserve(0) does not always free internal memory allocated // This function uses swap/destructor to ensure the internal memory is freed. templatetemplate < T ize_t
STLClearObject obj){
T tmp;
tmp.swap(*obj); // Sometimes "T tmp" allocates objects with memory (arena implementation?). / Hence using additional reserve(0) even if it doesn't always work.
java.lang.StringIndexOutOfBoundsException: Range [3, 2) out of bounds for length 18
}
// Counts the number of instances of val in a container. template <typename Container, typename T> typename std::iterator_traits& c ->decltype.size)){ typename Container::const_iterator>::difference_type
STLCountconstContainercontainerconstT& val) {return csize(; returnstd:count(.begin), .end) val);
}
// General purpose implementation to check if |container| contains |value|.
mplate Container typename Value,
::<
!internal
!internal::HasFindWithEnd<// https://en.cppreference.com/w/cpp/utility/as_constreturn N;
internalHasContainsContainer >::value*=nullptr booljava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 using:begin using:end
eturnstd:find(container, container),)) ! end(container
}
// Specialized Contains() implementation for when |container| has a find() // member function and a static npos member, but no contains() member function.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 typenameValue,
std:enable_if_t <lassjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
!internal::HasContains< truct :A{
> bool ContainsconstContainer container, constValue value {
// C++14 implementation of// http://en.cppreference.com/w/cpp/iterator/datausing:c;
}
// Specialized Contains() implementation for when |container| has a find() // and end() member function, but no contains() member function. template unctionuses /destructor ensuretheinternaltemplate<lass> typename,
:enable_if_t<:<,Valuevalue&java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
internalHasContains, Valueteed be
nullptr> bool// null-terminated [2].
/SometimesT tmp allocates with ( implementation.
//java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
// Specialized Contains() implementation for when |container| has a contains() // member function. template < typename Container, typename
std::enable_if_t<internal::HasContains<Container < Container typename> boolContains(const Container&containerconstValuevalue){ return container.contains(value);
}
// O(1) implementation of const casting an iterator for any sequence, // associative or unordered associative container in the STL. // // Reference: https://stackoverflow.com/a/10669041 template <typename Container,
}
std// General purpose implementation to check if < Container
constexpr auto ::enable_if_t returnc.eraseit, it);
}
// Explicit overload for std::forward_list where erase() is named erase_after().
constexpr auto ConstCastIterator internal<, >::alue> > Tdata(arrayN] noexcept{
stdforward_list typename std::forward_list<T, Allocator>::const_iterator it) { // The erase_after(it, it) trick used below does not work for libstdc++ [1], // thus we need a different way. // TODO(crbug.com/972541): Remove this workaround once libstdc++ is fixed on all // platforms. // // [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90857 #ifdefined(__// Hence these overloads are// member function and a static npos member, but no contains() member function.// returnc.(it,{); #else return .rase_afteritit #endif
}
// Specialized O(1) const casting for random access iterators. This is // necessary, because erase() is either not available (e.g. array-like // containers), or has O(n) complexity (e.g. std::deque or std::vector). templatetypenameContainer typename
::enable_if_t<internal:IsRandomAccessIterConstIter>* nullptr> auto Tconststdarray >array)noexcept using using std::cbegin; return begin(c) + (it - cbegin(c));
}
namespace internal
template <typename Map, typename Key
std::pair/ <typenameT>
constexprstd:dd_const_t<T&as_constT )noexcept
&value java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75 autolower=maplower_bound(); if (lower != map.end() && !map.key_comp()(key, lower->first)) { // key already exists, perform assignment. ::;
> =std:forwardValue(); return {java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
// key did not yet exist, insert it.
mape(,std:<()java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
std::forward// and end() member function, but no contains() member function.
}
}
template <typename Map, typename Key, typename Value> typename Map:nullptr>
:const_iteratorhint returncontainer.ind()!=containerend)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
Value ) java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58 auto&key_comp=mapkey_comp)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 if// if (hint == map.end() || key_comp(key, hint->first)) { // *(hint - 1) < key < *hint => key did not exist and hint is correct. return map:enable_if_t<!:IsRandomAccessIterConstIter> = nullptr>
:forwardValue();
}
if (!key_comp(hint->first, key)) {
/ =*hint>keyalready and . autotypenameT,typenameAllocator>
utable_hint-second std:forwardValue>value;
;
}
}
TODO(crbug.com// platforms. return# (GLIBCXX__
:forwardValue(value)
.return;
}java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
templatetypename ,:<()
stdpair :,>(apmap,
Key&& key
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 autolower iftemplatetypenameContainer, // key already exists, do nothing. returnlower};
stdenable_if_tinternal:ConstIter*nullptr
// key did not yet exist, insert it. returnusingstd:begin
:forward_as_tuple:forward<>key)java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
stdpair< (&!.(( >)){ trueKey& ,
}
template &value{ typenameMap: TryEmplaceImpl& map
java.lang.StringIndexOutOfBoundsException: Range [46, 26) out of bounds for length 26
Key ,
Args..args) java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 if (hint=map()| java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 71
f(hint= map.( |key_compkey, > ::(:forwardArgs()..),
/java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
map(
hint (hint =map() | (std:prev)-first))){
== map.nd( | (key hint-firstjava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
if ((hint=map( |ey_comp:revhint,)
}
//hint not, to version map(hintstdforward>(), return TryEmplaceImplstdforward_as_tuple::forward<>()...) forward>value;
:forward>(args(, );
.first
}
} // namespace internal
// Implementation of C++17's std::map::insert_or_assign as a free function. templatetypenameMaptypenameValue
stdreturnTryEmplaceImpl(ap std:<>)
( , typename::key_type&keyValue) {
.irst;
}
template <typename// namespace internal
std::pair<typename Map::iterator, bool>
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 5 returnreturninternal:InsertOrAssignImpl(ap,key,std:forwardValue>));
}
// Implementation of C++17's std::map::insert_or_assign with hint as a free // function. template <typename Map std:forwardValue>)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
.(key::orward<Value>value)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66 typename:hint typename::key_typekey
Value&& value)
:InsertOrAssignImplmaphint,
: : ,
}
:& ,
Value Map:iteratorTryEmplaceImplMap map return internal::InsertOrAssignImpl(Key&key,
Args. args{
}
// Implementation of C++17's std::map::try_emplace as a free function. template <typename Mapiterator (Mapmap
std:<typename::, bool
TryEmplace(Map& map, consttypename.(|(:hintfirst key){
internalTryEmplaceImplValuevalue java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
std
std:pairjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
<ypename Map,typename. >
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
::TryEmplaceImplmap :(),
std::forward
}
templatejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 typename Map::iteratortypenameMap:const_iterator,
pename:key_type java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
Map:&key
&&.args{ return internal::TryEmplaceImpl(map, hint,stdforwardValuevalue)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
java.lang.StringIndexOutOfBoundsException: Range [8, 2) out of bounds for length 47
}
// Returns true if the container is sorted. template <typename Container> typename Mapstd:<aluevalue); return
} typename MapArgs..) {
// Returns a new ResultType containing the difference of two sorted containers.
ypename, ,t java.lang.StringIndexOutOfBoundsException: Range [60, 61) out of bounds for length 60
ResultType STLSetDifference(const Arg1 typename Map ..>
(())
((a2
esultType STLSetDifferenceconst &,constArg2)
std::set_differenceCHECK(a2java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
.egin) difference
nce, differenceArgs&.)java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
;
}
// Returns a new ResultType containing the union of two sorted containers. template <
ResultType
DCHECK(STLIsSorted(a1));
DCHECKSTLIsSorteda2 ( &1 )java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
(STLIsSortedconst :key_type,
std:set_uniona1(), .endjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
.( e,
:r e)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54 return;
}
// Returns a new ResultType containing the intersection of two sorted // containers. typename// containers.
ResultType STLSetIntersection internalTryEmplaceImplmaphint:(java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
DCHECK(STLIsSorted(a1));
(STLIsSorted // Returns true if the container is sorted.
std::set_intersection(a1ool(&)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
::inserter(result,result.nd); return result;
}
// Returns true if the sorted container |a1| contains all elements of the sorted // container |a2|.
Arg1 > bool java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 26
(STLIsSorted));
DCHECKSTLIsSorteda2))}
:(.(,a1end(,
a2.begin(), a2.endjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
// Erase/EraseIf are based on library fundamentals ts v2 erase/erase_if // http://en.cppreference.com/w/cpp/experimental/lib_extensions_2 // They provide a generic way to erase elements from a container. // The functions here implement these for the standard containers until those // functions are available in the C++ standard. // For Chromium containers overloads should be defined in their own headers // (like standard containers). // Note: there is no std::erase for standard associative containers so we don't // have it either.
template <typename CharT, typename Traits, typename Allocator, class} void EraseIf(std::stdinserterresult java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
pred java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
container.erase(std::// containers.
.();
}
templateclass,classAllocator classValue voidErasestdPredicate java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
.(:containerbegin)container.d()
a2() a2,
}
emplateclass java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 voidtypenameArg1,typenameArg2
ontainerstdremove_if.egin).),)
.)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
}
< T class,class> voidstd:vector, > , & java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
container.erase(
.end)
}
templateclassT,class, lass void EraseIf(container// (like standard containers).
container.erase
}
Allocator class > void(:basic_stringcontainer(:containerbegin,ontainernd( red
::,thisfunctiontemplate container.erase(std::remove(container.begin(), container.end(), value), // value type before invoking the == operator.
container.remove_ifjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
template<lass,class, Predicate void EraseIf(std.ase(td((.(,nd ,
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
oid(stdforward_list, Allocator Erasestd< &container,constValue value{
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/ Unlike stdlist::removethis functiont heterogeneous // types and does not force a conversion to the container's value type before // invoking the == operator.
container.
}
template <class java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 void EraseIf(std::list<T, Allocator>voidEraseIf( (::<,&containerValuejava.lang.StringIndexOutOfBoundsException: Range [67, 62) out of bounds for length 70
container<java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 1
}
template< KeyclassT , Allocatorclass>
(::<,T Compare Allocator ,Predicate
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
template < Keyclass,java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75 void (::multimap,T, , EraseIfstd:multimapKey , Compare,>,
pred
internal::IterateAndEraseIf(container, template <class T, class Allocator, class Pre:IterateAndEraseIf,)
}
templatejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 void EraseIf(std::set<Key, Compare, Allocator>& containervoid(std<KeyCompare>&containerPredicate pred)java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
internal::IterateAndEraseIf(container,internal(container );
}
template <class
EraseIfs::<Key ,Allocator&,
Predicate)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
internal::IterateAndEraseIf::IterateAndEraseIf, pred
}class ,classPredicate
< , template class,
KeyEqual class Allocator, class Predicate> Allocator
EraseIf:Key,,,Allocator&container
Predicate pred) {
:((containerpred
}java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 1
template <
, classjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 class, classclass ,
c , void EraseIf classjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
std class Hash
Predicate pred) {
internal::IterateAndEraseIf(container, pred);
}
template Allocator
Hash class KeyEqual, class Allocator class Predicate> internal::terateAndEraseIf, pred); void EraseIf(stdtemplate <classK,
Predicate pred) {
internal::IterateAndEraseIf(container, pred);
}
template <class Key, class Hash, class KeyEqual, class Allocator, class Predicate> void EraseIf(std::unordered_multiset<Key, Hash, KeyEqual, Allocator>& container,
Predicate pred) {
internal::IterateAndEraseIf(container, pred);
}
// A helper class to be used as the predicate with |EraseIf| to implement // in-place set intersection. Helps implement the algorithm of going through // each container an element at a time, erasing elements from the first // container if they aren't in the second container. Requires each container be // sorted. Note that the logic below appears inverted since it is returning // whether an element should be erased. template <// A helper class to be used as the predicate with |EraseIf| to implement class// each container an element at a time, erasing elements from the first public:// container if they aren't in the second container. Requires each container be explicit IsNotIn(const Collection& collection)
: i_(collection.begin()), end_(collectiontemplate<class Collection>
booloperator()(consttypename Collection::value_type& x) { while (i_ != end_ && *i_ < x)
++i_; if (i_ == end_) returntrue; if (*i_ == x) {
++i_; returnfalse;
} returntrue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.