Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<chrono>: Make tzdb_list's internal ctor harder to unintentionally use #4229

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -2202,6 +2202,10 @@ namespace chrono {
return _STD move(_Icu_version) + "." + _STD to_string(_Num_leap_seconds);
}

struct _Secret_tzdb_list_construct_tag {
explicit _Secret_tzdb_list_construct_tag() = default;
};

_EXPORT_STD class tzdb_list {
private:
using _ListType = forward_list<tzdb, _Crt_allocator<tzdb>>;
Expand All @@ -2212,7 +2216,7 @@ namespace chrono {
tzdb_list(const tzdb_list&) = delete;
tzdb_list& operator=(const tzdb_list&) = delete;

tzdb_list() {
explicit tzdb_list(_Secret_tzdb_list_construct_tag) {
auto [_Icu_version, _Zones, _Links] = _Tzdb_generate_time_zones();
auto [_Leap_sec, _All_ls_positive] = _Tzdb_generate_leap_seconds(0);
auto _Version = _Icu_version + "." + _STD to_string(_Leap_sec.size());
Expand Down Expand Up @@ -2328,7 +2332,7 @@ namespace chrono {
}

_TRY_BEGIN
_STD construct_at(_My_tzdb);
_STD construct_at(_My_tzdb, _Secret_tzdb_list_construct_tag{});
_CATCH(const runtime_error&)
__std_free_crt(_My_tzdb);
_RERAISE;
Expand Down