Commit 09cbf47e authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Only use explicit copy-ctor in to_narrow with C++17

Summary: [Folly] Only use `explicit` copy-ctor in `to_narrow` with C++17 and higher, since C++17 introduces mandatory copy elision and the technique here relies on mandatory copy elision.

Differential Revision: D19175384

fbshipit-source-id: 9d3234a71b1b5e4f31d14137e42dbf3a73c79b2e
parent 764cdc0d
...@@ -312,8 +312,13 @@ class to_narrow_convertible { ...@@ -312,8 +312,13 @@ class to_narrow_convertible {
explicit constexpr to_narrow_convertible(Src const& value) noexcept explicit constexpr to_narrow_convertible(Src const& value) noexcept
: value_(value) {} : value_(value) {}
#if __cplusplus >= 201703L
explicit to_narrow_convertible(to_narrow_convertible const&) = default; explicit to_narrow_convertible(to_narrow_convertible const&) = default;
explicit to_narrow_convertible(to_narrow_convertible&&) = default; explicit to_narrow_convertible(to_narrow_convertible&&) = default;
#else
to_narrow_convertible(to_narrow_convertible const&) = default;
to_narrow_convertible(to_narrow_convertible&&) = default;
#endif
to_narrow_convertible& operator=(to_narrow_convertible const&) = default; to_narrow_convertible& operator=(to_narrow_convertible const&) = default;
to_narrow_convertible& operator=(to_narrow_convertible&&) = default; to_narrow_convertible& operator=(to_narrow_convertible&&) = default;
......
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