/* * Copyright 2016-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include #include #include #include #include namespace folly { namespace array_detail { template struct is_ref_wrapper : std::false_type {}; template struct is_ref_wrapper> : std::true_type {}; template using not_ref_wrapper = folly::Negation::type>>; template struct return_type_helper { using type = D; }; template struct return_type_helper { static_assert( folly::Conjunction...>::value, "TList cannot contain reference_wrappers when D is void"); using type = typename std::common_type::type; }; template using return_type = std:: array::type, sizeof...(TList)>; } // namespace array_detail template constexpr array_detail::return_type make_array(TList&&... t) { using value_type = typename array_detail::return_type_helper::type; return {{static_cast(std::forward(t))...}}; } namespace array_detail { template FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN constexpr auto make_array_with( MakeItem const& make, index_sequence) { return std::array{{make(Index)...}}; } } // namespace array_detail // make_array_with // // Constructs a std::array<..., Size> with elements m(i) for i in [0, Size). template constexpr auto make_array_with(MakeItem const& make) { return array_detail::make_array_with(make, make_index_sequence{}); } } // namespace folly