/*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2015 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
enum { value = std::is_same<T, T1>::value || IsOneOf<T, Ts...>::value };
};
-/**
- * A traits class to check for incomplete types.
- *
- * Example:
- *
- * struct FullyDeclared {}; // complete type
- * struct ForwardDeclared; // incomplete type
- *
- * is_complete<int>::value // evaluates to true
- * is_complete<FullyDeclared>::value // evaluates to true
- * is_complete<ForwardDeclared>::value // evaluates to false
- *
- * struct ForwardDeclared {}; // declared, at last
- *
- * is_complete<ForwardDeclared>::value // now it evaluates to true
- *
- * @author: Marcelo Juchem <marcelo@fb.com>
- */
-template <typename T>
-class is_complete {
- template <unsigned long long> struct sfinae {};
- template <typename U>
- constexpr static bool test(sfinae<sizeof(U)>*) { return true; }
- template <typename> constexpr static bool test(...) { return false; }
-public:
- constexpr static bool value = test<T>(nullptr);
-};
-
/*
* Complementary type traits for integral comparisons.
*
template <typename T>
struct is_negative_impl<T, false> {
- constexpr static bool check(T x) { return false; }
+ constexpr static bool check(T) { return false; }
};
// folly::to integral specializations can end up generating code
// Boost
FOLLY_ASSUME_FBVECTOR_COMPATIBLE_1(boost::shared_ptr);
+#define FOLLY_CREATE_HAS_MEMBER_TYPE_TRAITS(classname, type_name) \
+ template <typename T> \
+ struct classname { \
+ template <typename C> \
+ constexpr static bool test(typename C::type_name*) { return true; } \
+ template <typename> \
+ constexpr static bool test(...) { return false; } \
+ constexpr static bool value = test<T>(nullptr); \
+ }
+
#define FOLLY_CREATE_HAS_MEMBER_FN_TRAITS_IMPL(classname, func_name, cv_qual) \
template <typename TTheClass_, typename RTheReturn_, typename... TTheArgs_> \
class classname<TTheClass_, RTheReturn_(TTheArgs_...) cv_qual> { \