* @return the array pointer
*/
T *getAlias() const { return ptr; }
+ /**
+ * Access without ownership change.
+ * @return the array pointer
+ */
+ const T *getConstAlias() const { return ptr; }
/**
* Returns the array limit. Simple convenience method.
* @return getAlias()+getCapacity()
return this->fPool.getAlias();
}
+ const T *const *getConstAlias() const {
+ return this->fPool.getConstAlias();
+ }
+
/**
* Array item access (read-only).
* No index bounds check.
// of some kind.
void U_I18N_API UnitPreferences::getPreferencesFor(const char *category, const char *usage,
const char *region,
- const UnitPreference **&outPreferences,
+ const UnitPreference *const *&outPreferences,
int32_t &preferenceCount, UErrorCode &status) const {
int32_t idx = getPreferenceMetadataIndex(&metadata_, category, usage, region, status);
if (U_FAILURE(status)) { return; }
U_ASSERT(idx >= 0); // Failures should have been taken care of by `status`.
const UnitPreferenceMetadata *m = metadata_[idx];
- outPreferences = const_cast<const UnitPreference **>(unitPrefs_.getAlias()) + m->prefsOffset;
+ outPreferences = unitPrefs_.getConstAlias() + m->prefsOffset;
preferenceCount = m->prefsCount;
}
* TODO: maybe replace `UnitPreference **&outPrefrences` with a slice class?
*/
void getPreferencesFor(const char *category, const char *usage, const char *region,
- const UnitPreference **&outPreferences, int32_t &preferenceCount,
+ const UnitPreference *const *&outPreferences, int32_t &preferenceCount,
UErrorCode &status) const;
protected:
for (const auto &t : testCases) {
logln(t.name);
- const UnitPreference **prefs;
+ const UnitPreference *const *prefs;
int32_t prefsCount;
preferences.getPreferencesFor(t.category, t.usage, t.region, prefs, prefsCount, status);
if (status.errIfFailureAndReset("getPreferencesFor(\"%s\", \"%s\", \"%s\", ...", t.category,