• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*!
2 @file
3 Forward declares `boost::hana::permutations`.
4 
5 @copyright Louis Dionne 2013-2017
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
8  */
9 
10 #ifndef BOOST_HANA_FWD_PERMUTATIONS_HPP
11 #define BOOST_HANA_FWD_PERMUTATIONS_HPP
12 
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
15 
16 
17 BOOST_HANA_NAMESPACE_BEGIN
18     //! Return a sequence of all the permutations of the given sequence.
19     //! @ingroup group-Sequence
20     //!
21     //! Specifically, `permutations(xs)` is a sequence whose elements are
22     //! permutations of the original sequence `xs`. The permutations are not
23     //! guaranteed to be in any specific order. Also note that the number
24     //! of permutations grows very rapidly as the length of the original
25     //! sequence increases. The growth rate is `O(length(xs)!)`; with a
26     //! sequence `xs` of length only 8, `permutations(xs)` contains over
27     //! 40 000 elements!
28     //!
29     //!
30     //! Example
31     //! -------
32     //! @include example/permutations.cpp
33 #ifdef BOOST_HANA_DOXYGEN_INVOKED
__anon45b497270102(auto&& xs) 34     constexpr auto permutations = [](auto&& xs) {
35         return tag-dispatched;
36     };
37 #else
38     template <typename S, typename = void>
39     struct permutations_impl : permutations_impl<S, when<true>> { };
40 
41     struct permutations_t {
42         template <typename Xs>
43         constexpr auto operator()(Xs&& xs) const;
44     };
45 
46     constexpr permutations_t permutations{};
47 #endif
48 BOOST_HANA_NAMESPACE_END
49 
50 #endif // !BOOST_HANA_FWD_PERMUTATIONS_HPP
51