Introduce set_install as suggested by PR 99

* Retain install variable as a function local static to maintain
  recent fixes to initialization order problems.
This commit is contained in:
Howard Hinnant 2017-01-07 18:27:40 -05:00
parent 41093d05d8
commit 634b84eb60
2 changed files with 18 additions and 3 deletions

20
tz.cpp
View File

@ -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)

1
tz.h
View File

@ -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();