/* * Copyright (c) Facebook, Inc. and its affiliates. * * 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 using is_ref_wrapper = detail::is_instantiation_of; 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_ERASE constexpr auto make_array_with_( MakeItem const& make, std::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, std::make_index_sequence{}); } } // namespace folly