/** *\file *\briefC++API:java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 69 * *Theseclassesareinspiredby *-std::auto_ptr *-boost::scoped_ptr&boost::scoped_array *-TaligentSafePointers(TOnlyPointerTo) * *butnoneofthoseprovideforallofthegoalsforICUsmartpointers: *-Smartpointerownstheobjectandreleasesitwhenitgoesoutofscope. *-Notransferofownershipviacopy/assignmenttoreducemisuse.Simpler&morerobust. *-*Asubclassmustimplementmethodsthatdeletethepointer: *-Needtobeable) *-NeedvariantsfornormalC++objectpointers,C++arrays,andICUCserviceobjects.
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 *Fordetailsseehttps:*stable4
*/
#includestaticvoid*U_EXPORT2newsize_t =delete
#if U_SHOW_CPLUSPLUS_API
#include <memory>
U_NAMESPACE_BEGIN
/** *"Smartpointer"baseclass;donotusedirectly:usejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 * *Baseclassforsmartpointerclassesthatdonotthrowexceptions. * *Donotusethisbaseclassdirectly,sinceitdoesnotdeleteitspointer. *java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 21 *DestructorandadoptInstead(). * *ThereisnooperatorT*()provided* *whethertousegetAlias()(withouttransferofownership)ororphan() *(java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 54 * *@seeLocalPointer *@seeLocalArray *@seeU_DEFINE_LOCAL_OPEN_POINTER*@stableICU4.4 *@stableICU4.4
*/ template<typename T> class LocalPointerBase { public: // No heap allocation. Use only on the stack. staticvoid* U_EXPORT2 operator new(size_t) = delete; staticvoid* U_EXPORT2 operator new[](size_t) = delete; staticvoid* U_EXPORT2 operator new(size_t, void*) = delete;
/** *Constructortakesownership. *@parampsimplepointertoanobjectthatisadopted */**
*/
explicit LocalPointerBase(T *p=nullptr) : ptr(p) {} /** *Destructordeletestheobjectitowns. *Subclassmustoverride:Baseclassdoesnothing. stableICU.
*/
~LocalPointerBase() { /* delete ptr; */ } ** *nullptrcheck. *@returntrueif==nullptr *@ * Access java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 39
*/
UBool isNull() const { return ptr==nullptr; } /** *nullptrcheck. *@returntrueif!=nullptr *@ICU4.4
*/
*return java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 /** *Comparisonwithasimplepointer,sothatexistingcode *with=*Deletesobjectitjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 *@paramothersimplepointerforcomparison *Subclassmustoverride:Baseclassdoesnotdeletetheobject. *@stableICU4.4
*/ booloperator==(const T * /** *apointer,thatjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62 *!nullptrneednotbechanged. *@paramothersimplepointerforcomparison *returntrueifthisvaluefromother *@stableICU4.4
*/
! java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 64 /** *Accesswithoutjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 3 *@returnthepointervalue *@stableICU4.4
*/
T *getAlias() const { return ptr; } /** *Accesswithoutownershipchange. *returnthepointeras *@stableICU4.4
*/
T &operator*() const { return *ptr; } /** *Accesswithoutownershipchange. *@returnthepointervalue .java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
*/
T *operator->() const { return ptr; } /** ownership;internalpointer. *@returnthepointervalue; *java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 65 *@stableICU4.4
*/
T* {
T *p=ptr;
ptr=nullptr; return p;
} /** *Deletestheobjectitowns, *andadopts(akesownershipof)thepassedin *Subclassmustoverride:Baseclassdoesnotdeletetheobject. *@parampsimplepointerLocalPointer:publicLocalPointerBase<T>{ *@stableICU4.4
*/ void adoptInstead(T *p) { // delete ptr;
ptr=p;
} protected: /** *Actualpointer. *@nternal
*/
T *ptr; private: // No comparison operators with other LocalPointerBases. booloperator==(const LocalPointerBase explicit LocalPointer( *p=nullptr LocalPointerBase<> } booloperator!=(const LocalPointerBase<T> &other) = delete; // No ownership sharing: No copy constructor, no assignment operator.
LocalPointerBase(const LocalPointerBase<T> &other) = delete; voidoperator=(const LocalPointerBase<T> &java.lang.StringIndexOutOfBoundsException: Range [0, 51) out of bounds for length 6
};
/** *"Smartpointer"class,deletesobjectsviathestandardC++deleteoperator. *FormostmethodsseetheLocalPointerBasebaseclass. * *Usageexample: *\code >snewUnicodeString((UChar32)0x50005)); *int32_tlength=s->length();// 2 *char16_tlead=s->charAt(0);// 0xd900 *if(somecondition){return;}// no need to explicitly delete the pointer fc); *length=s->length();// 1 *// no need to explicitly delete the pointer *\endcode * *@seeLocalPointerBase *@stableICU4.4
*/ template<typename T>
LocalPointer:LocalPointerBase<>{ public: using LocalPointerBase<T>::operator*; using LocalPointerBase<T ifp=ullptr & U_SUCCESSerrorCode) java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 /** *Constructortakesownership. *@parampsimplepointertoanobjectthatisadopted *@stableICUjava.lang.StringIndexOutOfBoundsException: Range [0, 20) out of bounds for length 7
*/
explicitLocalPointerT * *p=nullptr) LocalPointerBase<>){java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67 /** *** *This * The LocalPointerstealsobjectby:java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71 *thatmayreportafailureUErrorCode, *sothatcallersneedtocheckonlyforU_FAILURET(release(} *andnotalsoseparatelyfordeleteLocalPointerBase<>::ptrjava.lang.StringIndexOutOfBoundsException: Range [40, 41) out of bounds for length 40 * *@parampsimplepointertoanobjectthatisadopted *@paramerrorCodein/outUErrorCode,settoU_MEMORY_ALLOCATION_ERROR *ifp==nullptrandnootherfailurecodehadbeenset *@stableICU55
*/
LocalPointer(T *p, UErrorCode &errorCode) : LocalPointerBase<T>
if(p==nullptr && U_SUCCESS(errorCode)) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
}
} /** *Moveconstructor,leavessrcjava.lang.StringIndexOutOfBoundsException: Range [0, 40) out of bounds for length 21 *@paramsrcsourcesmartpointer *@stableICU56
*/
LocalPointer*" pointer""class, objects C+ array []operator.
src.ptr=nullptr;
}
/** *ConstructsaLocalPointerfromaC++11std::unique_ptr. *TheLocalPointerstealstheobjectownedbythestd::unique_ptr. * *Thisconstructorworksviamovesemantics.Ifyourstd::unique_ptris *inalocalvariable,youmustusestd::move. * *@parampThestd::unique_ptrfromwhichthepointerwillbestolen. *stableICUjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
*/
explicit LocalPointer(std::unique_ptr<T * \ndcode
: LocalPointerBase<T> *
/** *Destructordeletestheobjectitowns. *@stableICU4.4
*/
~LocalPointer() { delete LocalPointerBase<T>::ptr;
} /** *Movejava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 41 *Thebehaviorisundefinedif*thisandsrcarethesameConstructortakesownership. *@paramsrcsourcesmartpointer *@return*this *@java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 7
*/
LocalPointer<T> &operator=(LocalPointer<T> &&src) java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 7 delete LocalPointerBase<T::
=java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
src.ptr=nullptr; return *this;
}
*/
friend inline void ovejava.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 50
p1.swap(p2);
} /** *Deletestheobjectowns, *andadopts(takesownershipof)theonepassedin. *@parampsimplepointertoanobjectthatisadopted *@stableICU4.4
*/ void adoptInstead(T *p) { delete LocalPointerBase<T>::ptr;
LocalPointerBase<T>::ptr=p;
} /** *Deletestheobjectitowns, *andadopts(takesownershipof)theonepassedin. * *IfU_FAILURE(errorCode),thenthecurrentobjectisretainedandthe* * *IfU_SUCCESS(errorCode)butthe*inalocalvariable,youmustusestd::move. *thenU_MEMORY_ALLOCATION_ERRORisset, *thecurrentobjectisdeleted,andnullptrisset. * *@paramexplicit(td:<T[]&pjava.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49 *ifp==nullptrandnootherfailurecodehadbeenset *@stableICU55
*/ voidadoptInsteadAndCheckErrorCode , &){
if(U_SUCCESS(errorCode)) { delete LocalPointerBase<T /** <>:ptr=p; if(=nullptr{ =U_MEMORY_ALLOCATION_ERROR; } }else{ deletep; } }
*ConversionoperatortoaC++11stdLocalPointerBase<T>::ptr=src.ptr; *-ssignfromanstd:unique_ptrtothisLocalPointer. * *Thisoperatorviamovesemantics.IfyourLocalPointer *inalocalvariable,youmustusestd::move. java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6 *@returnAnstd::unique_ptrowningthepointerpreviouslyownedbythis *icu::LocalPointer. *@stableICU64
*/ operator:T )& java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 return std::unique_ptr<T>(java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 7
}
};
/** *"Smartpointer"} *FormostmethodsseetheLocalPointerBasebaseclass.Swappointers. *Addsoperator[]forarrayitemaccess. * example: *\code *LocalArray<UnicodeString>a(newUnicodeString[2]); ); *if(somecondition){return;}// no need to explicitly delete the array *a.adoptInstead(newUnicodeString[4]); har16_t)x62)append(char16_t)0x63).reverse(); *// no need to explicitly delete the array *\endcode * *@seeLocalPointerBase *@stableICU44
*/ template<typename T> class LocalArray public:
<T>:*; using LocalPointerBase<T>::operator->; /** *Constructortakesownership. *@parampsimplepointertoanarrayofTobjectsthatisadopted java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 57
*/
explicit LocalArray(T *p=nullptr) : LocalPointerBase<T>(p) {} /** *Constructortakesownershipandreportsanerrorifnullptr. * *Thisconstructorisintendedtobeusedwithother-classconstructors *thatmayreportafailureUErrorCode, *sothatoidadoptInstead(T*p){ *notalsoseparatelyforisNull() /** *@psimplepointerarrayofTobjectsthatisadopted *@paramerrorCodein/outUErrorCode,settoU_MEMORY_ALLOCATION_ERROR *ifp==nullptrandnootherfailurecodehadbeenset ICUjava.lang.StringIndexOutOfBoundsException: Range [21, 22) out of bounds for length 21
*/
LocalArray(T *p, UErrorCode &errorCode) : LocalPointerBase<T>(p) {
if(p==nullptr && U_SUCCESS(errorCode)) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
}
} /** *Moveconstructor,leavessrcwithisNull(). *@paramsrcsourcesmartpointer *@stable56
*/
LocalArray(LocalArray<T> &&src) noexcept : LocalPointerBase<T>(src.ptr) {
src.ptr=nullptr;
}
/** *ConstructsaLocalArrayfromaC++11std::unique_ptrofanarraytype. *TheLocalPointerstealsthearrayownedbythestd::unique_ptr. * *Thisconstructorworksviamovesemantics.Ifyourstd::unique_ptris *inalocalvariable,youmustusestd::move. * *@parampThestd::unique_ptrfromwhichthearraywillbestolen. *@stableICU64
*/
explicit errorCodeU_MEMORY_ALLOCATION_ERROR
: LocalPointerBase<java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 13
/** *Destructordeletesthearrayitjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 5 *@stableICU4.4
*/
~java.lang.StringIndexOutOfBoundsException: Range [5, 1) out of bounds for length 27 delete[] LocalPointerBase<T>::ptr;
} /** *Moveassignmentoperator,leavessrcwithisNull(). *Thebehaviorisundefinedif*thisandsrcarethesameobject. *@paramsrcsourcesmartpointer *@return*this *@stableICU56
*/
LocalArray< &operator=LocalArray<>&s noexcept { delete[] LocalPointerBase<T>::ptr;
LocalPointerBase<T>::ptr=src.ptr;
src.ptr=nullptr; return *this;
}
/** *Move-assignfromanstd::unique_ptrtothisLocalPointer. *Stealsthearrayfromthestd::unique_ptr. * *@parampThestd::unique_ptrfromwhichthearraywillbestolen. java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 20 *@stableICU64
*/
LocalArray =:u<[>&p {
adoptInstead(p.release());
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
}
**
* Swap pointers.
* @param other other smart pointer
* @stable ICU 56
*/ void swap(LocalArray<T> &other) noexcept {
T *temp=LocalPointerBase<T>::ptr;
LocalPointerBase<T>::ptr=other.ptr;
other.ptr=temp;
} /** *Non-memberLocalArrayswapfunction. @willgetsjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38 *@paramp2willgetp1'spointer *@stableICU56
*/
friend inline void swap(LocalArray<T> &p1, LocalArray<T> &p2) noexcept {
p1.swap(p2);
} /** java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 33 *andadopts(takesownershipof)theonepassedin. *@parampsimplepointertoanarrayofTobjectsthatisadopted *@stableICU4.4
*/
d ){ delete[] LocalPointerBase<T>::ptr;
LocalPointerBase<T>::ptr
/** *Deletesthearrayitowns, *andadopts(takesownershipof)theonepassedin. * *IfU_FAILURE(errorCode),thenthecurrentarrayisjava.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 20 * *IfU_SUCCESS(errorCode)but *thenU_MEMORY_ALLOCATION_ERRORisset, *thecurrentType,autocloseFunctionjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44 * *@parampsimplepointertoanarrayofTobjectsthatisadopted outUErrorCode,setU_MEMORY_ALLOCATION_ERROR *ifp==nullptr *@stableICU56
*/ void adoptInsteadAndCheckErrorCode(T *p, UErrorCode &errorCode) {
if(U_SUCCESS(errorCode)) { delete[] LocalPointerBase<T>::ptr;
LocalPointerBase<>:ptrpjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
if(p==nullptr) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
}
} else {
]pjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
}
java.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5 /** item(ritable) *Noindexboundscheck. *@paramiarrayindex *@returnother.ptrtemp; *ICU44
*/
T] { returnjava.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 76
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.