Commit 9a1bfc69 authored by Eric Niebler's avatar Eric Niebler Committed by Facebook GitHub Bot

Avoid using std::enable_shared_from_this on older stdlibs that don't support weak_from_this()

Summary:
Older standard libraries provide a `std::enable_shared_from_this` that doesn't have a `weak_from_this()` member, even when compiling in C++17 mode. Change the preprocessor conditional to account for this, and select the custom Folly implementation when the `std::` one is non-conforming.

This change makes special accommodation for older MSVC versions, which fails to define the `__cpp_lib_enable_shared_from_this` feature test macro, but that provides a conforming `std::enable_shared_from_this` when compiling as C++17.

Reviewed By: yfeldblum, ispeters

Differential Revision: D25402425

fbshipit-source-id: c53b9fcebbf93c54342824dd56fd11eaa681abd1
parent 175f274c
......@@ -25,7 +25,7 @@ namespace folly {
*
* To be removed once C++17 becomes a minimum requirement for folly.
*/
#if __cplusplus >= 201700L || __cpp_lib_enable_shared_from_this >= 201603L
#if __cpp_lib_enable_shared_from_this >= 201603L || _MSVC_LANG >= 201703L
// Guaranteed to have std::enable_shared_from_this::weak_from_this(). Prefer
// type alias over our own class.
......
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