Skip to content

Commit

Permalink
static_assert that absl::Time and absl::Duration are trivially destru…
Browse files Browse the repository at this point in the history
…ctible.

PiperOrigin-RevId: 706793904
Change-Id: I1c7c9b871db73ca9910fd8fbaa52511da2872de0
  • Loading branch information
Abseil Team authored and copybara-github committed Dec 16, 2024
1 parent d30f578 commit 82d40e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions absl/time/duration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <limits>
#include <random>
#include <string>
#include <type_traits>

#include "gmock/gmock.h"
#include "gtest/gtest.h"
Expand Down Expand Up @@ -74,6 +75,8 @@ MATCHER_P(TimevalMatcher, tv, "") {
}

TEST(Duration, ConstExpr) {
static_assert(std::is_trivially_destructible<absl::Duration>::value,
"Duration is documented as being trivially destructible");
constexpr absl::Duration d0 = absl::ZeroDuration();
static_assert(d0 == absl::ZeroDuration(), "ZeroDuration()");
constexpr absl::Duration d1 = absl::Seconds(1);
Expand Down
3 changes: 3 additions & 0 deletions absl/time/time_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <ios>
#include <limits>
#include <string>
#include <type_traits>

#include "gmock/gmock.h"
#include "gtest/gtest.h"
Expand Down Expand Up @@ -89,6 +90,8 @@ MATCHER_P(TimevalMatcher, tv, "") {
}

TEST(Time, ConstExpr) {
static_assert(std::is_trivially_destructible<absl::Time>::value,
"Time is documented as being trivially destructible");
constexpr absl::Time t0 = absl::UnixEpoch();
static_assert(t0 == absl::UnixEpoch(), "UnixEpoch");
constexpr absl::Time t1 = absl::InfiniteFuture();
Expand Down

0 comments on commit 82d40e6

Please sign in to comment.