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

let FOLLY_TYPE_INFO_OF always use its arg

Summary: Even when RTTI is disabled, to avoid unused-arg warnings. Then use `FOLLY_TYPE_INFO_OF` to simplify the conditional compilation in `UniqueInstance`.

Reviewed By: praihan

Differential Revision: D30183405

fbshipit-source-id: 040d90751822dedb8faca561a89dcf35da25119b
parent bf6d3e57
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <typeinfo> #include <typeinfo>
#include <folly/CppAttributes.h> #include <folly/CppAttributes.h>
#include <folly/Portability.h>
#include <folly/detail/StaticSingletonManager.h> #include <folly/detail/StaticSingletonManager.h>
namespace folly { namespace folly {
...@@ -28,14 +27,15 @@ namespace detail { ...@@ -28,14 +27,15 @@ namespace detail {
class UniqueInstance { class UniqueInstance {
public: public:
#if !FOLLY_HAS_RTTI || (__GNUC__ && __GNUC__ < 7 && !__clang__) #if __GNUC__ && __GNUC__ < 7 && !__clang__
explicit UniqueInstance(...) noexcept {} explicit UniqueInstance(...) noexcept {}
#else #else
template <template <typename...> class Z, typename... Key, typename... Mapped> template <template <typename...> class Z, typename... Key, typename... Mapped>
FOLLY_EXPORT FOLLY_ALWAYS_INLINE explicit UniqueInstance( FOLLY_EXPORT FOLLY_ALWAYS_INLINE explicit UniqueInstance(
tag_t<Z<Key..., Mapped...>>, tag_t<Key...>, tag_t<Mapped...>) noexcept { tag_t<Z<Key..., Mapped...>>, tag_t<Key...>, tag_t<Mapped...>) noexcept {
static Ptr const tmpl = &typeid(key_t<Z>); static Ptr const tmpl = FOLLY_TYPE_INFO_OF(key_t<Z>);
static Ptr const ptrs[] = {&typeid(Key)..., &typeid(Mapped)...}; static Ptr const ptrs[] = {
FOLLY_TYPE_INFO_OF(Key)..., FOLLY_TYPE_INFO_OF(Mapped)...};
static Arg arg{ static Arg arg{
{tmpl, ptrs, sizeof...(Key), sizeof...(Mapped)}, {tmpl, ptrs, sizeof...(Key), sizeof...(Mapped)},
{tag<Value, key_t<Z, Key...>>}}; {tag<Value, key_t<Z, Key...>>}};
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
#if FOLLY_HAS_RTTI #if FOLLY_HAS_RTTI
#define FOLLY_TYPE_INFO_OF(...) (&typeid(__VA_ARGS__)) #define FOLLY_TYPE_INFO_OF(...) (&typeid(__VA_ARGS__))
#else #else
#define FOLLY_TYPE_INFO_OF(...) (static_cast<std::type_info const*>(nullptr)) #define FOLLY_TYPE_INFO_OF(...) \
((sizeof(__VA_ARGS__)), static_cast<std::type_info const*>(nullptr))
#endif #endif
namespace folly { namespace folly {
......
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