diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-02-11 20:04:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-11 20:04:49 +0100 |
commit | 25dae690c989d6b0651cd619b8d3d2f7955d6b96 (patch) | |
tree | 1828ebceac6ef7a890322187b68a64f1bbb2dec1 | |
parent | 98fdc0e897d8036599ae05ccab6ee3971c4d0413 (diff) | |
parent | cc68f1d562b94245f5a86d476b54b62d56f91ef4 (diff) |
Merge pull request #25996 from vespa-engine/toregge/add-workaround-for-libcxx-lacking-ostream-operator-for-duration
Add workaround for libc++ lacking stream operators for duration.
-rw-r--r-- | vespalib/src/vespa/vespalib/util/time.cpp | 18 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/time.h | 13 |
2 files changed, 31 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/util/time.cpp b/vespalib/src/vespa/vespalib/util/time.cpp index 51d5e580609..42155647870 100644 --- a/vespalib/src/vespa/vespalib/util/time.cpp +++ b/vespalib/src/vespa/vespalib/util/time.cpp @@ -92,3 +92,21 @@ Timer::waitAtLeast(duration dur, bool busyWait) { } } + +#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 160000 + +// Temporary workaround until libc++ supports stream operators for duration + +#include <ostream> + +namespace std::chrono { + +ostream& +operator<<(ostream& os, const nanoseconds& value) +{ + os << value.count() << "ns"; + return os; +} + +} +#endif diff --git a/vespalib/src/vespa/vespalib/util/time.h b/vespalib/src/vespa/vespalib/util/time.h index ce914b097d4..27f359071ae 100644 --- a/vespalib/src/vespa/vespalib/util/time.h +++ b/vespalib/src/vespa/vespalib/util/time.h @@ -99,3 +99,16 @@ duration adjustTimeoutByDetectedHz(duration timeout); duration adjustTimeoutByHz(duration timeout, long hz); } + +#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 160000 + +// Temporary workaround until libc++ supports stream operators for duration + +#include <iosfwd> + +namespace std::chrono { + +ostream& operator<<(ostream& os, const nanoseconds& value); + +} +#endif |