#endif
/**
- * char16_t * wrapper with implicit conversion from/to distinct but bit-compatible pointer types.
+ * char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types.
* @draft ICU 59
*/
class U_COMMON_API Char16Ptr final {
public:
/**
* Copies the pointer.
- * TODO: @param p ...
+ * @param p pointer
* @draft ICU 59
*/
inline Char16Ptr(char16_t *p);
/**
* Converts the pointer to char16_t *.
+ * @param p pointer to be converted
* @draft ICU 59
*/
inline Char16Ptr(uint16_t *p);
/**
* Converts the pointer to char16_t *.
* (Only defined if U_SIZEOF_WCHAR_T==2.)
+ * @param p pointer to be converted
* @draft ICU 59
*/
inline Char16Ptr(wchar_t *p);
#endif
/**
* nullptr constructor.
+ * @param p nullptr
* @draft ICU 59
*/
inline Char16Ptr(std::nullptr_t p);
/**
* Pointer access.
- * TODO @return ...
+ * @return the wrapped pointer
* @draft ICU 59
*/
inline char16_t *get() const;
/**
* char16_t pointer access via type conversion (e.g., static_cast).
+ * @return the wrapped pointer
* @draft ICU 59
*/
- operator char16_t *() const { return get(); }
- // TODO: do we need output conversion and other operator overloads
- // if we do not change return values to pointer wrappers?
- /**
- * uint16_t pointer access via type conversion (e.g., static_cast).
- * @draft ICU 59
- */
- inline operator uint16_t *() const;
-#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
- /**
- * wchar_t pointer access via type conversion (e.g., static_cast).
- * @draft ICU 59
- */
- inline operator wchar_t *() const;
-#endif
- operator void *() const { return get(); }
-
- char16_t operator[](std::ptrdiff_t offset) const { return get()[offset]; }
-
- UBool operator==(const Char16Ptr &other) const { return get() == other.get(); }
- UBool operator!=(const Char16Ptr &other) const { return !operator==(other); }
- UBool operator==(const char16_t *other) const { return get() == other; }
- UBool operator!=(const char16_t *other) const { return !operator==(other); }
- UBool operator==(const uint16_t *other) const { return static_cast<uint16_t *>(*this) == other; }
- UBool operator!=(const uint16_t *other) const { return !operator==(other); }
-#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
- UBool operator==(const wchar_t *other) const { return static_cast<wchar_t *>(*this) == other; }
- UBool operator!=(const wchar_t *other) const { return !operator==(other); }
-#endif
- UBool operator==(const std::nullptr_t null) const { return get() == null; }
- UBool operator!=(const std::nullptr_t null) const { return !operator==(null); }
- /**
- * Comparison with 0.
- * @return TRUE if the pointer is nullptr and zero==0
- * @draft ICU 59
- */
- UBool operator==(int zero) const { return get() == nullptr && zero == 0; }
- /**
- * Comparison with 0.
- * @return TRUE if the pointer is not nullptr and zero==0
- * @draft ICU 59
- */
- UBool operator!=(int zero) const { return get() != nullptr && zero == 0; }
-
- Char16Ptr operator+(std::ptrdiff_t offset) const { return Char16Ptr(get() + offset); }
+ inline operator char16_t *() const { return get(); }
private:
Char16Ptr() = delete;
char16_t *Char16Ptr::get() const { return p; }
-Char16Ptr::operator uint16_t *() const {
- U_ALIASING_BARRIER(p);
- return reinterpret_cast<uint16_t *>(p);
-}
-#if U_SIZEOF_WCHAR_T==2
-Char16Ptr::operator wchar_t *() const {
- U_ALIASING_BARRIER(p);
- return reinterpret_cast<wchar_t *>(p);
-}
-#endif
-
#else
Char16Ptr::Char16Ptr(char16_t *p) { u.cp = p; }
char16_t *Char16Ptr::get() const { return u.cp; }
-Char16Ptr::operator uint16_t *() const {
- return u.up;
-}
-#if U_SIZEOF_WCHAR_T==2
-Char16Ptr::operator wchar_t *() const {
- return u.wp;
-}
-#endif
-
#endif
/**
- * const char16_t * wrapper with implicit conversion from/to distinct but bit-compatible pointer types.
+ * const char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types.
* @draft ICU 59
*/
class U_COMMON_API ConstChar16Ptr final {
public:
/**
* Copies the pointer.
+ * @param p pointer
* @draft ICU 59
*/
inline ConstChar16Ptr(const char16_t *p);
/**
* Converts the pointer to char16_t *.
+ * @param p pointer to be converted
* @draft ICU 59
*/
inline ConstChar16Ptr(const uint16_t *p);
/**
* Converts the pointer to char16_t *.
* (Only defined if U_SIZEOF_WCHAR_T==2.)
+ * @param p pointer to be converted
* @draft ICU 59
*/
inline ConstChar16Ptr(const wchar_t *p);
#endif
/**
* nullptr constructor.
+ * @param p nullptr
* @draft ICU 59
*/
inline ConstChar16Ptr(const std::nullptr_t p);
/**
* Pointer access.
+ * @return the wrapped pointer
* @draft ICU 59
*/
inline const char16_t *get() const;
/**
* char16_t pointer access via type conversion (e.g., static_cast).
+ * @return the wrapped pointer
* @draft ICU 59
*/
- operator const char16_t *() const { return get(); }
- /**
- * uint16_t pointer access via type conversion (e.g., static_cast).
- * @draft ICU 59
- */
- inline operator const uint16_t *() const;
-#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
- /**
- * wchar_t pointer access via type conversion (e.g., static_cast).
- * @draft ICU 59
- */
- inline operator const wchar_t *() const;
-#endif
- operator const void *() const { return get(); }
-
- char16_t operator[](std::ptrdiff_t offset) const { return get()[offset]; }
-
- UBool operator==(const ConstChar16Ptr &other) const { return get() == other.get(); }
- UBool operator!=(const ConstChar16Ptr &other) const { return !operator==(other); }
- UBool operator==(const char16_t *other) const { return get() == other; }
- UBool operator!=(const char16_t *other) const { return !operator==(other); }
- UBool operator==(const uint16_t *other) const { return static_cast<const uint16_t *>(*this) == other; }
- UBool operator!=(const uint16_t *other) const { return !operator==(other); }
-#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
- UBool operator==(const wchar_t *other) const { return static_cast<const wchar_t *>(*this) == other; }
- UBool operator!=(const wchar_t *other) const { return !operator==(other); }
-#endif
- UBool operator==(const std::nullptr_t null) const { return get() == null; }
- UBool operator!=(const std::nullptr_t null) const { return !operator==(null); }
- UBool operator==(int zero) const { return get() == nullptr && zero == 0; }
- UBool operator!=(int zero) const { return get() != nullptr && zero == 0; }
-
- ConstChar16Ptr operator+(std::ptrdiff_t offset) { return ConstChar16Ptr(get() + offset); }
+ inline operator const char16_t *() const { return get(); }
private:
ConstChar16Ptr() = delete;
const char16_t *ConstChar16Ptr::get() const { return p; }
-ConstChar16Ptr::operator const uint16_t *() const {
- U_ALIASING_BARRIER(p);
- return reinterpret_cast<const uint16_t *>(p);
-}
-#if U_SIZEOF_WCHAR_T==2
-ConstChar16Ptr::operator const wchar_t *() const {
- U_ALIASING_BARRIER(p);
- return reinterpret_cast<const wchar_t *>(p);
-}
-#endif
-
#else
ConstChar16Ptr::ConstChar16Ptr(const char16_t *p) { u.cp = p; }
const char16_t *ConstChar16Ptr::get() const { return u.cp; }
-ConstChar16Ptr::operator const uint16_t *() const {
- return u.up;
-}
-#if U_SIZEOF_WCHAR_T==2
-ConstChar16Ptr::operator const wchar_t *() const {
- return u.wp;
-}
-#endif
-
#endif
U_NAMESPACE_END
* @draft ICU 59
*/
UNISTR_FROM_STRING_EXPLICIT UnicodeString(const uint16_t *text) :
- UnicodeString(ConstChar16Ptr(text).get()) {}
+ UnicodeString(ConstChar16Ptr(text)) {}
#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
/**
* @draft ICU 59
*/
UNISTR_FROM_STRING_EXPLICIT UnicodeString(const wchar_t *text) :
- UnicodeString(ConstChar16Ptr(text).get()) {}
+ UnicodeString(ConstChar16Ptr(text)) {}
#endif
/**
* @draft ICU 59
*/
UnicodeString(const uint16_t *text, int32_t length) :
- UnicodeString(ConstChar16Ptr(text).get(), length) {}
+ UnicodeString(ConstChar16Ptr(text), length) {}
#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
/**
* @draft ICU 59
*/
UnicodeString(const wchar_t *text, int32_t length) :
- UnicodeString(ConstChar16Ptr(text).get(), length) {}
+ UnicodeString(ConstChar16Ptr(text), length) {}
#endif
/**
* @draft ICU 59
*/
UnicodeString(uint16_t *buffer, int32_t buffLength, int32_t buffCapacity) :
- UnicodeString(Char16Ptr(buffer).get(), buffLength, buffCapacity) {}
+ UnicodeString(Char16Ptr(buffer), buffLength, buffCapacity) {}
#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
/**
* @draft ICU 59
*/
UnicodeString(wchar_t *buffer, int32_t buffLength, int32_t buffCapacity) :
- UnicodeString(Char16Ptr(buffer).get(), buffLength, buffCapacity) {}
+ UnicodeString(Char16Ptr(buffer), buffLength, buffCapacity) {}
#endif
/**