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

FOLLY_CXX17_CONSTEXPR

Summary: A macro which expands to `constexpr` under C++17. Can be used with `if` and lambdas in cases where `constexpr` is an optional hint but not necessary for the program to compile.

Reviewed By: Mizuchi

Differential Revision: D32607012

fbshipit-source-id: 56a6d8679ab2add4f88c89642166f1ed4b956089
parent 7c40f03a
......@@ -541,17 +541,14 @@ constexpr auto kCpplibVer = 0;
#define FOLLY_STORAGE_CONSTEXPR constexpr
#endif
// FOLLY_LAMBDA_CONSTEXPR
// FOLLY_CXX17_CONSTEXPR
//
// C++17 permits a lambda to be marked constexpr.
//
// Example:
//
// []() FOLLY_LAMBDA_CONSTEXPR { /* ... */ }
// C++17 permits more cases to be marked constexpr, including lambda bodies and
// the `if` keyword.
#if FOLLY_CPLUSPLUS >= 201703L
#define FOLLY_LAMBDA_CONSTEXPR constexpr
#define FOLLY_CXX17_CONSTEXPR constexpr
#else
#define FOLLY_LAMBDA_CONSTEXPR
#define FOLLY_CXX17_CONSTEXPR
#endif
#if __cplusplus >= 201703L
......
......@@ -491,7 +491,7 @@ struct invoke_traits : detail::invoke_traits_base<I> {
*/
#define FOLLY_INVOKE_MEMBER(membername) \
[](auto&& __folly_param_o, auto&&... __folly_param_a) \
FOLLY_LAMBDA_CONSTEXPR FOLLY_DETAIL_FORWARD_BODY( \
FOLLY_CXX17_CONSTEXPR FOLLY_DETAIL_FORWARD_BODY( \
FOLLY_DETAIL_FORWARD_REF(__folly_param_o) \
.membername(FOLLY_DETAIL_FORWARD_REF(__folly_param_a)...))
......
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