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
main v2022.02.14.00 v2022.02.07.00 v2022.01.31.00 v2022.01.24.00 v2022.01.17.00 v2022.01.10.00 v2022.01.03.00 v2021.12.27.00 v2021.12.20.00 v2021.12.13.00 v2021.12.06.00 v2021.11.29.00 v2021.11.15.00 v2021.11.08.00 v2021.11.01.00 v2021.10.25.00 v2021.10.18.00 v2021.10.11.00 v2021.10.04.00 v2021.09.27.00 v2021.09.20.00 v2021.09.13.00 v2021.09.06.00 v2021.08.30.00 v2021.08.23.00 v2021.08.02.00 v2021.07.22.00 v2021.07.20.01 v2021.07.20.00 v2021.06.28.00 v2021.06.14.00 v2021.06.07.00 v2021.05.31.00 v2021.05.24.00 v2021.05.17.00 v2021.05.10.00 v2021.05.03.00 v2021.04.26.00 v2021.04.19.00 v2021.04.12.00 v2021.04.05.00 v2021.03.29.00 v2021.03.22.00 v2021.03.15.00 v2021.03.08.00 v2021.03.01.00 v2021.02.22.00 v2021.02.15.00 v2021.02.08.00 v2021.02.01.00 v2021.01.25.00 v2021.01.18.01 v2021.01.18.00 v2021.01.11.00 v2021.01.04.00 v2020.12.28.00 v2020.12.21.00 v2020.12.14.00 v2020.12.07.00 v2020.11.30.00 v2020.11.23.00 v2020.11.16.00 v2020.11.09.00 v2020.11.02.00 v2020.10.26.00 v2020.10.19.00 v2020.10.12.00 v2020.10.05.00 v2020.09.28.00 v2020.09.21.00 v2020.09.14.00 v2020.09.07.00 v2020.08.31.00 v2020.08.24.00 v2020.08.17.00 v2020.08.10.00 v2020.08.03.00 v2020.07.27.00 v2020.07.20.00 v2020.07.13.00 v2020.07.06.00 v2020.06.29.00 v2020.06.15.00 v2020.06.08.00 v2020.06.01.00 v2020.05.25.00 v2020.05.18.00 v2020.05.11.00 v2020.05.04.00 v2020.04.27.00 v2020.04.20.00 v2020.04.13.00 v2020.04.06.00 v2020.03.30.00 v2020.03.23.00 v2020.03.16.00 v2020.03.09.00 v2020.03.02.00 v2020.02.24.00 v2020.02.17.00 v2020.02.10.00 v2020.02.03.00 v2020.01.27.00 v2020.01.20.00 v2020.01.13.00 v2020.01.06.00 v2019.12.30.00 v2019.12.23.00 v2019.12.16.00 v2019.12.09.00 v2019.12.06.00 v2019.12.02.00 v2019.11.11.00 v2019.11.04.00 v2019.10.28.00 v2019.10.21.00 v2019.10.14.00 v2019.10.07.00 v2019.09.30.00 v2019.09.23.00 v2019.09.16.00 v2019.09.09.00 v2019.09.02.00 v2019.08.26.00 v2019.08.19.00
No related merge requests found
......@@ -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