ext/intl: using a bit more modern c++ memory management features.#19163
Conversation
not always possible (e.g. PHP objects) but when scoped we can manage here to simplify memory managament starting with IntlDateFormat.
ndossche
left a comment
There was a problem hiding this comment.
+1 on the idea. Some comments.
| bool pattern = false; | ||
| UDate date; | ||
| TimeZone *timeZone = NULL; | ||
| std::unique_ptr<TimeZone> timeZone = NULL; |
There was a problem hiding this comment.
I believe it's not necessary to value-initialize these unique_ptrs.
| } | ||
| cal = new GregorianCalendar(Locale::createFromName(locale_str), status); | ||
| timeZone = std::unique_ptr<TimeZone>(tz); | ||
| cal = std::unique_ptr<Calendar>(new GregorianCalendar(Locale::createFromName(locale_str), status)); |
There was a problem hiding this comment.
Can't you use make_unique here instead of unique_ptr+new ?
There was a problem hiding this comment.
I wish but isn't it C++14 minimum ?
There was a problem hiding this comment.
Ah right, and it's the ICU version that decides between C++11/C++17... Nvm then ;)
|
this change appears to be the reason I can no longer compile master: does this change require an update of my dependencies or build scripts? |
|
Let me look at it, what is your compiler ? gcc or clang and version. ./configure options. |
…ll supporting C++11.
|
@SjonHortensius let me know if the PR works for you cheers. |
not always possible (e.g. PHP objects) but when scoped we can manage here to simplify memory managament starting with IntlDateFormat.