It does not work and show me the following error message
../../include/v8-maybe.h:84:50: error: call to deleted constructor of 'icu_71::number::FormattedNumberRange'
explicit Maybe(const T& t) : has_value_(true), value_(t) {}
^ ~
../../include/v8-maybe.h:102:10: note: in instantiation of member function 'v8::Maybe<icu_71::number::FormattedNumberRange>::Maybe' requested here
return Maybe<T>(t);
^
../../src/objects/js-number-format.cc:1949:10: note: in instantiation of function template specialization 'v8::Just<icu_71::number::FormattedNumberRange>' requested here
return Just(output);
^
../../third_party/icu/source/i18n/unicode/numberrangeformatter.h:661:5: note: 'FormattedNumberRange' has been explicitly marked deleted here
FormattedNumberRange(const FormattedNumberRange&) = delete;
^
1 error generated.
ninja: build stopped: subcommand failed.
The implementation of the Maybe tempalate can be found in
In v8 code base, one design pattern is having a Maybe<T> as return type.
This in general work for may ICU type, for example
Maybe<icu::Formattable> ToFormattable(Isolate* isolate, Handle<Object> obj, const char* field)
in https://source.chromium.org/chromium/chromium/src/+/main:v8/src/objects/js-number-format.cc;l=1706?q=Maybe<icu::&ss=chromium
or
Maybe<icu::UnicodeString> of(Isolate* isolate, const char* code) const override {
in https://source.chromium.org/chromium/chromium/src/+/main:v8/src/objects/js-display-names.cc;l=127?q=Maybe<icu::&ss=chromium
or
Maybe<icu::Locale> CreateICULocale(const std::string& bcp47_locale) {
in https://source.chromium.org/chromium/chromium/src/+/main:v8/src/objects/intl-objects.cc;l=446;bpv=1;bpt=1?q=Maybe<icu::&ss=chromium
However it does not work with
FormattedNumberRange and FormattedNumber
If change the function
static Maybe<bool> FormatRange( Isolate* isolate, const icu::number::LocalizedNumberRangeFormatter& number_range_format, const IntlMathematicalValue& x, const IntlMathematicalValue& y, icu::number::FormattedNumberRange* output);
to
static Maybe<icu::number::FormattedNumberRange> FormatRange( Isolate* isolate, const icu::number::LocalizedNumberRangeFormatter& number_range_format, const IntlMathematicalValue& x, const IntlMathematicalValue& y);
It does not work and show me the following error message
../../include/v8-maybe.h:84:50: error: call to deleted constructor of 'icu_71::number::FormattedNumberRange' explicit Maybe(const T& t) : has_value_(true), value_(t) {} ^ ~ ../../include/v8-maybe.h:102:10: note: in instantiation of member function 'v8::Maybe<icu_71::number::FormattedNumberRange>::Maybe' requested here return Maybe<T>(t); ^ ../../src/objects/js-number-format.cc:1949:10: note: in instantiation of function template specialization 'v8::Just<icu_71::number::FormattedNumberRange>' requested here return Just(output); ^ ../../third_party/icu/source/i18n/unicode/numberrangeformatter.h:661:5: note: 'FormattedNumberRange' has been explicitly marked deleted here FormattedNumberRange(const FormattedNumberRange&) = delete; ^ 1 error generated. ninja: build stopped: subcommand failed.
The implementation of the Maybe tempalate can be found in
https://source.chromium.org/chromium/chromium/src/+/main:v8/include/v8-maybe.h;drc=8dfda019b0ba2f4953d36071b4601948e1bcf690;l=29
Same as FormattedNumber
Please help to figure out how can we change ICU api to let v8 use Maybe<> as return for FormattedNumber and FormattedNumberRange.