Commit 5caa4e1d authored by Joe Loser's avatar Joe Loser Committed by Facebook Github Bot

Fix deduction guide macro guard for Replaceable (#1097)

Summary:
- `Replaceable` defines a deduction guide if the feature test macro for
  it is met, or if we are on MSVC. However, the MSVC version that folly
  supports also defines the feature test macro for deduction guides. As
  such, remove the extra check for MSVC.
- Add `ReplaceableTest` to the  cmake build.
- Add test for deduction guide.
Pull Request resolved: https://github.com/facebook/folly/pull/1097

Reviewed By: Orvid

Differential Revision: D14699047

Pulled By: yfeldblum

fbshipit-source-id: ee62bae0f4b05f1a110c2bd90470fecbb0666d24
parent abc7ab99
......@@ -637,7 +637,7 @@ class alignas(T) Replaceable
aligned_storage_for_t<T> storage_[1];
};
#if __cpp_deduction_guides >= 201703 || _MSC_VER
#if __cpp_deduction_guides >= 201703
template <class T>
Replaceable(T)->Replaceable<T>;
#endif
......
......@@ -334,3 +334,11 @@ TEST(ReplaceableTest, swapMemberFunctionDelegatesToUserSwap) {
r1.swap(r2);
EXPECT_TRUE(r1->calledSwap);
}
#if __cpp_deduction_guides >= 201703
TEST(ReplaceableTest, DeductionGuide) {
Basic b{};
Replaceable r{b};
EXPECT_TRUE((std::is_same_v<Replaceable<Basic>, decltype(r)>));
}
#endif
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