Commit 67ed8482 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

A test for the atomic_ref deduction guide

Summary:
[Folly] A test for the `atomic_ref` deduction guide, which permits removal of the preprocessor guard in the definition of `make_atomic_ref`.

Some parts of folly still support legacy versions of C++ but we do not necessarily run the tests on legacy platforms.

Reviewed By: akrieger

Differential Revision: D22635366

fbshipit-source-id: 8961d3465b63875a660d9e83d094ebf0cd64d1df
parent e2b1569f
...@@ -140,9 +140,6 @@ struct make_atomic_ref_t { ...@@ -140,9 +140,6 @@ struct make_atomic_ref_t {
alignof(T) == alignof(std::atomic<T>), alignof(T) == alignof(std::atomic<T>),
int> = 0> int> = 0>
atomic_ref<T> operator()(T& ref) const { atomic_ref<T> operator()(T& ref) const {
#if __cpp_deduction_guides >= 201703
return atomic_ref{ref};
#endif
return atomic_ref<T>{ref}; return atomic_ref<T>{ref};
} }
}; };
......
...@@ -20,6 +20,12 @@ ...@@ -20,6 +20,12 @@
class AtomicRefTest : public testing::Test {}; class AtomicRefTest : public testing::Test {};
TEST_F(AtomicRefTest, deduction) {
long value = 17;
auto ref = folly::atomic_ref{value}; // use deduction guide
EXPECT_EQ(17, ref.load(std::memory_order_relaxed));
}
TEST_F(AtomicRefTest, integer) { TEST_F(AtomicRefTest, integer) {
{ {
long value = 17; long value = 17;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment