SILENT KILLERPanel

Current Path: > > > > opt > alt > libicu > usr > include > unicode


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: ////opt/alt/libicu/usr/include/unicode

NameTypeSizeLast ModifiedActions
alphaindex.h File 27055 bytes November 07 2019 06:58:02.
appendable.h File 8632 bytes November 07 2019 06:58:02.
basictz.h File 9055 bytes November 07 2019 06:58:02.
brkiter.h File 28303 bytes November 07 2019 06:58:02.
bytestream.h File 9767 bytes November 07 2019 06:58:02.
bytestrie.h File 19718 bytes November 07 2019 06:58:02.
bytestriebuilder.h File 7186 bytes November 07 2019 06:58:02.
calendar.h File 107581 bytes November 07 2019 06:58:02.
caniter.h File 7550 bytes November 07 2019 06:58:02.
casemap.h File 25871 bytes November 07 2019 06:58:02.
char16ptr.h File 7331 bytes November 07 2019 06:58:02.
chariter.h File 24573 bytes November 07 2019 06:58:02.
choicfmt.h File 24418 bytes November 07 2019 06:58:02.
coleitr.h File 14033 bytes November 07 2019 06:58:02.
coll.h File 56928 bytes November 07 2019 06:58:02.
compactdecimalformat.h File 6971 bytes November 07 2019 06:58:02.
curramt.h File 3782 bytes November 07 2019 06:58:02.
currpinf.h File 7412 bytes November 07 2019 06:58:02.
currunit.h File 4082 bytes November 07 2019 06:58:02.
datefmt.h File 41334 bytes November 07 2019 06:58:02.
dbbi.h File 1133 bytes November 07 2019 06:58:02.
dcfmtsym.h File 20584 bytes November 07 2019 06:58:02.
decimfmt.h File 89926 bytes November 07 2019 06:58:02.
docmain.h File 7123 bytes November 07 2019 06:58:02.
dtfmtsym.h File 38548 bytes November 07 2019 06:58:02.
dtintrv.h File 3869 bytes November 07 2019 06:58:02.
dtitvfmt.h File 47676 bytes November 07 2019 06:58:02.
dtitvinf.h File 18902 bytes November 07 2019 06:58:02.
dtptngen.h File 25681 bytes November 07 2019 06:58:02.
dtrule.h File 8831 bytes November 07 2019 06:58:02.
edits.h File 21169 bytes November 07 2019 06:58:02.
enumset.h File 2130 bytes November 07 2019 06:58:02.
errorcode.h File 4894 bytes November 07 2019 06:58:02.
fieldpos.h File 8838 bytes November 07 2019 06:58:02.
filteredbrk.h File 5364 bytes November 07 2019 06:58:02.
fmtable.h File 24946 bytes November 07 2019 06:58:02.
format.h File 12741 bytes November 07 2019 06:58:02.
formattedvalue.h File 9963 bytes November 07 2019 06:58:02.
fpositer.h File 3047 bytes November 07 2019 06:58:02.
gender.h File 3347 bytes November 07 2019 06:58:02.
gregocal.h File 32331 bytes November 07 2019 06:58:02.
icudataver.h File 1051 bytes November 07 2019 06:58:02.
icuplug.h File 12166 bytes November 07 2019 06:58:02.
idna.h File 12938 bytes November 07 2019 06:58:02.
listformatter.h File 9644 bytes November 07 2019 06:58:02.
localebuilder.h File 10792 bytes November 07 2019 06:58:02.
localpointer.h File 20159 bytes November 07 2019 06:58:02.
locdspnm.h File 7231 bytes November 07 2019 06:58:02.
locid.h File 46015 bytes November 07 2019 06:58:02.
measfmt.h File 11710 bytes November 07 2019 06:58:02.
measunit.h File 90283 bytes November 07 2019 06:58:02.
measure.h File 4361 bytes November 07 2019 06:58:02.
messagepattern.h File 34460 bytes November 07 2019 06:58:02.
msgfmt.h File 45099 bytes November 07 2019 06:58:02.
normalizer2.h File 34789 bytes November 07 2019 06:58:02.
normlzr.h File 31476 bytes November 07 2019 06:58:02.
nounit.h File 2693 bytes November 07 2019 06:58:02.
numberformatter.h File 86654 bytes November 07 2019 06:58:02.
numberrangeformatter.h File 30653 bytes November 07 2019 06:58:02.
numfmt.h File 50530 bytes November 07 2019 06:58:02.
numsys.h File 7303 bytes November 07 2019 06:58:02.
parseerr.h File 3155 bytes November 07 2019 06:58:02.
parsepos.h File 5630 bytes November 07 2019 06:58:02.
platform.h File 27754 bytes November 07 2019 06:58:02.
plurfmt.h File 25786 bytes November 07 2019 06:58:02.
plurrule.h File 18774 bytes November 07 2019 06:58:02.
ptypes.h File 3577 bytes November 07 2019 06:58:02.
putil.h File 6487 bytes November 07 2019 06:58:02.
rbbi.h File 27053 bytes November 07 2019 06:58:02.
rbnf.h File 50984 bytes November 07 2019 06:58:02.
rbtz.h File 15838 bytes November 07 2019 06:58:02.
regex.h File 86320 bytes November 07 2019 06:58:02.
region.h File 9342 bytes November 07 2019 06:58:02.
reldatefmt.h File 22910 bytes November 07 2019 06:58:02.
rep.h File 9726 bytes November 07 2019 06:58:02.
resbund.h File 18440 bytes November 07 2019 06:58:02.
schriter.h File 6410 bytes November 07 2019 06:58:02.
scientificnumberformatter.h File 6474 bytes November 07 2019 06:58:02.
search.h File 22742 bytes November 07 2019 06:58:02.
selfmt.h File 14579 bytes November 07 2019 06:58:02.
simpleformatter.h File 12826 bytes November 07 2019 06:58:02.
simpletz.h File 46389 bytes November 07 2019 06:58:02.
smpdtfmt.h File 72597 bytes November 07 2019 06:58:02.
sortkey.h File 11383 bytes November 07 2019 06:58:02.
std_string.h File 1015 bytes November 07 2019 06:58:02.
strenum.h File 10279 bytes November 07 2019 06:58:02.
stringoptions.h File 5926 bytes November 07 2019 06:58:02.
stringpiece.h File 6610 bytes November 07 2019 06:58:02.
stringtriebuilder.h File 15636 bytes November 07 2019 06:58:02.
stsearch.h File 21801 bytes November 07 2019 06:58:02.
symtable.h File 4312 bytes November 07 2019 06:58:02.
tblcoll.h File 37272 bytes November 07 2019 06:58:02.
timezone.h File 42189 bytes November 07 2019 06:58:02.
tmunit.h File 3371 bytes November 07 2019 06:58:02.
tmutamt.h File 4918 bytes November 07 2019 06:58:02.
tmutfmt.h File 7977 bytes November 07 2019 06:58:02.
translit.h File 67339 bytes November 07 2019 06:58:02.
tzfmt.h File 43846 bytes November 07 2019 06:58:02.
tznames.h File 17190 bytes November 07 2019 06:58:02.
tzrule.h File 36170 bytes November 07 2019 06:58:02.
tztrans.h File 6214 bytes November 07 2019 06:58:02.
ubidi.h File 91711 bytes November 07 2019 06:58:02.
ubiditransform.h File 12950 bytes November 07 2019 06:58:02.
ubrk.h File 24547 bytes November 07 2019 06:58:02.
ucal.h File 56876 bytes November 07 2019 06:58:02.
ucasemap.h File 15546 bytes November 07 2019 06:58:02.
ucat.h File 5484 bytes November 07 2019 06:58:02.
uchar.h File 144035 bytes November 07 2019 06:58:02.
ucharstrie.h File 21569 bytes November 07 2019 06:58:02.
ucharstriebuilder.h File 7316 bytes November 07 2019 06:58:02.
uchriter.h File 13457 bytes November 07 2019 06:58:02.
uclean.h File 11474 bytes November 07 2019 06:58:02.
ucnv.h File 85085 bytes November 07 2019 06:58:02.
ucnv_cb.h File 6748 bytes November 07 2019 06:58:02.
ucnv_err.h File 21492 bytes November 07 2019 06:58:02.
ucnvsel.h File 6283 bytes November 07 2019 06:58:02.
ucol.h File 62864 bytes November 07 2019 06:58:02.
ucoleitr.h File 9684 bytes November 07 2019 06:58:02.
uconfig.h File 12338 bytes November 07 2019 06:58:02.
ucpmap.h File 5709 bytes November 07 2019 06:58:02.
ucptrie.h File 22824 bytes November 07 2019 06:58:02.
ucsdet.h File 15018 bytes November 07 2019 06:58:02.
ucurr.h File 16536 bytes November 07 2019 06:58:02.
udat.h File 62267 bytes November 07 2019 06:58:02.
udata.h File 15905 bytes November 07 2019 06:58:02.
udateintervalformat.h File 10272 bytes November 07 2019 06:58:02.
udatpg.h File 26564 bytes November 07 2019 06:58:02.
udisplaycontext.h File 6029 bytes November 07 2019 06:58:02.
uenum.h File 7970 bytes November 07 2019 06:58:02.
ufieldpositer.h File 4461 bytes November 07 2019 06:58:02.
uformattable.h File 11198 bytes November 07 2019 06:58:02.
uformattedvalue.h File 12430 bytes November 07 2019 06:58:02.
ugender.h File 2052 bytes November 07 2019 06:58:02.
uidna.h File 34169 bytes November 07 2019 06:58:02.
uiter.h File 23319 bytes November 07 2019 06:58:02.
uldnames.h File 10702 bytes November 07 2019 06:58:02.
ulistformatter.h File 9043 bytes November 07 2019 06:58:02.
uloc.h File 51971 bytes November 07 2019 06:58:02.
ulocdata.h File 11533 bytes November 07 2019 06:58:02.
umachine.h File 13509 bytes November 07 2019 06:58:02.
umisc.h File 1365 bytes November 07 2019 06:58:02.
umsg.h File 24812 bytes November 07 2019 06:58:02.
umutablecptrie.h File 8477 bytes November 07 2019 06:58:02.
unifilt.h File 3716 bytes November 07 2019 06:58:02.
unifunct.h File 4079 bytes November 07 2019 06:58:02.
unimatch.h File 6184 bytes November 07 2019 06:58:02.
unirepl.h File 3403 bytes November 07 2019 06:58:02.
uniset.h File 66440 bytes November 07 2019 06:58:02.
unistr.h File 174477 bytes November 07 2019 06:58:02.
unorm.h File 20938 bytes November 07 2019 06:58:02.
unorm2.h File 25254 bytes November 07 2019 06:58:02.
unum.h File 54832 bytes November 07 2019 06:58:02.
unumberformatter.h File 25795 bytes November 07 2019 06:58:02.
unumsys.h File 7387 bytes November 07 2019 06:58:02.
uobject.h File 11106 bytes November 07 2019 06:58:02.
upluralrules.h File 8068 bytes November 07 2019 06:58:02.
uregex.h File 73784 bytes November 07 2019 06:58:02.
uregion.h File 10073 bytes November 07 2019 06:58:02.
ureldatefmt.h File 17670 bytes November 07 2019 06:58:02.
urename.h File 134551 bytes November 07 2019 06:58:02.
urep.h File 5507 bytes November 07 2019 06:58:02.
ures.h File 37415 bytes November 07 2019 06:58:02.
uscript.h File 27510 bytes November 07 2019 06:58:02.
usearch.h File 39038 bytes November 07 2019 06:58:02.
uset.h File 40958 bytes November 07 2019 06:58:02.
usetiter.h File 9719 bytes November 07 2019 06:58:02.
ushape.h File 18432 bytes November 07 2019 06:58:02.
uspoof.h File 67613 bytes November 07 2019 06:58:02.
usprep.h File 8331 bytes November 07 2019 06:58:02.
ustdio.h File 39469 bytes November 07 2019 06:58:02.
ustream.h File 1844 bytes November 07 2019 06:58:02.
ustring.h File 74211 bytes November 07 2019 06:58:02.
ustringtrie.h File 3224 bytes November 07 2019 06:58:02.
utext.h File 59505 bytes November 07 2019 06:58:02.
utf.h File 8046 bytes November 07 2019 06:58:02.
utf16.h File 22866 bytes November 07 2019 06:58:02.
utf32.h File 763 bytes November 07 2019 06:58:02.
utf8.h File 30682 bytes November 07 2019 06:58:02.
utf_old.h File 44827 bytes November 07 2019 06:58:02.
utmscale.h File 14113 bytes November 07 2019 06:58:02.
utrace.h File 14219 bytes November 07 2019 06:58:02.
utrans.h File 26157 bytes November 07 2019 06:58:02.
utypes.h File 31108 bytes November 07 2019 06:58:02.
uvernum.h File 6832 bytes November 07 2019 06:58:02.
uversion.h File 6865 bytes November 07 2019 06:58:02.
vtzone.h File 20651 bytes November 07 2019 06:58:02.

Reading File: ////opt/alt/libicu/usr/include/unicode/localpointer.h

// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
*   Copyright (C) 2009-2016, International Business Machines
*   Corporation and others.  All Rights Reserved.
*
*******************************************************************************
*   file name:  localpointer.h
*   encoding:   UTF-8
*   tab size:   8 (not used)
*   indentation:4
*
*   created on: 2009nov13
*   created by: Markus W. Scherer
*/

#ifndef __LOCALPOINTER_H__
#define __LOCALPOINTER_H__

/**
 * \file
 * \brief C++ API: "Smart pointers" for use with and in ICU4C C++ code.
 *
 * These classes are inspired by
 * - std::auto_ptr
 * - boost::scoped_ptr & boost::scoped_array
 * - Taligent Safe Pointers (TOnlyPointerTo)
 *
 * but none of those provide for all of the goals for ICU smart pointers:
 * - Smart pointer owns the object and releases it when it goes out of scope.
 * - No transfer of ownership via copy/assignment to reduce misuse. Simpler & more robust.
 * - ICU-compatible: No exceptions.
 * - Need to be able to orphan/release the pointer and its ownership.
 * - Need variants for normal C++ object pointers, C++ arrays, and ICU C service objects.
 *
 * For details see http://site.icu-project.org/design/cpp/scoped_ptr
 */

#include "unicode/utypes.h"

#if U_SHOW_CPLUSPLUS_API

#include <memory>

U_NAMESPACE_BEGIN

/**
 * "Smart pointer" base class; do not use directly: use LocalPointer etc.
 *
 * Base class for smart pointer classes that do not throw exceptions.
 *
 * Do not use this base class directly, since it does not delete its pointer.
 * A subclass must implement methods that delete the pointer:
 * Destructor and adoptInstead().
 *
 * There is no operator T *() provided because the programmer must decide
 * whether to use getAlias() (without transfer of ownership) or orphan()
 * (with transfer of ownership and NULLing of the pointer).
 *
 * @see LocalPointer
 * @see LocalArray
 * @see U_DEFINE_LOCAL_OPEN_POINTER
 * @stable ICU 4.4
 */
template<typename T>
class LocalPointerBase {
public:
    // No heap allocation. Use only on the stack.
    static void* U_EXPORT2 operator new(size_t) = delete;
    static void* U_EXPORT2 operator new[](size_t) = delete;
#if U_HAVE_PLACEMENT_NEW
    static void* U_EXPORT2 operator new(size_t, void*) = delete;
#endif

    /**
     * Constructor takes ownership.
     * @param p simple pointer to an object that is adopted
     * @stable ICU 4.4
     */
    explicit LocalPointerBase(T *p=NULL) : ptr(p) {}
    /**
     * Destructor deletes the object it owns.
     * Subclass must override: Base class does nothing.
     * @stable ICU 4.4
     */
    ~LocalPointerBase() { /* delete ptr; */ }
    /**
     * NULL check.
     * @return TRUE if ==NULL
     * @stable ICU 4.4
     */
    UBool isNull() const { return ptr==NULL; }
    /**
     * NULL check.
     * @return TRUE if !=NULL
     * @stable ICU 4.4
     */
    UBool isValid() const { return ptr!=NULL; }
    /**
     * Comparison with a simple pointer, so that existing code
     * with ==NULL need not be changed.
     * @param other simple pointer for comparison
     * @return true if this pointer value equals other
     * @stable ICU 4.4
     */
    bool operator==(const T *other) const { return ptr==other; }
    /**
     * Comparison with a simple pointer, so that existing code
     * with !=NULL need not be changed.
     * @param other simple pointer for comparison
     * @return true if this pointer value differs from other
     * @stable ICU 4.4
     */
    bool operator!=(const T *other) const { return ptr!=other; }
    /**
     * Access without ownership change.
     * @return the pointer value
     * @stable ICU 4.4
     */
    T *getAlias() const { return ptr; }
    /**
     * Access without ownership change.
     * @return the pointer value as a reference
     * @stable ICU 4.4
     */
    T &operator*() const { return *ptr; }
    /**
     * Access without ownership change.
     * @return the pointer value
     * @stable ICU 4.4
     */
    T *operator->() const { return ptr; }
    /**
     * Gives up ownership; the internal pointer becomes NULL.
     * @return the pointer value;
     *         caller becomes responsible for deleting the object
     * @stable ICU 4.4
     */
    T *orphan() {
        T *p=ptr;
        ptr=NULL;
        return p;
    }
    /**
     * Deletes the object it owns,
     * and adopts (takes ownership of) the one passed in.
     * Subclass must override: Base class does not delete the object.
     * @param p simple pointer to an object that is adopted
     * @stable ICU 4.4
     */
    void adoptInstead(T *p) {
        // delete ptr;
        ptr=p;
    }
protected:
    /**
     * Actual pointer.
     * @internal
     */
    T *ptr;
private:
    // No comparison operators with other LocalPointerBases.
    bool operator==(const LocalPointerBase<T> &other);
    bool operator!=(const LocalPointerBase<T> &other);
    // No ownership sharing: No copy constructor, no assignment operator.
    LocalPointerBase(const LocalPointerBase<T> &other);
    void operator=(const LocalPointerBase<T> &other);
};

/**
 * "Smart pointer" class, deletes objects via the standard C++ delete operator.
 * For most methods see the LocalPointerBase base class.
 *
 * Usage example:
 * \code
 * LocalPointer<UnicodeString> s(new UnicodeString((UChar32)0x50005));
 * int32_t length=s->length();  // 2
 * char16_t lead=s->charAt(0);  // 0xd900
 * if(some condition) { return; }  // no need to explicitly delete the pointer
 * s.adoptInstead(new UnicodeString((char16_t)0xfffc));
 * length=s->length();  // 1
 * // no need to explicitly delete the pointer
 * \endcode
 *
 * @see LocalPointerBase
 * @stable ICU 4.4
 */
template<typename T>
class LocalPointer : public LocalPointerBase<T> {
public:
    using LocalPointerBase<T>::operator*;
    using LocalPointerBase<T>::operator->;
    /**
     * Constructor takes ownership.
     * @param p simple pointer to an object that is adopted
     * @stable ICU 4.4
     */
    explicit LocalPointer(T *p=NULL) : LocalPointerBase<T>(p) {}
    /**
     * Constructor takes ownership and reports an error if NULL.
     *
     * This constructor is intended to be used with other-class constructors
     * that may report a failure UErrorCode,
     * so that callers need to check only for U_FAILURE(errorCode)
     * and not also separately for isNull().
     *
     * @param p simple pointer to an object that is adopted
     * @param errorCode in/out UErrorCode, set to U_MEMORY_ALLOCATION_ERROR
     *     if p==NULL and no other failure code had been set
     * @stable ICU 55
     */
    LocalPointer(T *p, UErrorCode &errorCode) : LocalPointerBase<T>(p) {
        if(p==NULL && U_SUCCESS(errorCode)) {
            errorCode=U_MEMORY_ALLOCATION_ERROR;
        }
    }
    /**
     * Move constructor, leaves src with isNull().
     * @param src source smart pointer
     * @stable ICU 56
     */
    LocalPointer(LocalPointer<T> &&src) U_NOEXCEPT : LocalPointerBase<T>(src.ptr) {
        src.ptr=NULL;
    }

#ifndef U_HIDE_DRAFT_API
    /**
     * Constructs a LocalPointer from a C++11 std::unique_ptr.
     * The LocalPointer steals the object owned by the std::unique_ptr.
     *
     * This constructor works via move semantics. If your std::unique_ptr is
     * in a local variable, you must use std::move.
     *
     * @param p The std::unique_ptr from which the pointer will be stolen.
     * @draft ICU 64
     */
    explicit LocalPointer(std::unique_ptr<T> &&p)
        : LocalPointerBase<T>(p.release()) {}
#endif  /* U_HIDE_DRAFT_API */

    /**
     * Destructor deletes the object it owns.
     * @stable ICU 4.4
     */
    ~LocalPointer() {
        delete LocalPointerBase<T>::ptr;
    }
    /**
     * Move assignment operator, leaves src with isNull().
     * The behavior is undefined if *this and src are the same object.
     * @param src source smart pointer
     * @return *this
     * @stable ICU 56
     */
    LocalPointer<T> &operator=(LocalPointer<T> &&src) U_NOEXCEPT {
        delete LocalPointerBase<T>::ptr;
        LocalPointerBase<T>::ptr=src.ptr;
        src.ptr=NULL;
        return *this;
    }

#ifndef U_HIDE_DRAFT_API
    /**
     * Move-assign from an std::unique_ptr to this LocalPointer.
     * Steals the pointer from the std::unique_ptr.
     *
     * @param p The std::unique_ptr from which the pointer will be stolen.
     * @return *this
     * @draft ICU 64
     */
    LocalPointer<T> &operator=(std::unique_ptr<T> &&p) U_NOEXCEPT {
        adoptInstead(p.release());
        return *this;
    }
#endif  /* U_HIDE_DRAFT_API */

    /**
     * Swap pointers.
     * @param other other smart pointer
     * @stable ICU 56
     */
    void swap(LocalPointer<T> &other) U_NOEXCEPT {
        T *temp=LocalPointerBase<T>::ptr;
        LocalPointerBase<T>::ptr=other.ptr;
        other.ptr=temp;
    }
    /**
     * Non-member LocalPointer swap function.
     * @param p1 will get p2's pointer
     * @param p2 will get p1's pointer
     * @stable ICU 56
     */
    friend inline void swap(LocalPointer<T> &p1, LocalPointer<T> &p2) U_NOEXCEPT {
        p1.swap(p2);
    }
    /**
     * Deletes the object it owns,
     * and adopts (takes ownership of) the one passed in.
     * @param p simple pointer to an object that is adopted
     * @stable ICU 4.4
     */
    void adoptInstead(T *p) {
        delete LocalPointerBase<T>::ptr;
        LocalPointerBase<T>::ptr=p;
    }
    /**
     * Deletes the object it owns,
     * and adopts (takes ownership of) the one passed in.
     *
     * If U_FAILURE(errorCode), then the current object is retained and the new one deleted.
     *
     * If U_SUCCESS(errorCode) but the input pointer is NULL,
     * then U_MEMORY_ALLOCATION_ERROR is set,
     * the current object is deleted, and NULL is set.
     *
     * @param p simple pointer to an object that is adopted
     * @param errorCode in/out UErrorCode, set to U_MEMORY_ALLOCATION_ERROR
     *     if p==NULL and no other failure code had been set
     * @stable ICU 55
     */
    void adoptInsteadAndCheckErrorCode(T *p, UErrorCode &errorCode) {
        if(U_SUCCESS(errorCode)) {
            delete LocalPointerBase<T>::ptr;
            LocalPointerBase<T>::ptr=p;
            if(p==NULL) {
                errorCode=U_MEMORY_ALLOCATION_ERROR;
            }
        } else {
            delete p;
        }
    }

#ifndef U_HIDE_DRAFT_API
    /**
     * Conversion operator to a C++11 std::unique_ptr.
     * Disowns the object and gives it to the returned std::unique_ptr.
     *
     * This operator works via move semantics. If your LocalPointer is
     * in a local variable, you must use std::move.
     *
     * @return An std::unique_ptr owning the pointer previously owned by this
     *         icu::LocalPointer.
     * @draft ICU 64
     */
    operator std::unique_ptr<T> () && {
        return std::unique_ptr<T>(LocalPointerBase<T>::orphan());
    }
#endif  /* U_HIDE_DRAFT_API */
};

/**
 * "Smart pointer" class, deletes objects via the C++ array delete[] operator.
 * For most methods see the LocalPointerBase base class.
 * Adds operator[] for array item access.
 *
 * Usage example:
 * \code
 * LocalArray<UnicodeString> a(new UnicodeString[2]);
 * a[0].append((char16_t)0x61);
 * if(some condition) { return; }  // no need to explicitly delete the array
 * a.adoptInstead(new UnicodeString[4]);
 * a[3].append((char16_t)0x62).append((char16_t)0x63).reverse();
 * // no need to explicitly delete the array
 * \endcode
 *
 * @see LocalPointerBase
 * @stable ICU 4.4
 */
template<typename T>
class LocalArray : public LocalPointerBase<T> {
public:
    using LocalPointerBase<T>::operator*;
    using LocalPointerBase<T>::operator->;
    /**
     * Constructor takes ownership.
     * @param p simple pointer to an array of T objects that is adopted
     * @stable ICU 4.4
     */
    explicit LocalArray(T *p=NULL) : LocalPointerBase<T>(p) {}
    /**
     * Constructor takes ownership and reports an error if NULL.
     *
     * This constructor is intended to be used with other-class constructors
     * that may report a failure UErrorCode,
     * so that callers need to check only for U_FAILURE(errorCode)
     * and not also separately for isNull().
     *
     * @param p simple pointer to an array of T objects that is adopted
     * @param errorCode in/out UErrorCode, set to U_MEMORY_ALLOCATION_ERROR
     *     if p==NULL and no other failure code had been set
     * @stable ICU 56
     */
    LocalArray(T *p, UErrorCode &errorCode) : LocalPointerBase<T>(p) {
        if(p==NULL && U_SUCCESS(errorCode)) {
            errorCode=U_MEMORY_ALLOCATION_ERROR;
        }
    }
    /**
     * Move constructor, leaves src with isNull().
     * @param src source smart pointer
     * @stable ICU 56
     */
    LocalArray(LocalArray<T> &&src) U_NOEXCEPT : LocalPointerBase<T>(src.ptr) {
        src.ptr=NULL;
    }

#ifndef U_HIDE_DRAFT_API
    /**
     * Constructs a LocalArray from a C++11 std::unique_ptr of an array type.
     * The LocalPointer steals the array owned by the std::unique_ptr.
     *
     * This constructor works via move semantics. If your std::unique_ptr is
     * in a local variable, you must use std::move.
     *
     * @param p The std::unique_ptr from which the array will be stolen.
     * @draft ICU 64
     */
    explicit LocalArray(std::unique_ptr<T[]> &&p)
        : LocalPointerBase<T>(p.release()) {}
#endif  /* U_HIDE_DRAFT_API */

    /**
     * Destructor deletes the array it owns.
     * @stable ICU 4.4
     */
    ~LocalArray() {
        delete[] LocalPointerBase<T>::ptr;
    }
    /**
     * Move assignment operator, leaves src with isNull().
     * The behavior is undefined if *this and src are the same object.
     * @param src source smart pointer
     * @return *this
     * @stable ICU 56
     */
    LocalArray<T> &operator=(LocalArray<T> &&src) U_NOEXCEPT {
        delete[] LocalPointerBase<T>::ptr;
        LocalPointerBase<T>::ptr=src.ptr;
        src.ptr=NULL;
        return *this;
    }

#ifndef U_HIDE_DRAFT_API
    /**
     * Move-assign from an std::unique_ptr to this LocalPointer.
     * Steals the array from the std::unique_ptr.
     *
     * @param p The std::unique_ptr from which the array will be stolen.
     * @return *this
     * @draft ICU 64
     */
    LocalArray<T> &operator=(std::unique_ptr<T[]> &&p) U_NOEXCEPT {
        adoptInstead(p.release());
        return *this;
    }
#endif  /* U_HIDE_DRAFT_API */

    /**
     * Swap pointers.
     * @param other other smart pointer
     * @stable ICU 56
     */
    void swap(LocalArray<T> &other) U_NOEXCEPT {
        T *temp=LocalPointerBase<T>::ptr;
        LocalPointerBase<T>::ptr=other.ptr;
        other.ptr=temp;
    }
    /**
     * Non-member LocalArray swap function.
     * @param p1 will get p2's pointer
     * @param p2 will get p1's pointer
     * @stable ICU 56
     */
    friend inline void swap(LocalArray<T> &p1, LocalArray<T> &p2) U_NOEXCEPT {
        p1.swap(p2);
    }
    /**
     * Deletes the array it owns,
     * and adopts (takes ownership of) the one passed in.
     * @param p simple pointer to an array of T objects that is adopted
     * @stable ICU 4.4
     */
    void adoptInstead(T *p) {
        delete[] LocalPointerBase<T>::ptr;
        LocalPointerBase<T>::ptr=p;
    }
    /**
     * Deletes the array it owns,
     * and adopts (takes ownership of) the one passed in.
     *
     * If U_FAILURE(errorCode), then the current array is retained and the new one deleted.
     *
     * If U_SUCCESS(errorCode) but the input pointer is NULL,
     * then U_MEMORY_ALLOCATION_ERROR is set,
     * the current array is deleted, and NULL is set.
     *
     * @param p simple pointer to an array of T objects that is adopted
     * @param errorCode in/out UErrorCode, set to U_MEMORY_ALLOCATION_ERROR
     *     if p==NULL and no other failure code had been set
     * @stable ICU 56
     */
    void adoptInsteadAndCheckErrorCode(T *p, UErrorCode &errorCode) {
        if(U_SUCCESS(errorCode)) {
            delete[] LocalPointerBase<T>::ptr;
            LocalPointerBase<T>::ptr=p;
            if(p==NULL) {
                errorCode=U_MEMORY_ALLOCATION_ERROR;
            }
        } else {
            delete[] p;
        }
    }
    /**
     * Array item access (writable).
     * No index bounds check.
     * @param i array index
     * @return reference to the array item
     * @stable ICU 4.4
     */
    T &operator[](ptrdiff_t i) const { return LocalPointerBase<T>::ptr[i]; }

#ifndef U_HIDE_DRAFT_API
    /**
     * Conversion operator to a C++11 std::unique_ptr.
     * Disowns the object and gives it to the returned std::unique_ptr.
     *
     * This operator works via move semantics. If your LocalPointer is
     * in a local variable, you must use std::move.
     *
     * @return An std::unique_ptr owning the pointer previously owned by this
     *         icu::LocalPointer.
     * @draft ICU 64
     */
    operator std::unique_ptr<T[]> () && {
        return std::unique_ptr<T[]>(LocalPointerBase<T>::orphan());
    }
#endif  /* U_HIDE_DRAFT_API */
};

/**
 * \def U_DEFINE_LOCAL_OPEN_POINTER
 * "Smart pointer" definition macro, deletes objects via the closeFunction.
 * Defines a subclass of LocalPointerBase which works just
 * like LocalPointer<Type> except that this subclass will use the closeFunction
 * rather than the C++ delete operator.
 *
 * Usage example:
 * \code
 * LocalUCaseMapPointer csm(ucasemap_open(localeID, options, &errorCode));
 * utf8OutLength=ucasemap_utf8ToLower(csm.getAlias(),
 *     utf8Out, (int32_t)sizeof(utf8Out),
 *     utf8In, utf8InLength, &errorCode);
 * if(U_FAILURE(errorCode)) { return; }  // no need to explicitly delete the UCaseMap
 * \endcode
 *
 * @see LocalPointerBase
 * @see LocalPointer
 * @stable ICU 4.4
 */
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction) \
    class LocalPointerClassName : public LocalPointerBase<Type> { \
    public: \
        using LocalPointerBase<Type>::operator*; \
        using LocalPointerBase<Type>::operator->; \
        explicit LocalPointerClassName(Type *p=NULL) : LocalPointerBase<Type>(p) {} \
        LocalPointerClassName(LocalPointerClassName &&src) U_NOEXCEPT \
                : LocalPointerBase<Type>(src.ptr) { \
            src.ptr=NULL; \
        } \
        /* TODO: Be agnostic of the deleter function signature from the user-provided std::unique_ptr? */ \
        explicit LocalPointerClassName(std::unique_ptr<Type, decltype(&closeFunction)> &&p) \
                : LocalPointerBase<Type>(p.release()) {} \
        ~LocalPointerClassName() { if (ptr != NULL) { closeFunction(ptr); } } \
        LocalPointerClassName &operator=(LocalPointerClassName &&src) U_NOEXCEPT { \
            if (ptr != NULL) { closeFunction(ptr); } \
            LocalPointerBase<Type>::ptr=src.ptr; \
            src.ptr=NULL; \
            return *this; \
        } \
        /* TODO: Be agnostic of the deleter function signature from the user-provided std::unique_ptr? */ \
        LocalPointerClassName &operator=(std::unique_ptr<Type, decltype(&closeFunction)> &&p) { \
            adoptInstead(p.release()); \
            return *this; \
        } \
        void swap(LocalPointerClassName &other) U_NOEXCEPT { \
            Type *temp=LocalPointerBase<Type>::ptr; \
            LocalPointerBase<Type>::ptr=other.ptr; \
            other.ptr=temp; \
        } \
        friend inline void swap(LocalPointerClassName &p1, LocalPointerClassName &p2) U_NOEXCEPT { \
            p1.swap(p2); \
        } \
        void adoptInstead(Type *p) { \
            if (ptr != NULL) { closeFunction(ptr); } \
            ptr=p; \
        } \
        operator std::unique_ptr<Type, decltype(&closeFunction)> () && { \
            return std::unique_ptr<Type, decltype(&closeFunction)>(LocalPointerBase<Type>::orphan(), closeFunction); \
        } \
    }

U_NAMESPACE_END

#endif  /* U_SHOW_CPLUSPLUS_API */
#endif  /* __LOCALPOINTER_H__ */

SILENT KILLER Tool