Commit 81cc37b9 authored by Christos Stratopoulos's avatar Christos Stratopoulos Committed by Facebook Github Bot

do not rely on deprecated __cpp_template_auto macro (#1174)

Summary:
Introduces a `FOLLY_NTTP_AUTO` macro to test if NTTP is available.

As per [cppreference](https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros), the macro `__cpp_nontype_template_parameter_auto` is the correct feature test macro to use for the NTTP used to define poly member list. The `__cpp_template_auto` version is checked too, but it was [deprecated](https://fossies.org/diffs/gcc/8.2.0_vs_8.3.0/gcc/c-family/ChangeLog-diff.html) in gcc 8.3 and not supported at all in MSVC.
Pull Request resolved: https://github.com/facebook/folly/pull/1174

Reviewed By: yfeldblum

Differential Revision: D15906768

Pulled By: Orvid

fbshipit-source-id: 831213ec1214a234246bb6b01be89574a0cace25
parent 52a691fb
......@@ -32,6 +32,13 @@
#include <folly/PolyException.h>
#if defined(__cpp_template_auto) || \
defined(__cpp_nontype_template_parameter_auto)
#define FOLLY_POLY_NTTP_AUTO 1
#else
#define FOLLY_POLY_NTTP_AUTO 0
#endif
namespace folly {
/// \cond
namespace detail {
......@@ -66,7 +73,7 @@ detail::AddCvrefOf<T, I>& poly_cast(detail::PolyRoot<I>&);
template <class T, class I>
detail::AddCvrefOf<T, I> const& poly_cast(detail::PolyRoot<I> const&);
#if !defined(__cpp_template_auto)
#if !FOLLY_POLY_NTTP_AUTO
#define FOLLY_AUTO class
template <class... Ts>
using PolyMembers = detail::TypeList<Ts...>;
......@@ -233,7 +240,7 @@ using MembersOf = typename I::template Members<remove_cvref_t<T>>;
template <class I, class T>
using InterfaceOf = typename I::template Interface<T>;
#if !defined(__cpp_template_auto)
#if !FOLLY_POLY_NTTP_AUTO
template <class T, T V>
using Member = std::integral_constant<T, V>;
......
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