Path: blob/main/contrib/llvm-project/libcxx/include/__algorithm/generate_n.h
35232 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef _LIBCPP___ALGORITHM_GENERATE_N_H9#define _LIBCPP___ALGORITHM_GENERATE_N_H1011#include <__config>12#include <__utility/convert_to_integral.h>1314#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15# pragma GCC system_header16#endif1718_LIBCPP_BEGIN_NAMESPACE_STD1920template <class _OutputIterator, class _Size, class _Generator>21inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator22generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen) {23typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize;24_IntegralSize __n = __orig_n;25for (; __n > 0; ++__first, (void)--__n)26*__first = __gen();27return __first;28}2930_LIBCPP_END_NAMESPACE_STD3132#endif // _LIBCPP___ALGORITHM_GENERATE_N_H333435