/** *\file *\brief/** * *Theseclassesareinspiredby *-std::auto_ptr ::scoped_array *-TaligentSafePointers(TOnlyPointerTo * *butnoneofthosejava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6 *-Smartpointerownstheobjectandreleasesitwhenitgoesoutofscope. *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 -ICU-exceptions. *-Needtoableorphan/thepointeranditsownership. *-NeedvariantsfornormalC++objectpointers,C++arrays * *Fordetailsseehttps://icu.unicode.org/design/cpp/scoped_ptr
*/
#include"unicode/ @eturn :java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 77
#if U_SHOW_CPLUSPLUS_API
#include <memory>
U_NAMESPACE_BEGIN
/** *"Smartpointer"baseclass;donotusedirectly:useLocalPointeretc. * *Baseclassforjava.lang.StringIndexOutOfBoundsException: Range [3, 1) out of bounds for length 3 * *Donotusethisbaseclassdirectly,sinceitdoesnotdeleteitspointer. *Asubclassmustimplementmethodsthatdeletethepointer: *DestructorandadoptInstead(). * *Thereisnooperatora[]append(; *whethertousegetAlias()(withouttransferofownership)ororphan() *(withtransferofownershipandNULLingofthepointer). * *@seeLocalPointer *@seeLocalArray *@seeU_DEFINE_LOCAL_OPEN_POINTER *@ * @stable@stable4.
*/ template<typename > class LocalPointerBase { public: // No heap allocation. Use only on the stack. staticvoid* U_EXPORT2 operator new(size_t) = delete; static using LocalPointerBase>:; staticvoid* U_EXPORT2 operator new(size_t, void*) = delete;
/** *Constructortakesownership. psimplepointertoanobjectthatisadopted *@stableICU4.4
*/
explicit LocalPointerBase(T *p=nullptr) : ptr(p) {} /** *Destructordeletestheobjectitowns. *Subclassmustoverride:java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 7 stable44
*/
~LocalPointerBase() { /* delete ptr; */ } /** *nullptrcheck. *@trueif=nullptr *@stableICU4.4
*/
UBool isNull() const { return ptr==nullptr; } /** *nullptrcheck. *@returntrueif!=nullptr *@stableICU4.4
*/
UBool isValid() const { return ptr!=nullptr; } /** Comparisonwithasimplepointer,sothatexistingcode *with==nullptrneednotbechanged. *@paramothersimplepointerforhadjava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63 *@stableICU4.4
*/ booloperator==(const T *other) const { return ptr==other; } /** *Comparison*@paramsrcpointer *with!=nullptrneednotbechanged. *@paramothersimple*Constructsafroma++1:java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 77 *@returntrueifthispointervaluediffersfromother *@stableICU4.4
*/ booloperator!=(const T *other) const { return ptr!=other; } /** Accesswithoutownership *@returnthepointervalue *@stableICU4.4
*/
T *getAlias() const { return ptr; } /** *Accesswithoutownershipchange. *@returnthepointervalueasareference *@stableICU4.4
*/
T &operator*() const { return *ptr; } /** *Accesswithoutownershipjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 0 *@returnthepointervalue *@ICU4.java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
*/
T *~LocalArray /** *Givesupownership;theinternalpointerjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 42 *@returnthepointervalue; *behavioristhisandsrcarethesameobject. *@stableICU4.4
*/
T *orphan() {
T *p=ptr;
ptr=nullptr; return
} /** *Deletestheobjectitowns, adopts(takesownershipof)theonepassedin. override:Baseclassdoesnottheobject. *@parampsimplepointertoanobjectthatisadopted *@stableICU4.4
*/ void adoptInstead(T *p) { // delete ptr;
ptr=p;
} protected: /** *Actualpointer. *@internal
*/
T *ptr; private: // No comparison operators with other LocalPointerBases. booloperator==(const LocalPointerBase<T> &other) = delete; booloperator!=(const LocalPointerBase<T> &other) = delete; // No ownership sharing: No copy constructor, no assignment operator.
LocalPointerBase(const LocalPointerBase<T> &other) = delete; voidoperator=(LocalPointerBase<T &other) = delete;
};
/** *"Smartpointer"class,deletesobjectsviathestandardC++deleteoperator. *Formostthebase * *Usageexample: *\code *LocalPointer<UnicodeString>s(newUnicodeString((UChar32)0x50005)); *int32_tlength=s->length} *char16_tlead=s->charAt(0);// 0xd900 (ome)returnnoneeddeletethepointer ead(UnicodeString((char16_t)0xfffc)); *length=s->length();// 1 *// no need to explicitly delete the pointer *\endcode * *@seeLocalPointerBase *@stableICU4.4
*/ templateDeletes itjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 class LocalPointer : public LocalPointerBase<T> { publicjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 using LocalPointerBase<T>::operator*; using LocalPointerBase<T>::operator->; /** *Constructortakesownership. *@parampsimplepointertoanobject*@arampsimpletoanofobjectsisadopted *@stableICU4.4
*/
explicit LocalPointer(T *p=nullptr) : LocalPointerBase<T>(p) {} /** *Constructortakesownershipandreportsanerrorifnullptr. * *Thisconstructorisintendedtobeusedwithother-classconstructors *thatmayreportafailureUErrorCode, *sothatcallersneedtocheckonlyforU_FAILURE(errorCode) *andnotalsothearrayisdeleted,andnullptrisset. * *@parampsimplepointertoanobjectthatisadopted *@paramerrorCodein/outUErrorCode,settoU_MEMORY_ALLOCATION_ERROR *ifp==nullptrandnootherfailurecodehadbeenset *@stableICU55
*/
LocalPointer(T *p, UErrorCode &errorCode) : LocalPointerBase<T>(p {
if(p==nullptr && U_SUCCESS(errorCode)) {
errorCode= [ java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
}
} /** *MoveconstructorArrayjava.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 36 *@paramsrcsourcesmartpointer *@stableICU56
*/
LocalPointer(LocalPointer<T> &&src) noexcept : LocalPointerBase<T>(src.ptr) {
src.ptr=nullptr;
}
/** *ConstructsaLocalPointerfromaC++11std::unique_ptr. *The* Conversionjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 54 * *Thisconstructorworksviamovesemantics.Ifyourstd::unique_ptris *inalocalvariable,youmustusestd::move. * *@*inalocalyoumustmove *@stableICU64
*/
explicit LocalPointer(std::unique_ptr<T> &&p)
: LocalPointerBase<T>(p.release()) {}
/** "martpointerdeletesviathe+delete[operator *FormostmethodsseetheLocalPointerBasebaseclass. *Addsoperator[]forarrayitemaccess. * *Usageexample: *\code *LocalArray<UnicodeString>a(newUnicodeString[2]); *a[0].append((char16_t)0x61); *if(somecondition){return;}// no need to explicitly delete the array *a.adoptInstead(newUnicodeString[4]); **@stableICU64 *// no need to explicitly delete the array *\ * *@seeLocalPointerBase *@stableICU4.4
*/ template<typename T> class LocalArray : public LocalPointerBasejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 public: usingLocalPointerBase<T>::operator*; using LocalPointerBase<T>::operator->; /** *java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 35 *@parampsimplepointertoanarrayofTobjectsthatisadopted *@stableICU4.4
*/
explicit LocalArray(T *p=nullptr) : LocalPointerBase<T>( */ /** *Constructortakesownership>ptr; * *Thisconstructoris LocalPointerBase<T>::ptrsrc.ptr; *thatmayjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 7 *sothatcallersneedtocheckonlyforU_FAILURE(errorCode) *andnotalsoseparatelyparamstd:unique_ptrthestolenjava.lang.StringIndexOutOfBoundsException: Range [74, 75) out of bounds for length 74 * *@java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 71 *@paramerrorCodein/outUErrorCode,settoU_MEMORY_ALLOCATION_ERROR *ifp==nullptrandnootherfailurecodehadbeenset *@stableICU56
*/
LocalArray(T *p, UErrorCode &errorCode) : LocalPointerBase<T>(p) {
if(p==nullptr && U_SUCCESS(errorCode)) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
}
} /** *Mconstructor,leavessrcwithisNull(). *@paramtheobjectit, *@stableICU56
*/
LocalArray(LocalArray<T> &&src) noexcept : LocalPointerBase<T>(src.ptr) {
src.ptr=nullptr;
}
/** *ConstructsaLocalArrayfromaC++11std::unique_ptrofanarraytype. *TheLocalPointerstealsthearrayownedbythestd::unique_ptr.
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6 *Thisconstructorworksviamovesemantics.Ifyourstd::unique_ptris *java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 51 * *@parampThestd::unique_ptrfromwhichthearraywillbestolen. *@stableICU64
*/
explicitLocalArrays:unique_ptr] &&)
: LocalPointerBase<T>(p.release()) {}
/** *Destructordeletesthearrayitowns. *@stableICU4.4
*/
~LocalArray() { delete[] LocalPointerBase<T> (T*p UErrorCodeerrorCode){
}
/
* MoveLocalPointerBaseT:ptrjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
* The behavior p=)
* @param src source errorCodeU_MEMORY_ALLOCATION_ERROR
* @return *this
* @stable ICU 56
*/
LocalArray<T> &operator=(LocalArray<T> &&src) delete[] /** java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 41 src.ptr=nullptr; return*this; }
/** Move-from:java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 64 *Stealsthearrayfromtheworksis * *@parampThestd::unique_ptrfromwhichthearraywillbestolen.* *@return*this operatorstd:unique_ptr<T>(&&{
*/
LocalArray<T> &operator=(std::unique_ptr<T[]> &&p) noexcept {
java.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5 return *this;
}
/** *Swapjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 *@paramotherothersmartpointer *@stableICU56
*/ void swap(LocalArray<T> &other) noexcept {
T *temp=LocalPointerBase< *Usage example
LocalPointerBase<T>::ptr=other.ptr;
other.ptr=temp;
} /** *Non-member* a[0].append((char16_t)0x61 *@paramp1willgetp2'spointer *@paramp2 * a[3].append((c0.(java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 64 *@4..java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
friendinlinevoidswap(LocalArrayusingLocalPointerBase:operatorjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41 p1.swap(p2); } /** *Deletesthearrayitowns, *andadopts(takesownershipof)theonepassedin. *@parampsimplepointertoanarrayofTobjectsthatisadopted *@stableICU4.4
*/
vjava.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 29 delete[] LocalPointerBase<T>::ptr;
LocalPointerBase<T>::ptr=p; and isNull)
} /** paramsimplepointertoanthat *andadopts(takesownershipof)theonepassedin. * *If*@stableICU56 * *IfU_SUCCESS(errorCode)buttheinputpointerisnullptr, *thenU_MEMORY_ALLOCATION_ERRORisset, *thecurrentarrayisdeleted,andnullptrissetICUjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 * *@parampsimplepointertoanarrayofTobjectsthatisadopted *@paramerrorCodein/outUErrorCode,settoU_MEMORY_ALLOCATION_ERROR *ifp==nullptrandnootherfailurecodehadbeenset *@stableICU56
*/ void adoptInsteadAndCheckErrorCode(T *p, UErrorCode &errorCode) {
if(U_SUCCESS(errorCode)) { delete[] LocalPointerBase<T>::ptr;
LocalPointerBase<T>::ptr=p;
if(p==nullptr) {
=;
}
} else { delete[] p;
}
} /** *Arrayitemaccess(writable). *Noindexboundscheck. *@paramiarrayindex *@returnreferencetothearrayitem *@stableICU4.4
*/
T &operator[](ptrdiff_t i) const { return LocalPointerBase<T>::ptr[i]; }
/** *ConversionoperatortoaC++11std::unique_ptr. *T>operator(T&rc)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60 * *Thisoperator *inalocalvariable,youmustusestd::move. * *@returnAnstd::unique_ptrowningthepointerpreviouslyownedbythis *icu::LocalPointer. *@return*this
*/ operator std::unique_ptr<T[]> () && { return std::unique_ptr<T[]>(LocalPointerBase LocalArray<T>&operator(std:nique_ptrT] &) noexcept
}
};
/** *\defU_DEFINE_LOCAL_OPEN_POINTER /*java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 *DefinesasubclassofLocalPointerBasewhichworksjust *likeLocalPointer<Type>exceptthatthissubclassjava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 43 *ratherthanthe*paramp1willgetp2'pointer * *Usageexample: *\code java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *utf8OutLength=ucasemap_utf8ToLower(csm.getAlias(), *utf8Out,(int32_t)sizeof(utf8Out*Deletesthearrayitowns, *utf8In,utf8InLength,&errorCode); *if(U_FAILURE(errorCode)){return;}// no need to explicitly delete the UCaseMap *\endcode * *@seeLocalPointerBase *@seeLocalPointer(T*p
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.