Commit 3a7d1323 authored by Joe Loser's avatar Joe Loser Committed by Facebook Github Bot

Deduction guide for fbvector (#1090)

Summary:
- Add deduction guide for `fbvector` which is only available if the
  feature test macro for deduction guides is available or if we are on
  MSVC.
Pull Request resolved: https://github.com/facebook/folly/pull/1090

Reviewed By: nbronson

Differential Revision: D14663586

Pulled By: yfeldblum

fbshipit-source-id: b3db8fc6ee3b13b84bb6a4a49d2a1801dc80fd4a
parent 1727ca23
......@@ -1748,4 +1748,12 @@ void attach(fbvector<T, A>& v, T* data, size_t sz, size_t cap) {
v.impl_.z_ = data + cap;
}
#if __cpp_deduction_guides >= 201703
template <
class InputIt,
class Allocator =
std::allocator<typename std::iterator_traits<InputIt>::value_type>>
fbvector(InputIt, InputIt, Allocator = Allocator())
->fbvector<typename std::iterator_traits<InputIt>::value_type, Allocator>;
#endif
} // namespace folly
......@@ -256,3 +256,15 @@ TEST(FBVector, zero_len) {
fb6 = il;
fbvector<int> fb7(fb6.begin(), fb6.end());
}
#if __cpp_deduction_guides >= 201703
TEST(FBVector, deduction_guides) {
fbvector<int> v(3);
fbvector x(v.begin(), v.end());
EXPECT_TRUE((std::is_same_v<fbvector<int>, decltype(x)>));
fbvector y{v.begin(), v.end()};
EXPECT_TRUE((std::is_same_v<fbvector<fbvector<int>::iterator>, decltype(y)>));
}
#endif
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