Commit cd5c885f authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Cut IsRelocatable of containers

Summary:
[Folly] Cut IsRelocatable markings of containers, removing forward declarations of the containers to avoid over-inclusion and to avoid undefined behavior.

> 16.5.4.2.1 [namespace.std]\1
> Unless otherwise specified, the behavior of a C++ program is undefined if it adds declarations or definitions to namespace std or to a namespace within namespace std.

Closes #1203.
Closes #1204.

Reviewed By: igorsugak

Differential Revision: D16855473

fbshipit-source-id: 0e6acc4f589707aa79b0001b415bcadfab652d62
parent 210e404b
......@@ -372,7 +372,7 @@ class fbvector {
if (!std::is_trivially_destructible<T>::value) {
#define FOLLY_FBV_OP(p) (p)->~T()
// EXPERIMENTAL DATA on fbvector<vector<int>> (where each vector<int> has
// size 0).
// size 0), were vector<int> to be relocatable.
// The unrolled version seems to work faster for small to medium sized
// fbvectors. It gets a 10% speedup on fbvectors of size 1024, 64, and
// 16.
......
......@@ -21,6 +21,7 @@
#include <functional>
#include <limits>
#include <memory>
#include <tuple>
#include <type_traits>
#include <folly/Portability.h>
......@@ -604,30 +605,6 @@ struct is_transparent : detail::is_transparent_<void, T> {};
FOLLY_ASSUME_RELOCATABLE(__VA_ARGS__<T1, T2, T3, T4>); \
}
/**
* Instantiate FOLLY_ASSUME_FBVECTOR_COMPATIBLE for a few types. It is
* safe to assume that pair is compatible if both of its components
* are. Furthermore, all STL containers can be assumed to comply,
* although that is not guaranteed by the standard.
*/
FOLLY_NAMESPACE_STD_BEGIN
template <class T, class U>
struct pair;
template <class T, class A>
class vector;
template <class T, class A>
class deque;
template <class T, class C, class A>
class set;
template <class K, class V, class C, class A>
class map;
template <class T>
class shared_ptr;
FOLLY_NAMESPACE_STD_END
namespace folly {
// STL commonly-used types
......@@ -725,11 +702,8 @@ bool greater_than(LHS const lhs) {
// Assume nothing when compiling with MSVC.
#ifndef _MSC_VER
FOLLY_ASSUME_FBVECTOR_COMPATIBLE_2(std::vector)
FOLLY_ASSUME_FBVECTOR_COMPATIBLE_2(std::deque)
FOLLY_ASSUME_FBVECTOR_COMPATIBLE_2(std::unique_ptr)
FOLLY_ASSUME_FBVECTOR_COMPATIBLE_1(std::shared_ptr)
FOLLY_ASSUME_FBVECTOR_COMPATIBLE_1(std::function)
#endif
/* Some combinations of compilers and C++ libraries make __int128 and
......
......@@ -20,6 +20,7 @@
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
#include <folly/ScopeGuard.h>
#include <folly/portability/GTest.h>
......@@ -76,7 +77,7 @@ TEST(Traits, scalars) {
}
TEST(Traits, containers) {
EXPECT_TRUE(IsRelocatable<vector<F1>>::value);
EXPECT_FALSE(IsRelocatable<vector<F1>>::value);
EXPECT_TRUE((IsRelocatable<pair<F1, F1>>::value));
EXPECT_TRUE((IsRelocatable<pair<T1, T2>>::value));
}
......
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