|
|
|||
File indexing completed on 2025-12-15 09:53:04
0001 /*! 0002 @file 0003 Forward declares `boost::hana::intersperse`. 0004 0005 Copyright Louis Dionne 2013-2022 0006 Distributed under the Boost Software License, Version 1.0. 0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 0008 */ 0009 0010 #ifndef BOOST_HANA_FWD_INTERSPERSE_HPP 0011 #define BOOST_HANA_FWD_INTERSPERSE_HPP 0012 0013 #include <boost/hana/config.hpp> 0014 #include <boost/hana/core/when.hpp> 0015 0016 0017 namespace boost { namespace hana { 0018 //! Insert a value between each pair of elements in a finite sequence. 0019 //! @ingroup group-Sequence 0020 //! 0021 //! Given a finite `Sequence` `xs` with a linearization of 0022 //! `[x1, x2, ..., xn]`, `intersperse(xs, z)` is a new sequence with a 0023 //! linearization of `[x1, z, x2, z, x3, ..., xn-1, z, xn]`. In other 0024 //! words, it inserts the `z` element between every pair of elements of 0025 //! the original sequence. If the sequence is empty or has a single 0026 //! element, `intersperse` returns the sequence as-is. In all cases, 0027 //! the sequence must be finite. 0028 //! 0029 //! 0030 //! @param xs 0031 //! The sequence in which a value is interspersed. 0032 //! 0033 //! @param z 0034 //! The value to be inserted between every pair of elements of the sequence. 0035 //! 0036 //! 0037 //! Example 0038 //! ------- 0039 //! @include example/intersperse.cpp 0040 #ifdef BOOST_HANA_DOXYGEN_INVOKED 0041 constexpr auto intersperse = [](auto&& xs, auto&& z) { 0042 return tag-dispatched; 0043 }; 0044 #else 0045 template <typename S, typename = void> 0046 struct intersperse_impl : intersperse_impl<S, when<true>> { }; 0047 0048 struct intersperse_t { 0049 template <typename Xs, typename Z> 0050 constexpr auto operator()(Xs&& xs, Z&& z) const; 0051 }; 0052 0053 BOOST_HANA_INLINE_VARIABLE constexpr intersperse_t intersperse{}; 0054 #endif 0055 }} // end namespace boost::hana 0056 0057 #endif // !BOOST_HANA_FWD_INTERSPERSE_HPP
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|