From 634b84eb609e73a6997c7e7e8ae6dbbad6446b53 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sat, 7 Jan 2017 18:27:40 -0500 Subject: [PATCH] Introduce set_install as suggested by PR 99 * Retain install variable as a function local static to maintain recent fixes to initialization order problems. --- tz.cpp | 20 +++++++++++++++++--- tz.h | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tz.cpp b/tz.cpp index 8c6f999..bf7e4b4 100644 --- a/tz.cpp +++ b/tz.cpp @@ -215,10 +215,10 @@ namespace date using namespace detail; static -const std::string& -get_install() +std::string& +access_install() { - static const std::string install + static std::string install #ifndef INSTALL # ifdef _WIN32 @@ -239,6 +239,20 @@ get_install() return install; } +void +set_install(const std::string& s) +{ + access_install() = s; +} + +static +const std::string& +get_install() +{ + static const std::string& ref = access_install(); + return ref; +} + static std::string get_download_gz_file(const std::string& version) diff --git a/tz.h b/tz.h index ec5a8f2..6e7a4dd 100644 --- a/tz.h +++ b/tz.h @@ -767,6 +767,7 @@ operator<<(std::ostream& os, const TZ_DB& db); DATE_API const TZ_DB& get_tzdb(); DATE_API const TZ_DB& reload_tzdb(); +DATE_API void set_install(const std::string& install); #if HAS_REMOTE_API DATE_API std::string remote_version();