diff --git a/example/view/make.cpp b/example/view/make.cpp new file mode 100644 index 0000000000..20b2007d11 --- /dev/null +++ b/example/view/make.cpp @@ -0,0 +1,23 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +constexpr auto tuple = hana::make_tuple(1, 2.2, '3'); +constexpr auto view = hana::make_view(tuple); + +// Until an algorithm is applied to the view, it is basically a reference +// to the original object, unchanged. +static_assert(hana::at_c<0>(view) == 1, ""); +static_assert(hana::at_c<1>(view) == 2.2, ""); +static_assert(hana::at_c<2>(view) == '3', ""); + +int main() { } diff --git a/example/view/view.cpp b/example/view/view.cpp new file mode 100644 index 0000000000..4e66569534 --- /dev/null +++ b/example/view/view.cpp @@ -0,0 +1,41 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using namespace hana::literals; + + +struct Fish { std::string name; }; +struct Cat { std::string name; }; +struct Dog { std::string name; }; + +int main() { + hana::tuple animals{{"Nemo"}, {"Garfield"}, {"Snoopy"}}; + + // Create a view of the tuple + auto view = hana::make_view(animals); + + // Apply an algorithm to the view. No work is actually done here, this + // just returns a new filtered view. + auto mammals = hana::remove_if(view, [](auto const& a) { + return hana::is_a(a); + }); + + // The work is done here, when accessing the elements of the view. + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(mammals).name == "Garfield"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(mammals).name == "Snoopy"); + + // Views have reference semantics, so we can use them to modify the + // original containers (unless the view applies a transformation). + hana::at_c<1>(mammals).name = "Beethoven"; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(animals).name == "Beethoven"); +} diff --git a/include/boost/hana.hpp b/include/boost/hana.hpp index a8ad0413f1..8bff47f907 100644 --- a/include/boost/hana.hpp +++ b/include/boost/hana.hpp @@ -199,6 +199,7 @@ namespace boost { #include #include #include +#include #include #include #include diff --git a/include/boost/hana/cartesian_product.hpp b/include/boost/hana/cartesian_product.hpp index 556c3b5237..f4d9f322f2 100644 --- a/include/boost/hana/cartesian_product.hpp +++ b/include/boost/hana/cartesian_product.hpp @@ -59,9 +59,12 @@ BOOST_HANA_NAMESPACE_BEGIN static constexpr std::size_t length = total_length(); static constexpr auto indices_of(std::size_t i) { - constexpr std::size_t lengths[sizeof...(Lengths)] = {Lengths...}; constexpr std::size_t n = sizeof...(Lengths); + constexpr std::size_t lengths[n] = {Lengths...}; detail::array result{}; + if (length == 0) { + return result; + } for (std::size_t j = n; j--;) { result[j] = i % lengths[j]; i /= lengths[j]; @@ -69,21 +72,72 @@ BOOST_HANA_NAMESPACE_BEGIN return result; } - template + template static constexpr auto - product_element(std::index_sequence, Xs&& ...xs) { + product_element(std::index_sequence, F&& f, Xs&& ...xs) { constexpr auto indices = indices_of(n); - return hana::make(hana::at_c(xs)...); + return static_cast(f)(hana::at_c(xs)...); } - template + template static constexpr auto - create_product(std::index_sequence, Xs&& ...xs) { - return hana::make(product_element( - std::make_index_sequence{}, xs... + create_product(std::index_sequence, F&& f, Xs&& ...xs) { + return F{}(product_element( + std::make_index_sequence{}, + static_cast(f), xs... )...); } }; + + template <> + struct cartesian_product_indices<> { + static constexpr std::size_t total_length() + { return 0; } + + static constexpr std::size_t length = 0; + }; + + struct make_cartesian_product_indices_helper_t { + template + constexpr auto operator()(Xs&& ...xs) const + -> detail::cartesian_product_indices< + decltype(hana::length(xs))::value... + > + { return {}; } + }; + + struct make_cartesian_product_indices_t { + template + constexpr auto operator()(Xs&& xs) const { + return hana::unpack( + static_cast(xs), + make_cartesian_product_indices_helper_t{}); + } + }; + + constexpr make_cartesian_product_indices_t make_cartesian_product_indices{}; + + template + struct make_cartesian_product_element_t { + F const& f; + + constexpr auto operator()() const { + return f(); + } + + template + constexpr auto operator()(X1&& x1, Xs&& ...xs) const { + constexpr auto indices = detail::cartesian_product_indices< + decltype(hana::length(x1))::value, + decltype(hana::length(xs))::value... + >{}; + return indices.template product_element( + std::make_index_sequence{}, f, + static_cast(x1), + static_cast(xs)... + ); + } + }; } // Credits: implementation adapted from http://github.com/alexk7/hel. @@ -99,8 +153,9 @@ BOOST_HANA_NAMESPACE_BEGIN using indices = detail::cartesian_product_indices< decltype(hana::length(xs))::value... >; - return indices::template create_product( + return indices::template create_product( std::make_index_sequence{}, + hana::make, static_cast(xs)...); } diff --git a/include/boost/hana/experimental/view.hpp b/include/boost/hana/experimental/view.hpp deleted file mode 100644 index cc2f4c606f..0000000000 --- a/include/boost/hana/experimental/view.hpp +++ /dev/null @@ -1,515 +0,0 @@ -/* -@file -Defines experimental views. - -@copyright Louis Dionne 2013-2017 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#ifndef BOOST_HANA_EXPERIMENTAL_VIEW_HPP -#define BOOST_HANA_EXPERIMENTAL_VIEW_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -// Pros of views -// - No temporary container created between algorithms -// - Lazy, so only the minimum is required -// -// Cons of views -// - Reference semantics mean possibility for dangling references -// - Lose the ability to move from temporary containers -// - When fetching the members of a view multiple times, no caching is done. -// So for example, `t = transform(xs, f); at_c<0>(t); at_c<0>(t)` will -// compute `f(at_c<0>(xs))` twice. -// - push_back creates a joint_view and a single_view. The single_view holds -// the value as a member. When doing multiple push_backs, we end up with a -// joint_view, joint_view, ....>>> -// which contains a reference to `xxx` and all the `T`s by value. Such a -// "view" is not cheap to copy, which is inconsistent with the usual -// expectations about views. - -BOOST_HANA_NAMESPACE_BEGIN - -namespace experimental { - struct view_tag; - - namespace detail { - template - struct is_view { - static constexpr bool value = false; - }; - - template - using view_storage = typename std::conditional< - detail::is_view::value, Sequence, Sequence& - >::type; - } - - ////////////////////////////////////////////////////////////////////////// - // sliced_view - ////////////////////////////////////////////////////////////////////////// - template - struct sliced_view_t { - detail::view_storage sequence_; - using hana_tag = view_tag; - }; - - template - constexpr auto sliced(Sequence& sequence, Indices const& indices) { - return hana::unpack(indices, [&](auto ...i) { - return sliced_view_t{sequence}; - }); - } - - namespace detail { - template - struct is_view> { - static constexpr bool value = true; - }; - } - - ////////////////////////////////////////////////////////////////////////// - // transformed_view - ////////////////////////////////////////////////////////////////////////// - template - struct transformed_view_t { - detail::view_storage sequence_; - F f_; - using hana_tag = view_tag; - }; - - template - constexpr transformed_view_t::type> - transformed(Sequence& sequence, F&& f) { - return {sequence, static_cast(f)}; - } - - namespace detail { - template - struct is_view> { - static constexpr bool value = true; - }; - } - - ////////////////////////////////////////////////////////////////////////// - // filtered_view - ////////////////////////////////////////////////////////////////////////// -#if 0 - template - using filtered_view_t = sliced_view_t>; - - template - constexpr filtered_view_t filtered(Sequence& sequence, Pred&& pred) { - return {sequence}; - } -#endif - - ////////////////////////////////////////////////////////////////////////// - // joined_view - ////////////////////////////////////////////////////////////////////////// - template - struct joined_view_t { - detail::view_storage sequence1_; - detail::view_storage sequence2_; - using hana_tag = view_tag; - }; - - struct make_joined_view_t { - template - constexpr joined_view_t operator()(Sequence1& s1, Sequence2& s2) const { - return {s1, s2}; - } - }; - constexpr make_joined_view_t joined{}; - - namespace detail { - template - struct is_view> { - static constexpr bool value = true; - }; - } - - ////////////////////////////////////////////////////////////////////////// - // single_view - ////////////////////////////////////////////////////////////////////////// - template - struct single_view_t { - T value_; - using hana_tag = view_tag; - }; - - template - constexpr single_view_t::type> single_view(T&& t) { - return {static_cast(t)}; - } - - namespace detail { - template - struct is_view> { - static constexpr bool value = true; - }; - } - - ////////////////////////////////////////////////////////////////////////// - // empty_view - ////////////////////////////////////////////////////////////////////////// - struct empty_view_t { - using hana_tag = view_tag; - }; - - constexpr empty_view_t empty_view() { - return {}; - } - - namespace detail { - template <> - struct is_view { - static constexpr bool value = true; - }; - } -} // end namespace experimental - -////////////////////////////////////////////////////////////////////////// -// Foldable -////////////////////////////////////////////////////////////////////////// -template <> -struct unpack_impl { - // sliced_view - template - static constexpr decltype(auto) - apply(experimental::sliced_view_t view, F&& f) { - (void)view; // Remove spurious unused variable warning with GCC - return static_cast(f)(hana::at_c(view.sequence_)...); - } - - // transformed_view - template - static constexpr decltype(auto) - apply(experimental::transformed_view_t view, G&& g) { - return hana::unpack(view.sequence_, hana::on(static_cast(g), view.f_)); - } - - // joined_view - template - static constexpr decltype(auto) - unpack_joined(View view, F&& f, std::index_sequence, - std::index_sequence) - { - (void)view; // Remove spurious unused variable warning with GCC - return static_cast(f)(hana::at_c(view.sequence1_)..., - hana::at_c(view.sequence2_)...); - } - - template - static constexpr decltype(auto) - apply(experimental::joined_view_t view, F&& f) { - constexpr auto N1 = decltype(hana::length(view.sequence1_))::value; - constexpr auto N2 = decltype(hana::length(view.sequence2_))::value; - return unpack_joined(view, static_cast(f), - std::make_index_sequence{}, - std::make_index_sequence{}); - } - - // single_view - template - static constexpr decltype(auto) apply(experimental::single_view_t view, F&& f) { - return static_cast(f)(view.value_); - } - - // empty_view - template - static constexpr decltype(auto) apply(experimental::empty_view_t, F&& f) { - return static_cast(f)(); - } -}; - -////////////////////////////////////////////////////////////////////////// -// Iterable -////////////////////////////////////////////////////////////////////////// -template <> -struct at_impl { - // sliced_view - template - static constexpr decltype(auto) - apply(experimental::sliced_view_t view, N const&) { - constexpr std::size_t indices[] = {i...}; - constexpr std::size_t n = indices[N::value]; - return hana::at_c(view.sequence_); - } - - // transformed_view - template - static constexpr decltype(auto) - apply(experimental::transformed_view_t view, N const& n) { - return view.f_(hana::at(view.sequence_, n)); - } - - // joined_view - template - static constexpr decltype(auto) at_joined_view(View view, N const&, hana::true_) { - return hana::at_c(view.sequence1_); - } - - template - static constexpr decltype(auto) at_joined_view(View view, N const&, hana::false_) { - return hana::at_c(view.sequence2_); - } - - template - static constexpr decltype(auto) - apply(experimental::joined_view_t view, N const& n) { - constexpr auto Left = decltype(hana::length(view.sequence1_))::value; - return at_joined_view(view, n, hana::bool_c<(N::value < Left)>); - } - - // single_view - template - static constexpr decltype(auto) apply(experimental::single_view_t view, N const&) { - static_assert(N::value == 0, - "trying to fetch an out-of-bounds element in a hana::single_view"); - return view.value_; - } - - // empty_view - template - static constexpr decltype(auto) apply(experimental::empty_view_t, N const&) = delete; -}; - -template <> -struct length_impl { - // sliced_view - template - static constexpr auto - apply(experimental::sliced_view_t) { - return hana::size_c; - } - - // transformed_view - template - static constexpr auto apply(experimental::transformed_view_t view) { - return hana::length(view.sequence_); - } - - // joined_view - template - static constexpr auto apply(experimental::joined_view_t view) { - return hana::size_c< - decltype(hana::length(view.sequence1_))::value + - decltype(hana::length(view.sequence2_))::value - >; - } - - // single_view - template - static constexpr auto apply(experimental::single_view_t) { - return hana::size_c<1>; - } - - // empty_view - static constexpr auto apply(experimental::empty_view_t) { - return hana::size_c<0>; - } -}; - -template <> -struct is_empty_impl { - // sliced_view - template - static constexpr auto - apply(experimental::sliced_view_t) { - return hana::bool_c; - } - - // transformed_view - template - static constexpr auto apply(experimental::transformed_view_t view) { - return hana::is_empty(view.sequence_); - } - - // joined_view - template - static constexpr auto apply(experimental::joined_view_t view) { - return hana::and_(hana::is_empty(view.sequence1_), - hana::is_empty(view.sequence2_)); - } - - // single_view - template - static constexpr auto apply(experimental::single_view_t) { - return hana::false_c; - } - - // empty_view - static constexpr auto apply(experimental::empty_view_t) { - return hana::true_c; - } -}; - -template <> -struct drop_front_impl { - template - static constexpr auto apply(View view, N const&) { - constexpr auto n = N::value; - constexpr auto Length = decltype(hana::length(view))::value; - return experimental::sliced(view, hana::range_c); - } -}; - -////////////////////////////////////////////////////////////////////////// -// Functor -////////////////////////////////////////////////////////////////////////// -template <> -struct transform_impl { - template - static constexpr auto - apply(experimental::transformed_view_t view, G&& g) { - return experimental::transformed(view.sequence_, - hana::compose(static_cast(g), view.f_)); - } - - template - static constexpr auto apply(View view, F&& f) { - return experimental::transformed(view, static_cast(f)); - } -}; - -////////////////////////////////////////////////////////////////////////// -// Applicative -////////////////////////////////////////////////////////////////////////// -template <> -struct lift_impl { - template - static constexpr auto apply(T&& t) { - return experimental::single_view(static_cast(t)); - } -}; - -template <> -struct ap_impl { - template - static constexpr auto apply(F&& f, X&& x) { - // TODO: Implement cleverly; we most likely need a cartesian_product - // view or something like that. - return hana::ap(hana::to_tuple(f), hana::to_tuple(x)); - } -}; - -////////////////////////////////////////////////////////////////////////// -// Monad -////////////////////////////////////////////////////////////////////////// -template <> -struct flatten_impl { - template - static constexpr auto apply(View view) { - // TODO: Implement a flattened_view instead - return hana::fold_left(view, experimental::empty_view(), - experimental::joined); - } -}; - -////////////////////////////////////////////////////////////////////////// -// MonadPlus -////////////////////////////////////////////////////////////////////////// -template <> -struct concat_impl { - template - static constexpr auto apply(View1 view1, View2 view2) { - return experimental::joined(view1, view2); - } -}; - -template <> -struct empty_impl { - static constexpr auto apply() { - return experimental::empty_view(); - } -}; - -////////////////////////////////////////////////////////////////////////// -// Comparable -////////////////////////////////////////////////////////////////////////// -template <> -struct equal_impl { - template - static constexpr auto apply(View1 v1, View2 v2) { - // TODO: Use a lexicographical comparison algorithm. - return hana::equal(hana::to_tuple(v1), hana::to_tuple(v2)); - } -}; - -template -struct equal_impl::value>> { - template - static constexpr auto apply(View1 v1, Seq const& s) { - // TODO: Use a lexicographical comparison algorithm. - return hana::equal(hana::to_tuple(v1), hana::to_tuple(s)); - } -}; - -template -struct equal_impl::value>> { - template - static constexpr auto apply(Seq const& s, View2 v2) { - // TODO: Use a lexicographical comparison algorithm. - return hana::equal(hana::to_tuple(s), hana::to_tuple(v2)); - } -}; - -////////////////////////////////////////////////////////////////////////// -// Orderable -////////////////////////////////////////////////////////////////////////// -template <> -struct less_impl { - template - static constexpr auto apply(View1 v1, View2 v2) { - return hana::lexicographical_compare(v1, v2); - } -}; - -template -struct less_impl::value>> { - template - static constexpr auto apply(View1 v1, Seq const& s) { - return hana::lexicographical_compare(v1, s); - } -}; - -template -struct less_impl::value>> { - template - static constexpr auto apply(Seq const& s, View2 v2) { - return hana::lexicographical_compare(s, v2); - } -}; - -BOOST_HANA_NAMESPACE_END - -#endif // !BOOST_HANA_EXPERIMENTAL_VIEW_HPP diff --git a/include/boost/hana/fwd/view.hpp b/include/boost/hana/fwd/view.hpp new file mode 100644 index 0000000000..8b09d8d933 --- /dev/null +++ b/include/boost/hana/fwd/view.hpp @@ -0,0 +1,143 @@ +/*! +@file +Forward declares `boost::hana::view`. + +@copyright Louis Dionne 2013-2016 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#ifndef BOOST_HANA_FWD_VIEW_HPP +#define BOOST_HANA_FWD_VIEW_HPP + +#include +#include + +#include + + +BOOST_HANA_NAMESPACE_BEGIN + //! @ingroup group-datatypes + //! Lazy view over an existing object. + //! + //! It is sometimes desirable to manipulate an object as-if some algorithm + //! had been applied on it, but without eagerly applying the algorithm on + //! the original object. This can be done by employing a view, which allows + //! creating a modified _image_ of the object. This works by having views + //! implement the interface required by many concepts in a lazy way, + //! deferring the actual computation to some key places in the interface. + //! For example, for a view over a sequence, the computation of most + //! algorithms will be deferred to the time when an element of the view + //! is accessed. + //! + //! Views have the following advantages: + //! - No temporary container created between algorithms + //! - Lazy, so only the minimum amount of computation is done + //! + //! They also have the following disadvantages: + //! - Reference semantics open the door to dangling references and other + //! lifetime bugs; be careful when using views + //! - Fetching subobjects of a view multiple times can cause some + //! computations to be done multiple times. For example, accessing + //! the first member of a `hana::transform`ed view twice will cause + //! the transforming function to be applied twice on the fetched element. + //! This is not a problem of views per se, but of naive lazy evaluation + //! in general. + //! + //! + //! Modeled concepts + //! ---------------- + //! In theory, it ought to be possible to create general views of objects + //! that model almost arbitrary concepts. However, in the current version + //! of the library, only views over `Sequence`s are supported. When a view + //! is created over a `Sequence`, the following models are provided for the + //! resulting view: + //! - `Foldable` + //! - `Iterable` + //! - `Functor` + //! - `Applicative` + //! - `Monad` + //! - `MonadPlus` + //! - `Comparable` + //! - `Orderable` + //! + //! Example + //! ------- + //! @include example/view/view.cpp +#ifdef BOOST_HANA_DOXYGEN_INVOKED + template + struct view { + //! Copy-construct a view from another view, such that both views + //! now refer to the same underlying object. + constexpr view(view const& other) = default; + +#if 0 //! @todo Implement these operators + //! Equivalent to `hana::chain`. + template + friend constexpr auto operator|(view, F); + + //! Equivalent to `hana::equal` + template + friend constexpr auto operator==(X&& x, Y&& y); + + //! Equivalent to `hana::not_equal` + template + friend constexpr auto operator!=(X&& x, Y&& y); + + //! Equivalent to `hana::less` + template + friend constexpr auto operator<(X&& x, Y&& y); + + //! Equivalent to `hana::greater` + template + friend constexpr auto operator>(X&& x, Y&& y); + + //! Equivalent to `hana::less_equal` + template + friend constexpr auto operator<=(X&& x, Y&& y); + + //! Equivalent to `hana::greater_equal` + template + friend constexpr auto operator>=(X&& x, Y&& y); + + //! Equivalent to `hana::at` + template + constexpr decltype(auto) operator[](N&& n); +#endif + }; +#else + namespace experimental { template struct identity_view_t; } + template + using view = experimental::identity_view_t; +#endif + + //! Tag representing `hana::view`s. + //! @related view + struct view_tag { }; + + +#ifdef BOOST_HANA_DOXYGEN_INVOKED + //! Function object for creating a `view`. + //! @relates hana::view + //! + //! Given an object `xs`, `make` returns a new view over that + //! object. The created view only refers to the original object, and no + //! copy is made. The lifetime of the referred-to object must span the + //! entire lifetime of the view, otherwise the view is dangling and the + //! behavior is undefined. + //! + //! Example + //! ------- + //! @include example/view/make.cpp + template <> + constexpr auto make = [](auto& xs) { + return view{xs}; + }; +#endif + + //! Alias to `make`; provided for convenience. + //! @relates hana::view + constexpr auto make_view = make; +BOOST_HANA_NAMESPACE_END + +#endif // !BOOST_HANA_FWD_VIEW_HPP diff --git a/include/boost/hana/view.hpp b/include/boost/hana/view.hpp new file mode 100644 index 0000000000..6296b6b25b --- /dev/null +++ b/include/boost/hana/view.hpp @@ -0,0 +1,739 @@ +/*! +@file +Defines `boost::hana::view`. + +@copyright Louis Dionne 2013-2016 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#ifndef BOOST_HANA_VIEW_HPP +#define BOOST_HANA_VIEW_HPP + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +BOOST_HANA_NAMESPACE_BEGIN + namespace detail { + template + struct is_view { + static constexpr bool value = false; + }; + + template + using view_storage = typename std::conditional< + detail::is_view::value, Sequence, Sequence& + >::type; + + ////////////////////////////////////////////////////////////////////// + // cartesian_product_element_view + ////////////////////////////////////////////////////////////////////// + template + struct cartesian_product_element_view_t { + detail::view_storage sequences_; + using hana_tag = view_tag; + }; + + template + struct is_view> { + static constexpr bool value = true; + }; + + ////////////////////////////////////////////////////////////////////// + // cartesian_product_view + ////////////////////////////////////////////////////////////////////// + template + struct cartesian_product_view_t { + detail::view_storage sequences_; + using hana_tag = view_tag; + }; + + struct make_cartesian_product_view_t { + template + constexpr cartesian_product_view_t operator()(Sequences& s) const { + return {s}; + } + }; + + constexpr make_cartesian_product_view_t cartesian_product_view{}; + + template + struct is_view> { + static constexpr bool value = true; + }; + + ////////////////////////////////////////////////////////////////////// + // sliced_view + ////////////////////////////////////////////////////////////////////// + template + struct sliced_view_t { + detail::view_storage sequence_; + using hana_tag = view_tag; + }; + + template + constexpr auto sliced(Sequence& sequence, Indices const& indices) { + return hana::unpack(indices, [&](auto ...i) { + return sliced_view_t{sequence}; + }); + } + + template + struct is_view> { + static constexpr bool value = true; + }; + + ////////////////////////////////////////////////////////////////////// + // transformed_view + ////////////////////////////////////////////////////////////////////// + template + struct transformed_view_t { + detail::view_storage sequence_; + F f_; + using hana_tag = view_tag; + }; + + template + constexpr transformed_view_t::type> + transformed(Sequence& sequence, F&& f) { + return {sequence, static_cast(f)}; + } + + template + struct is_view> { + static constexpr bool value = true; + }; + + ////////////////////////////////////////////////////////////////////// + // joined_view + ////////////////////////////////////////////////////////////////////// + template + struct joined_view_t { + detail::view_storage sequence1_; + detail::view_storage sequence2_; + using hana_tag = view_tag; + }; + + struct make_joined_view_t { + template + constexpr joined_view_t + operator()(Sequence1& s1, Sequence2& s2) const { + return {s1, s2}; + } + }; + constexpr make_joined_view_t joined{}; + + template + struct is_view> { + static constexpr bool value = true; + }; + + ////////////////////////////////////////////////////////////////////// + // flattened_view + ////////////////////////////////////////////////////////////////////// + template + struct flattened_view_t { + detail::view_storage sequences_; + using hana_tag = view_tag; + }; + + struct make_flattened_view_t { + template + constexpr flattened_view_t operator()(Sequences& s) const { + return {s}; + } + }; + constexpr make_flattened_view_t flattened{}; + + template + struct is_view> { + static constexpr bool value = true; + }; + + ////////////////////////////////////////////////////////////////////// + // single_view + ////////////////////////////////////////////////////////////////////// + template + struct single_view_t { + detail::view_storage value_; + using hana_tag = view_tag; + }; + + template + constexpr single_view_t single_view(T& t) + { return {t}; } + + template + struct is_view> { + static constexpr bool value = true; + }; + + ////////////////////////////////////////////////////////////////////// + // empty_view + ////////////////////////////////////////////////////////////////////// + struct empty_view_t { + using hana_tag = view_tag; + }; + + constexpr empty_view_t empty_view() { + return {}; + } + + template <> + struct is_view { + static constexpr bool value = true; + }; + + ////////////////////////////////////////////////////////////////////// + // identity_view + ////////////////////////////////////////////////////////////////////// + template + struct identity_view_t { + detail::view_storage sequence_; + using hana_tag = view_tag; + }; + + template + constexpr identity_view_t identity_view(Xs& xs) { + return {xs}; + } + + template + struct is_view> { + static constexpr bool value = true; + }; + } // end namespace detail + + template <> + struct make_impl { + template + static constexpr detail::identity_view_t apply(Xs& xs) + { return {xs}; } + }; + + ////////////////////////////////////////////////////////////////////////// + // Foldable + ////////////////////////////////////////////////////////////////////////// + template <> + struct unpack_impl { + // cartesian_product_element_view + template + static constexpr decltype(auto) + apply(detail::cartesian_product_element_view_t view, F const& f) { + using Indices = decltype(detail::make_cartesian_product_indices(view.sequences_)); + return hana::unpack(view.sequences_, + detail::make_cartesian_product_element_t{f}); + } + + // cartesian_product_view + template + static constexpr decltype(auto) + unpack_cartesian_product(View view, F&& f, std::index_sequence) { + return static_cast(f)( + detail::cartesian_product_element_view_t{ + view.sequences_ + }...); + } + + template + static constexpr decltype(auto) + apply(detail::cartesian_product_view_t view, F&& f) { + using Indices = decltype(detail::make_cartesian_product_indices(view.sequences_)); + return unpack_cartesian_product(view, static_cast(f), + std::make_index_sequence{}); + } + + // sliced_view + template + static constexpr decltype(auto) + apply(detail::sliced_view_t view, F&& f) { + (void)view; // Remove spurious unused variable warning with GCC + return static_cast(f)(hana::at_c(view.sequence_)...); + } + + // transformed_view + template + static constexpr decltype(auto) + apply(detail::transformed_view_t view, G&& g) { + return hana::unpack(view.sequence_, hana::on(static_cast(g), view.f_)); + } + + // joined_view + template + static constexpr decltype(auto) + unpack_joined(View view, F&& f, std::index_sequence, + std::index_sequence) + { + (void)view; // Remove spurious unused variable warning with GCC + return static_cast(f)(hana::at_c(view.sequence1_)..., + hana::at_c(view.sequence2_)...); + } + + template + static constexpr decltype(auto) + apply(detail::joined_view_t view, F&& f) { + constexpr auto N1 = decltype(hana::length(view.sequence1_))::value; + constexpr auto N2 = decltype(hana::length(view.sequence2_))::value; + return unpack_joined(view, static_cast(f), + std::make_index_sequence{}, + std::make_index_sequence{}); + } + + // flattened_view + template + static constexpr decltype(auto) + apply(detail::flattened_view_t view, F&& f) { + return detail::unpack_flatten(view.sequences_, static_cast(f)); + } + + // single_view + template + static constexpr decltype(auto) apply(detail::single_view_t view, F&& f) { + return static_cast(f)(view.value_); + } + + // empty_view + template + static constexpr decltype(auto) apply(detail::empty_view_t, F&& f) { + return static_cast(f)(); + } + + // identity_view + template + static constexpr decltype(auto) apply(detail::identity_view_t view, F&& f) { + return hana::unpack(view.sequence_, static_cast(f)); + } + }; + + ////////////////////////////////////////////////////////////////////////// + // Iterable + ////////////////////////////////////////////////////////////////////////// + template <> + struct at_impl { + // cartesian_product_element_view + template + static constexpr decltype(auto) + apply(detail::cartesian_product_element_view_t view, N const&) { + using Indices = decltype(detail::make_cartesian_product_indices(view.sequences_)); + return hana::at_c( + hana::at_c(view.sequences_)); + } + + // cartesian_product_view + template + static constexpr decltype(auto) + apply(detail::cartesian_product_view_t view, N const&) { + return detail::cartesian_product_element_view_t{view.sequences_}; + } + + // sliced_view + template + static constexpr decltype(auto) + apply(detail::sliced_view_t view, N const&) { + constexpr std::size_t indices[] = {i...}; + constexpr std::size_t n = indices[N::value]; + return hana::at_c(view.sequence_); + } + + // transformed_view + template + static constexpr decltype(auto) + apply(detail::transformed_view_t view, N const& n) { + return view.f_(hana::at(view.sequence_, n)); + } + + // joined_view + template + static constexpr decltype(auto) at_joined_view(View view, N const&, hana::true_) { + return hana::at_c(view.sequence1_); + } + + template + static constexpr decltype(auto) at_joined_view(View view, N const&, hana::false_) { + return hana::at_c(view.sequence2_); + } + + template + static constexpr decltype(auto) + apply(detail::joined_view_t view, N const& n) { + constexpr auto Left = decltype(hana::length(view.sequence1_))::value; + return at_joined_view(view, n, hana::bool_c<(N::value < Left)>); + } + + // flattened_view + struct index_pair { std::size_t sequence; std::size_t index; }; + template + struct flat_indexer { + constexpr index_pair operator()() const { + constexpr std::size_t sizes[] = {Lenghts...}; + std::size_t current = 0; + std::size_t n = N; + while (n >= sizes[current]) { + n -= sizes[current]; + ++current; + } + return index_pair{current, n}; + } + }; + template + struct make_flat_indexer { + template + constexpr auto operator()(S const& ...s) const + -> flat_indexer + { return {}; } + }; + + template + static constexpr decltype(auto) + apply(detail::flattened_view_t view, N const&) { + using Indexer = decltype(hana::unpack(view.sequences_, + make_flat_indexer{})); + constexpr auto indices = Indexer{}(); + return hana::at_c( + hana::at_c(view.sequences_) + ); + } + + // single_view + template + static constexpr decltype(auto) apply(detail::single_view_t view, N const&) { + static_assert(N::value == 0, + "trying to fetch an out-of-bounds element in a hana::single_view"); + return view.value_; + } + + // empty_view + template + static constexpr decltype(auto) apply(detail::empty_view_t, N const&) = delete; + + // identity_view + template + static constexpr decltype(auto) apply(detail::identity_view_t view, N const& n) { + return hana::at(view.sequence_, n); + } + }; + + template <> + struct length_impl { + // cartesian_product_view_element + template + static constexpr auto apply(detail::cartesian_product_element_view_t view) { + return hana::length(view.sequences_); + } + + // cartesian_product_view + template + static constexpr auto apply(detail::cartesian_product_view_t view) { + using Indices = decltype(detail::make_cartesian_product_indices(view.sequences_)); + return hana::size_c; + } + + // sliced_view + template + static constexpr auto + apply(detail::sliced_view_t) { + return hana::size_c; + } + + // transformed_view + template + static constexpr auto apply(detail::transformed_view_t view) { + return hana::length(view.sequence_); + } + + // joined_view + template + static constexpr auto apply(detail::joined_view_t view) { + return hana::size_c< + decltype(hana::length(view.sequence1_))::value + + decltype(hana::length(view.sequence2_))::value + >; + } + + // flattened_view + struct sum_lengths { + template + constexpr auto operator()(S const& ...s) const { + constexpr std::size_t lengths[sizeof...(S)] = {decltype(hana::length(s))::value...}; + constexpr std::size_t sum = detail::accumulate(lengths, lengths+sizeof...(S), 0); + return hana::size_t{}; + } + }; + + template + static constexpr auto apply(detail::flattened_view_t view) { + return hana::unpack(view.sequences_, sum_lengths{}); + } + + // single_view + template + static constexpr auto apply(detail::single_view_t const&) { + return hana::size_c<1>; + } + + // empty_view + static constexpr auto apply(detail::empty_view_t) { + return hana::size_c<0>; + } + + // identity_view + template + static constexpr auto apply(detail::identity_view_t const& view) { + return hana::length(view.sequence_); + } + }; + + template <> + struct is_empty_impl { + // cartesian_product_view_element + template + static constexpr auto apply(detail::cartesian_product_element_view_t view) { + using Indices = decltype(detail::make_cartesian_product_indices(view.sequences_)); + return hana::bool_c; + } + + // cartesian_product_view + template + static constexpr auto apply(detail::cartesian_product_view_t view) { + using Indices = decltype(detail::make_cartesian_product_indices(view.sequences_)); + return hana::bool_c; + } + + // sliced_view + template + static constexpr auto + apply(detail::sliced_view_t) { + return hana::bool_c; + } + + // transformed_view + template + static constexpr auto apply(detail::transformed_view_t view) { + return hana::is_empty(view.sequence_); + } + + // joined_view + template + static constexpr auto apply(detail::joined_view_t view) { + return hana::and_(hana::is_empty(view.sequence1_), + hana::is_empty(view.sequence2_)); + } + + // flattened_view + template + static constexpr auto apply(detail::flattened_view_t view) { + return hana::all_of(view.sequences_, hana::is_empty); + } + + // single_view + template + static constexpr auto apply(detail::single_view_t const&) { + return hana::false_c; + } + + // empty_view + static constexpr auto apply(detail::empty_view_t) { + return hana::true_c; + } + + // identity_view + template + static constexpr auto apply(detail::identity_view_t const& view) { + return hana::is_empty(view.sequence_); + } + }; + + template <> + struct drop_front_impl { + template + static constexpr auto apply(View view, N const&) { + constexpr auto n = N::value; + constexpr auto Length = decltype(hana::length(view))::value; + constexpr auto begin = (n > Length ? Length : n); + return detail::sliced(view, hana::range_c); + } + }; + + ////////////////////////////////////////////////////////////////////////// + // Functor + ////////////////////////////////////////////////////////////////////////// + template <> + struct transform_impl { + template + static constexpr auto + apply(detail::transformed_view_t view, G&& g) { + return detail::transformed(view.sequence_, + hana::compose(static_cast(g), view.f_)); + } + + template + static constexpr auto apply(detail::identity_view_t view, F&& f) { + return detail::transformed(view.sequence_, static_cast(f)); + } + + template + static constexpr auto apply(View view, F&& f) { + return detail::transformed(view, static_cast(f)); + } + }; + + ////////////////////////////////////////////////////////////////////////// + // Applicative + ////////////////////////////////////////////////////////////////////////// + template <> + struct lift_impl { + template + static constexpr detail::single_view_t::type> apply(T&& t) { + return {static_cast(t)}; + } + }; + + template <> + struct ap_impl { + template + static constexpr auto apply(F f, X x) { + // Note: `f` and `x` must both be view, so we're not returning + // dangling references below. + auto fs = detail::single_view(f); + auto xs = detail::single_view(x); + auto joined = detail::joined(fs, xs); + auto product = detail::cartesian_product_view(joined); + return detail::transformed(product, hana::fuse(hana::apply)); + } + }; + + ////////////////////////////////////////////////////////////////////////// + // Monad + ////////////////////////////////////////////////////////////////////////// + template <> + struct flatten_impl { + template + static constexpr auto apply(detail::identity_view_t view) { + return detail::flattened(view.sequence_); + } + + template + static constexpr auto apply(View view) { + return detail::flattened(view); + } + }; + + ////////////////////////////////////////////////////////////////////////// + // MonadPlus + ////////////////////////////////////////////////////////////////////////// + template <> + struct concat_impl { + template + static constexpr auto apply(View1 view1, View2 view2) { + return detail::joined(view1, view2); + } + }; + + template <> + struct empty_impl { + static constexpr auto apply() { + return detail::empty_view_t{}; + } + }; + + ////////////////////////////////////////////////////////////////////////// + // Comparable + ////////////////////////////////////////////////////////////////////////// + template + inline constexpr auto equal_helper(Xs const& xs, Ys const& ys) { + constexpr std::size_t xs_size = decltype(hana::length(xs))::value; + constexpr std::size_t ys_size = decltype(hana::length(ys))::value; + detail::compare_finite_sequences comp{xs, ys}; + return comp.template apply<0>(hana::bool_{}, + hana::bool_{}); + } + + template <> + struct equal_impl { + template + static constexpr auto apply(View1&& v1, View2&& v2) { + return equal_helper(static_cast(v1), static_cast(v2)); + } + }; + + template + struct equal_impl::value>> { + template + static constexpr auto apply(View1&& v1, View2&& v2) { + return equal_helper(static_cast(v1), static_cast(v2)); + } + }; + + template + struct equal_impl::value>> { + template + static constexpr auto apply(View1&& v1, View2&& v2) { + return equal_helper(static_cast(v1), static_cast(v2)); + } + }; + + ////////////////////////////////////////////////////////////////////////// + // Orderable + ////////////////////////////////////////////////////////////////////////// + template <> + struct less_impl { + template + static constexpr auto apply(View1 v1, View2 v2) { + return hana::lexicographical_compare(v1, v2); + } + }; + + template + struct less_impl::value>> { + template + static constexpr auto apply(View1 v1, Seq const& s) { + return hana::lexicographical_compare(v1, s); + } + }; + + template + struct less_impl::value>> { + template + static constexpr auto apply(Seq const& s, View2 v2) { + return hana::lexicographical_compare(s, v2); + } + }; +BOOST_HANA_NAMESPACE_END + +#endif // !BOOST_HANA_VIEW_HPP diff --git a/test/_include/auto/ap.hpp b/test/_include/auto/ap.hpp index 7fe0fc5bea..de22dbf883 100644 --- a/test/_include/auto/ap.hpp +++ b/test/_include/auto/ap.hpp @@ -71,6 +71,23 @@ TestCase test_ap{[]{ MAKE_TUPLE(f(ct_eq<0>{}), f(ct_eq<1>{}), f(ct_eq<2>{}), g(ct_eq<0>{}), g(ct_eq<1>{}), g(ct_eq<2>{})) )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(MAKE_TUPLE(f, g), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + MAKE_TUPLE(ct_eq<10>{}, ct_eq<11>{})), + MAKE_TUPLE( + f(ct_eq<0>{}, ct_eq<10>{}), + f(ct_eq<0>{}, ct_eq<11>{}), + f(ct_eq<1>{}, ct_eq<10>{}), + f(ct_eq<1>{}, ct_eq<11>{}), + + g(ct_eq<0>{}, ct_eq<10>{}), + g(ct_eq<0>{}, ct_eq<11>{}), + g(ct_eq<1>{}, ct_eq<10>{}), + g(ct_eq<1>{}, ct_eq<11>{}) + ) + )); }}; #endif // !BOOST_HANA_TEST_AUTO_AP_HPP diff --git a/test/view/auto/_specs.hpp b/test/view/auto/_specs.hpp new file mode 100644 index 0000000000..f1e2fb174e --- /dev/null +++ b/test/view/auto/_specs.hpp @@ -0,0 +1,29 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_VIEW_AUTO_SPECS_HPP +#define BOOST_HANA_TEST_VIEW_AUTO_SPECS_HPP + +#include +#include + +#include +#include + + +// If we want to use the automatic testing, we need to allocate the containers +// over which we create views, otherwise the lifetime won't work. +template +auto MAKE_TUPLE(T&& ...t) { + using Tuple = boost::hana::tuple::type...>; + static std::vector> pool; + pool.push_back(std::make_unique(std::forward(t)...)); + return boost::hana::make_view(*pool.back().get()); +} + +#define MAKE_TUPLE_NO_CONSTEXPR +#define TUPLE_TYPE(...) ::boost::hana::view<::boost::hana::tuple<__VA_ARGS__>> +#define TUPLE_TAG ::boost::hana::view_tag + +#endif // !BOOST_HANA_TEST_VIEW_AUTO_SPECS_HPP diff --git a/test/view/auto/ap.cpp b/test/view/auto/ap.cpp new file mode 100644 index 0000000000..064be84f52 --- /dev/null +++ b/test/view/auto/ap.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/test/view/auto/at.cpp b/test/view/auto/at.cpp new file mode 100644 index 0000000000..b53bd0829a --- /dev/null +++ b/test/view/auto/at.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/test/view/auto/drop_front.cpp b/test/view/auto/drop_front.cpp new file mode 100644 index 0000000000..a56e3d05c4 --- /dev/null +++ b/test/view/auto/drop_front.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/test/view/auto/drop_while.cpp b/test/view/auto/drop_while.cpp new file mode 100644 index 0000000000..7cea101524 --- /dev/null +++ b/test/view/auto/drop_while.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/test/view/auto/for_each.cpp b/test/view/auto/for_each.cpp new file mode 100644 index 0000000000..9d8735b1fd --- /dev/null +++ b/test/view/auto/for_each.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/test/view/auto/is_empty.cpp b/test/view/auto/is_empty.cpp new file mode 100644 index 0000000000..bba91c9bb1 --- /dev/null +++ b/test/view/auto/is_empty.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/test/view/auto/lexicographical_compare.cpp b/test/view/auto/lexicographical_compare.cpp new file mode 100644 index 0000000000..55e58112c7 --- /dev/null +++ b/test/view/auto/lexicographical_compare.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/test/view/auto/transform.cpp b/test/view/auto/transform.cpp new file mode 100644 index 0000000000..9806cb881e --- /dev/null +++ b/test/view/auto/transform.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "_specs.hpp" +#include + +int main() { } diff --git a/test/view/cartesian_product/at.cpp b/test/view/cartesian_product/at.cpp new file mode 100644 index 0000000000..4e050d60e4 --- /dev/null +++ b/test/view/cartesian_product/at.cpp @@ -0,0 +1,88 @@ +// Copyright Louis Dionne 2013-2016 +// Copyright Jason Rice 2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + + { + const auto storage = container( + container(ct_eq<0>{}) + ); + + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<0>), + container(ct_eq<0>{}) + )); + } + + { + const auto storage = container( + container(ct_eq<0>{}), + container(ct_eq<0>{}) + ); + + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<0>), + container(ct_eq<0>{}, ct_eq<0>{}) + )); + } + + { + const auto storage = container( + container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + container(ct_eq<3>{}, ct_eq<4>{}) + ); + + auto view = hana::detail::cartesian_product_view(storage); + + auto expected = container( + container(ct_eq<0>{}, ct_eq<3>{}), + container(ct_eq<0>{}, ct_eq<4>{}), + container(ct_eq<1>{}, ct_eq<3>{}), + container(ct_eq<1>{}, ct_eq<4>{}), + container(ct_eq<2>{}, ct_eq<3>{}), + container(ct_eq<2>{}, ct_eq<4>{}) + ); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<0>), + hana::at(expected, hana::size_c<0>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<1>), + hana::at(expected, hana::size_c<1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<2>), + hana::at(expected, hana::size_c<2>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<3>), + hana::at(expected, hana::size_c<3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<4>), + hana::at(expected, hana::size_c<4>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<5>), + hana::at(expected, hana::size_c<5>) + )); + } +} diff --git a/test/view/cartesian_product/is_empty.cpp b/test/view/cartesian_product/is_empty.cpp new file mode 100644 index 0000000000..aab59855e6 --- /dev/null +++ b/test/view/cartesian_product/is_empty.cpp @@ -0,0 +1,71 @@ +// Copyright Louis Dionne 2013-2016 +// Copyright Jason Rice 2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + + { + auto storage = container(container()); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(view)); + } + + { + auto storage = container(container(ct_eq<0>{}), container()); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(view)); + } + + { + auto storage = container( + container(ct_eq<0>{}), + container(ct_eq<1>{}), + container(ct_eq<2>{}, ct_eq<3>{}), + container(), + container(ct_eq<4>{}) + ); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(view)); + } + + { + auto storage = container(container(ct_eq<0>{})); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(view))); + } + + { + auto storage = container( + container(ct_eq<0>{}), + container(ct_eq<1>{}), + container(ct_eq<2>{}, ct_eq<3>{}), + container(ct_eq<4>{}) + ); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(view))); + } + + { + auto storage = container( + container(ct_eq<0>{}), + container(ct_eq<1>{}), + container(ct_eq<2>{}, ct_eq<3>{}), + container(ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}) + ); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(view))); + } +} diff --git a/test/view/cartesian_product/length.cpp b/test/view/cartesian_product/length.cpp new file mode 100644 index 0000000000..86a88cab71 --- /dev/null +++ b/test/view/cartesian_product/length.cpp @@ -0,0 +1,86 @@ +// Copyright Louis Dionne 2013-2016 +// Copyright Jason Rice 2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + + { + auto storage = container(container()); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(view), + hana::size_c<0> + )); + } + + { + auto storage = container(container(ct_eq<0>{}), container()); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(view)); + } + + { + auto storage = container( + container(ct_eq<0>{}), + container(ct_eq<1>{}), + container(ct_eq<2>{}, ct_eq<3>{}), + container(), + container(ct_eq<4>{}) + ); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(view), + hana::size_c<0> + )); + } + + { + auto storage = container(container(ct_eq<0>{})); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(view), + hana::size_c<1> + )); + } + + { + auto storage = container( + container(ct_eq<0>{}), + container(ct_eq<1>{}), + container(ct_eq<2>{}, ct_eq<3>{}), + container(ct_eq<4>{}) + ); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(view), + hana::size_c<2> + )); + } + + { + auto storage = container( + container(ct_eq<0>{}), + container(ct_eq<1>{}), + container(ct_eq<2>{}, ct_eq<3>{}), + container(ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}) + ); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(view), + hana::size_c<6> + )); + } +} diff --git a/test/view/cartesian_product/modifications.cpp b/test/view/cartesian_product/modifications.cpp new file mode 100644 index 0000000000..b2ec005066 --- /dev/null +++ b/test/view/cartesian_product/modifications.cpp @@ -0,0 +1,39 @@ +// Copyright Louis Dionne 2013-2016 +// Copyright Jason Rice 2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + auto container = ::seq; + + auto storage = container(container(0), + container(1), + container(2, 3), + container(4, 5, 6)); + + auto view = hana::detail::cartesian_product_view(storage); + + hana::at_c<0>(hana::at_c<0>(view)) = 90; + hana::at_c<1>(hana::at_c<0>(view)) = 91; + hana::at_c<2>(hana::at_c<0>(view)) = 92; + hana::at_c<3>(hana::at_c<0>(view)) = 94; + hana::at_c<3>(hana::at_c<1>(view)) = 95; + hana::at_c<2>(hana::at_c<5>(view)) = 93; + hana::at_c<3>(hana::at_c<5>(view)) = 96; + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + storage, + container(container(90), + container(91), + container(92, 93), + container(94, 95, 96)) + )); +} diff --git a/test/view/cartesian_product/unpack.cpp b/test/view/cartesian_product/unpack.cpp new file mode 100644 index 0000000000..4519afd3a2 --- /dev/null +++ b/test/view/cartesian_product/unpack.cpp @@ -0,0 +1,111 @@ +// Copyright Louis Dionne 2013-2016 +// Copyright Jason Rice 2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + auto make_container = [](auto ...x) { + return ::seq(x...); + }; + + { + auto storage = container(); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(view)); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(hana::unpack(view, make_container))); + } + + { + auto storage = container(container()); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(view)); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(hana::unpack(view, make_container))); + } + + { + auto storage = container(container(), container(), container()); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(view)); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(hana::unpack(view, make_container))); + } + + { + auto storage = container(container(ct_eq<0>{}), container()); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(view)); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(hana::unpack(view, make_container))); + } + + { + auto storage = container( + container(ct_eq<0>{}), + container(ct_eq<1>{}), + container(ct_eq<2>{}, ct_eq<3>{}), + container(), + container(ct_eq<4>{}) + ); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(view, make_container), + container() + )); + } + + { + auto storage = container(container(ct_eq<0>{})); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(view, make_container), + container(container(ct_eq<0>{})) + )); + } + + { + auto storage = container( + container(ct_eq<0>{}), + container(ct_eq<1>{}), + container(ct_eq<2>{}, ct_eq<3>{}), + container(ct_eq<4>{}) + ); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(view, make_container), + container( + container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<4>{}), + container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<3>{}, ct_eq<4>{}) + ) + )); + } + + { + auto storage = container( + container(ct_eq<0>{}), + container(ct_eq<1>{}), + container(ct_eq<2>{}, ct_eq<3>{}), + container(ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}) + ); + auto view = hana::detail::cartesian_product_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(view, make_container), + container( + container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<4>{}), + container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<5>{}), + container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<6>{}), + container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<3>{}, ct_eq<4>{}), + container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<3>{}, ct_eq<5>{}), + container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<3>{}, ct_eq<6>{}) + ) + )); + } +} diff --git a/test/experimental/view/empty/is_empty.cpp b/test/view/empty/is_empty.cpp similarity index 78% rename from test/experimental/view/empty/is_empty.cpp rename to test/view/empty/is_empty.cpp index c3efb7e255..3c82fd1362 100644 --- a/test/experimental/view/empty/is_empty.cpp +++ b/test/view/empty/is_empty.cpp @@ -3,14 +3,14 @@ // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) #include -#include #include +#include namespace hana = boost::hana; int main() { { - auto empty = hana::experimental::empty_view(); + auto empty = hana::detail::empty_view(); BOOST_HANA_CONSTANT_CHECK(hana::is_empty(empty)); } } diff --git a/test/experimental/view/empty/length.cpp b/test/view/empty/length.cpp similarity index 83% rename from test/experimental/view/empty/length.cpp rename to test/view/empty/length.cpp index 3325ec9c76..09bb9ab0d1 100644 --- a/test/experimental/view/empty/length.cpp +++ b/test/view/empty/length.cpp @@ -4,15 +4,15 @@ #include #include -#include #include #include +#include namespace hana = boost::hana; int main() { { - auto empty = hana::experimental::empty_view(); + auto empty = hana::detail::empty_view(); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(empty), hana::size_c<0> diff --git a/test/experimental/view/empty/unpack.cpp b/test/view/empty/unpack.cpp similarity index 83% rename from test/experimental/view/empty/unpack.cpp rename to test/view/empty/unpack.cpp index 6942e35af1..7e9342eeed 100644 --- a/test/experimental/view/empty/unpack.cpp +++ b/test/view/empty/unpack.cpp @@ -4,8 +4,8 @@ #include #include -#include #include +#include #include namespace hana = boost::hana; @@ -15,7 +15,7 @@ int main() { auto f = hana::test::_injection<0>{}; { - auto empty = hana::experimental::empty_view(); + auto empty = hana::detail::empty_view(); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(empty, f), f() diff --git a/test/view/flattened/at.cpp b/test/view/flattened/at.cpp new file mode 100644 index 0000000000..6189833073 --- /dev/null +++ b/test/view/flattened/at.cpp @@ -0,0 +1,168 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + + { + auto storage1 = container(ct_eq<0>{}); + auto storage2 = container(); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<0>), + ct_eq<0>{} + )); + }{ + auto storage1 = container(); + auto storage2 = container(ct_eq<0>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<0>), + ct_eq<0>{} + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<1>), + ct_eq<1>{} + )); + }{ + auto storage1 = container(ct_eq<0>{}); + auto storage2 = container(ct_eq<1>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<1>), + ct_eq<1>{} + )); + }{ + auto storage1 = container(); + auto storage2 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<1>), + ct_eq<1>{} + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(ct_eq<2>{}, ct_eq<3>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<1>), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<2>), + ct_eq<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<3>), + ct_eq<3>{} + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(ct_eq<2>{}, ct_eq<3>{}); + auto storage3 = container(ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}); + auto storage = container(storage1, storage2, storage3); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<1>), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<2>), + ct_eq<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<3>), + ct_eq<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<4>), + ct_eq<4>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<5>), + ct_eq<5>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<6>), + ct_eq<6>{} + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(); + auto storage3 = container(ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}); + auto storage4 = container(); + auto storage = container(storage1, storage2, storage3, storage4); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<1>), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<2>), + ct_eq<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<3>), + ct_eq<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(flat, hana::size_c<4>), + ct_eq<4>{} + )); + } +} diff --git a/test/view/flattened/is_empty.cpp b/test/view/flattened/is_empty.cpp new file mode 100644 index 0000000000..3263c8f498 --- /dev/null +++ b/test/view/flattened/is_empty.cpp @@ -0,0 +1,99 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + + { + auto storage1 = container(); + auto storage = container(storage1); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(flat)); + }{ + auto storage1 = container(); + auto storage2 = container(); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(flat)); + }{ + auto storage1 = container(); + auto storage2 = container(); + auto storage3 = container(); + auto storage = container(storage1, storage2, storage3); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(flat)); + } + + { + auto storage1 = container(ct_eq<0>{}); + auto storage2 = container(); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(flat))); + }{ + auto storage1 = container(); + auto storage2 = container(ct_eq<0>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(flat))); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(flat))); + }{ + auto storage1 = container(ct_eq<0>{}); + auto storage2 = container(ct_eq<1>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(flat))); + }{ + auto storage1 = container(); + auto storage2 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(flat))); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(ct_eq<2>{}, ct_eq<3>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(flat))); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(ct_eq<2>{}, ct_eq<3>{}); + auto storage3 = container(ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}); + auto storage = container(storage1, storage2, storage3); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(flat))); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(); + auto storage3 = container(ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}); + auto storage4 = container(); + auto storage = container(storage1, storage2, storage3, storage4); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(flat))); + } +} diff --git a/test/view/flattened/length.cpp b/test/view/flattened/length.cpp new file mode 100644 index 0000000000..a0ca41f82e --- /dev/null +++ b/test/view/flattened/length.cpp @@ -0,0 +1,133 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + + { + auto storage1 = container(); + auto storage = container(storage1); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(flat), + hana::size_c<0> + )); + }{ + auto storage1 = container(); + auto storage2 = container(); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(flat), + hana::size_c<0> + )); + }{ + auto storage1 = container(); + auto storage2 = container(); + auto storage3 = container(); + auto storage = container(storage1, storage2, storage3); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(flat), + hana::size_c<0> + )); + } + + { + auto storage1 = container(ct_eq<0>{}); + auto storage2 = container(); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(flat), + hana::size_c<1> + )); + }{ + auto storage1 = container(); + auto storage2 = container(ct_eq<0>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(flat), + hana::size_c<1> + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(flat), + hana::size_c<2> + )); + }{ + auto storage1 = container(ct_eq<0>{}); + auto storage2 = container(ct_eq<1>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(flat), + hana::size_c<2> + )); + }{ + auto storage1 = container(); + auto storage2 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(flat), + hana::size_c<2> + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(ct_eq<2>{}, ct_eq<3>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(flat), + hana::size_c<4> + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(ct_eq<2>{}, ct_eq<3>{}); + auto storage3 = container(ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}); + auto storage = container(storage1, storage2, storage3); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(flat), + hana::size_c<7> + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(); + auto storage3 = container(ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}); + auto storage4 = container(); + auto storage = container(storage1, storage2, storage3, storage4); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(flat), + hana::size_c<5> + )); + } +} diff --git a/test/view/flattened/modifications.cpp b/test/view/flattened/modifications.cpp new file mode 100644 index 0000000000..c3f2a30370 --- /dev/null +++ b/test/view/flattened/modifications.cpp @@ -0,0 +1,44 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + auto container = ::seq; + + auto storage = container(container(0, 1, 2), + container(3, 4), + container(), + container(5)); + auto view = hana::detail::flattened(storage); + hana::at_c<0>(view) = 90; + hana::at_c<1>(view) = 91; + hana::at_c<2>(view) = 92; + hana::at_c<3>(view) = 93; + hana::at_c<4>(view) = 94; + hana::at_c<5>(view) = 95; + + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(view) == 90); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(view) == 91); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(view) == 92); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<3>(view) == 93); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<4>(view) == 94); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<5>(view) == 95); + + auto& storage1 = hana::at_c<0>(storage); + auto& storage2 = hana::at_c<1>(storage); + auto& storage4 = hana::at_c<3>(storage); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage1) == 90); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage1) == 91); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(storage1) == 92); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage2) == 93); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage2) == 94); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage4) == 95); +} diff --git a/test/view/flattened/unpack.cpp b/test/view/flattened/unpack.cpp new file mode 100644 index 0000000000..6c27501ab1 --- /dev/null +++ b/test/view/flattened/unpack.cpp @@ -0,0 +1,123 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + constexpr auto f = hana::test::_injection<0>{}; + + { + auto storage1 = container(); + auto storage = container(storage1); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(flat, f), + f() + )); + }{ + auto storage1 = container(); + auto storage2 = container(); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(flat, f), + f() + )); + } + + { + auto storage1 = container(ct_eq<0>{}); + auto storage2 = container(); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(flat, f), + f(ct_eq<0>{}) + )); + }{ + auto storage1 = container(); + auto storage2 = container(ct_eq<0>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(flat, f), + f(ct_eq<0>{}) + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(flat, f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + }{ + auto storage1 = container(ct_eq<0>{}); + auto storage2 = container(ct_eq<1>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(flat, f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + }{ + auto storage1 = container(); + auto storage2 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(flat, f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(ct_eq<2>{}, ct_eq<3>{}); + auto storage = container(storage1, storage2); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(flat, f), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(ct_eq<2>{}, ct_eq<3>{}); + auto storage3 = container(ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}); + auto storage = container(storage1, storage2, storage3); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(flat, f), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}) + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(); + auto storage3 = container(ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}); + auto storage4 = container(); + auto storage = container(storage1, storage2, storage3, storage4); + auto flat = hana::detail::flattened(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(flat, f), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + )); + } +} diff --git a/test/view/identity/at.cpp b/test/view/identity/at.cpp new file mode 100644 index 0000000000..cb47b3469f --- /dev/null +++ b/test/view/identity/at.cpp @@ -0,0 +1,80 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + + { + auto storage = container(ct_eq<0>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<0>), + ct_eq<0>{} + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<1>), + ct_eq<1>{} + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<1>), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<2>), + ct_eq<2>{} + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<1>), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<2>), + ct_eq<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(view, hana::size_c<3>), + ct_eq<3>{} + )); + } +} diff --git a/test/view/identity/is_empty.cpp b/test/view/identity/is_empty.cpp new file mode 100644 index 0000000000..d2fa460fad --- /dev/null +++ b/test/view/identity/is_empty.cpp @@ -0,0 +1,43 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + + { + auto storage = container(); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(view)); + } + + { + auto storage = container(ct_eq<0>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(view))); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(view))); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(view))); + } +} diff --git a/test/view/identity/length.cpp b/test/view/identity/length.cpp new file mode 100644 index 0000000000..f89f034e32 --- /dev/null +++ b/test/view/identity/length.cpp @@ -0,0 +1,65 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + + { + auto storage = container(); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(view), + hana::size_c<0> + )); + } + + { + auto storage = container(ct_eq<0>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(view), + hana::size_c<1> + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(view), + hana::size_c<2> + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(view), + hana::size_c<3> + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(view), + hana::size_c<4> + )); + } +} diff --git a/test/view/identity/modifications.cpp b/test/view/identity/modifications.cpp new file mode 100644 index 0000000000..f9a99b248d --- /dev/null +++ b/test/view/identity/modifications.cpp @@ -0,0 +1,29 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + auto container = ::seq; + + auto storage = container(0, 1, 2); + auto view = hana::detail::identity_view(storage); + hana::at_c<0>(view) = 90; + hana::at_c<1>(view) = 91; + hana::at_c<2>(view) = 92; + + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(view) == 90); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(view) == 91); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(view) == 92); + + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage) == 90); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage) == 91); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(storage) == 92); +} diff --git a/test/view/identity/unpack.cpp b/test/view/identity/unpack.cpp new file mode 100644 index 0000000000..a2d3de97eb --- /dev/null +++ b/test/view/identity/unpack.cpp @@ -0,0 +1,65 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + constexpr auto f = hana::test::_injection<0>{}; + + { + auto storage = container(); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(view, f), + f() + )); + } + + { + auto storage = container(ct_eq<0>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(view, f), + f(ct_eq<0>{}) + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(view, f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(view, f), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}); + auto view = hana::detail::identity_view(storage); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(view, f), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + } +} diff --git a/test/experimental/view/joined/at.cpp b/test/view/joined/at.cpp similarity index 85% rename from test/experimental/view/joined/at.cpp rename to test/view/joined/at.cpp index ec4e00170c..ff282e7644 100644 --- a/test/experimental/view/joined/at.cpp +++ b/test/view/joined/at.cpp @@ -5,8 +5,8 @@ #include #include #include -#include #include +#include #include #include @@ -20,7 +20,7 @@ int main() { { auto storage1 = container(ct_eq<0>{}); auto storage2 = container(); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at(joined, hana::size_c<0>), ct_eq<0>{} @@ -28,7 +28,7 @@ int main() { }{ auto storage1 = container(); auto storage2 = container(ct_eq<0>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at(joined, hana::size_c<0>), ct_eq<0>{} @@ -38,7 +38,7 @@ int main() { { auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); auto storage2 = container(); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at(joined, hana::size_c<0>), ct_eq<0>{} @@ -50,7 +50,7 @@ int main() { }{ auto storage1 = container(ct_eq<0>{}); auto storage2 = container(ct_eq<1>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at(joined, hana::size_c<0>), ct_eq<0>{} @@ -62,7 +62,7 @@ int main() { }{ auto storage1 = container(); auto storage2 = container(ct_eq<0>{}, ct_eq<1>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at(joined, hana::size_c<0>), ct_eq<0>{} @@ -76,7 +76,7 @@ int main() { { auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); auto storage2 = container(ct_eq<2>{}, ct_eq<3>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at(joined, hana::size_c<0>), ct_eq<0>{} diff --git a/test/experimental/view/joined/is_empty.cpp b/test/view/joined/is_empty.cpp similarity index 77% rename from test/experimental/view/joined/is_empty.cpp rename to test/view/joined/is_empty.cpp index b8a5e0ae5b..5e0f035a8d 100644 --- a/test/experimental/view/joined/is_empty.cpp +++ b/test/view/joined/is_empty.cpp @@ -3,9 +3,9 @@ // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) #include -#include #include #include +#include #include namespace hana = boost::hana; @@ -19,25 +19,25 @@ int main() { { auto storage1 = container(); auto storage2 = container(); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::is_empty(joined)); } { auto storage1 = container(undefined<0>{}); auto storage2 = container(); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(joined))); } { auto storage1 = container(undefined<0>{}); auto storage2 = container(undefined<1>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(joined))); } { auto storage1 = container(); auto storage2 = container(undefined<0>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(joined))); } } diff --git a/test/experimental/view/joined/length.cpp b/test/view/joined/length.cpp similarity index 79% rename from test/experimental/view/joined/length.cpp rename to test/view/joined/length.cpp index 457d5f626d..ea0874ef32 100644 --- a/test/experimental/view/joined/length.cpp +++ b/test/view/joined/length.cpp @@ -4,9 +4,9 @@ #include #include -#include #include #include +#include #include namespace hana = boost::hana; @@ -20,7 +20,7 @@ int main() { { auto storage1 = container(); auto storage2 = container(); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(joined), hana::size_c<0> @@ -30,7 +30,7 @@ int main() { { auto storage1 = container(undefined<0>{}); auto storage2 = container(); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(joined), hana::size_c<1> @@ -40,7 +40,7 @@ int main() { { auto storage1 = container(); auto storage2 = container(undefined<0>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(joined), hana::size_c<1> @@ -50,7 +50,7 @@ int main() { { auto storage1 = container(undefined<0>{}); auto storage2 = container(undefined<1>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(joined), hana::size_c<2> @@ -60,7 +60,7 @@ int main() { { auto storage1 = container(undefined<0>{}); auto storage2 = container(undefined<1>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(joined), hana::size_c<2> @@ -70,7 +70,7 @@ int main() { { auto storage1 = container(undefined<0>{}, undefined<1>{}); auto storage2 = container(undefined<2>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(joined), hana::size_c<3> @@ -80,7 +80,7 @@ int main() { { auto storage1 = container(undefined<0>{}, undefined<1>{}, undefined<2>{}); auto storage2 = container(undefined<3>{}, undefined<4>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(joined), hana::size_c<5> diff --git a/test/view/joined/modifications.cpp b/test/view/joined/modifications.cpp new file mode 100644 index 0000000000..61fea1fd1c --- /dev/null +++ b/test/view/joined/modifications.cpp @@ -0,0 +1,36 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + auto container = ::seq; + + auto storage1 = container(0, 1, 2); + auto storage2 = container(3, 4); + auto view = hana::detail::joined(storage1, storage2); + hana::at_c<0>(view) = 90; + hana::at_c<1>(view) = 91; + hana::at_c<2>(view) = 92; + hana::at_c<3>(view) = 93; + hana::at_c<4>(view) = 94; + + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(view) == 90); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(view) == 91); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(view) == 92); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<3>(view) == 93); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<4>(view) == 94); + + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage1) == 90); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage1) == 91); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(storage1) == 92); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage2) == 93); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage2) == 94); +} diff --git a/test/experimental/view/joined/unpack.cpp b/test/view/joined/unpack.cpp similarity index 79% rename from test/experimental/view/joined/unpack.cpp rename to test/view/joined/unpack.cpp index cf0896d8ff..3d9b87c87d 100644 --- a/test/experimental/view/joined/unpack.cpp +++ b/test/view/joined/unpack.cpp @@ -4,8 +4,8 @@ #include #include -#include #include +#include #include #include @@ -20,7 +20,7 @@ int main() { { auto storage1 = container(); auto storage2 = container(); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(joined, f), f() @@ -30,7 +30,7 @@ int main() { { auto storage1 = container(ct_eq<0>{}); auto storage2 = container(); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(joined, f), f(ct_eq<0>{}) @@ -38,7 +38,7 @@ int main() { }{ auto storage1 = container(); auto storage2 = container(ct_eq<0>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(joined, f), f(ct_eq<0>{}) @@ -46,7 +46,7 @@ int main() { }{ auto storage1 = container(ct_eq<0>{}); auto storage2 = container(ct_eq<1>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(joined, f), f(ct_eq<0>{}, ct_eq<1>{}) @@ -56,7 +56,7 @@ int main() { { auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); auto storage2 = container(); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(joined, f), f(ct_eq<0>{}, ct_eq<1>{}) @@ -64,7 +64,7 @@ int main() { }{ auto storage1 = container(); auto storage2 = container(ct_eq<0>{}, ct_eq<1>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(joined, f), f(ct_eq<0>{}, ct_eq<1>{}) @@ -72,7 +72,7 @@ int main() { }{ auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); auto storage2 = container(ct_eq<2>{}, ct_eq<3>{}); - auto joined = hana::experimental::joined(storage1, storage2); + auto joined = hana::detail::joined(storage1, storage2); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(joined, f), f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) diff --git a/test/view/nested.cpp b/test/view/nested.cpp new file mode 100644 index 0000000000..1cb55497a9 --- /dev/null +++ b/test/view/nested.cpp @@ -0,0 +1,111 @@ +// Copyright Jason Rice 2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define CHECK_EQUAL(X, Y) BOOST_HANA_RUNTIME_CHECK(X == Y) + +namespace hana = boost::hana; + +namespace { + template + struct in_place { + int value; + + in_place() + : value(i) + { } + + bool operator==(in_place const& x) const { + return &x == this && value == x.value; + } + }; + + template + struct injected_in_place + { + in_place const& value; + + bool operator==(injected_in_place const& x) const { + return value == x.value; + } + }; + + template + inline injected_in_place make_injected_in_place(in_place const& x) { + return {x}; + } +} + + +int main() { + { + // identity, identity, joined, sliced + using Xs = hana::basic_tuple, in_place<1>, in_place<3>>; + using Ys = hana::basic_tuple, in_place<5>>; + auto xs = std::unique_ptr(new Xs{}); + auto ys = std::unique_ptr(new Ys{}); + auto xs_view = ([&xs] { + auto temp = hana::make_view(*xs); + return hana::make_view(temp); + })(); + auto ys_view = hana::make_view(*ys); + + auto result = hana::drop_front(hana::concat(xs_view, ys_view)); + + CHECK_EQUAL(hana::at_c<0>(result), hana::at_c<1>(*xs)); + CHECK_EQUAL(hana::at_c<1>(result), hana::at_c<2>(*xs)); + CHECK_EQUAL(hana::at_c<2>(result), hana::at_c<0>(*ys)); + CHECK_EQUAL(hana::at_c<3>(result), hana::at_c<1>(*ys)); + }{ + // identity, flattened, transformed + auto f = [](auto const& x) { return make_injected_in_place(x); }; + + using Xs = hana::basic_tuple< + hana::basic_tuple, in_place<1>, in_place<3>>, + hana::basic_tuple, in_place<5>> + >; + + auto xs = std::unique_ptr(new Xs{}); + auto xs_view = hana::make_view(*xs); + + auto result = hana::transform(hana::flatten(xs_view), f); + + CHECK_EQUAL(hana::at_c<0>(result), f(hana::at_c<0>(hana::at_c<0>(*xs)))); + CHECK_EQUAL(hana::at_c<1>(result), f(hana::at_c<1>(hana::at_c<0>(*xs)))); + CHECK_EQUAL(hana::at_c<2>(result), f(hana::at_c<2>(hana::at_c<0>(*xs)))); + CHECK_EQUAL(hana::at_c<3>(result), f(hana::at_c<0>(hana::at_c<1>(*xs)))); + CHECK_EQUAL(hana::at_c<4>(result), f(hana::at_c<1>(hana::at_c<1>(*xs)))); + }{ + // identity, joined, empty + using Xs = hana::basic_tuple, in_place<1>, in_place<3>>; + using Ys = hana::basic_tuple, in_place<5>>; + auto xs = std::unique_ptr(new Xs{}); + auto ys = std::unique_ptr(new Ys{}); + auto xs_view = hana::make_view(*xs); + auto ys_view = hana::make_view(*ys); + + auto result = hana::concat(xs_view, hana::concat(hana::empty(), ys_view)); + + BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::length(result), hana::size_c<5>)); + + CHECK_EQUAL(hana::at_c<0>(result), hana::at_c<0>(*xs)); + CHECK_EQUAL(hana::at_c<1>(result), hana::at_c<1>(*xs)); + CHECK_EQUAL(hana::at_c<2>(result), hana::at_c<2>(*xs)); + CHECK_EQUAL(hana::at_c<3>(result), hana::at_c<0>(*ys)); + CHECK_EQUAL(hana::at_c<4>(result), hana::at_c<1>(*ys)); + } +} diff --git a/test/experimental/view/single/at.cpp b/test/view/single/at.cpp similarity index 79% rename from test/experimental/view/single/at.cpp rename to test/view/single/at.cpp index 20d1490be0..eb6c849771 100644 --- a/test/experimental/view/single/at.cpp +++ b/test/view/single/at.cpp @@ -5,8 +5,8 @@ #include #include #include -#include #include +#include #include namespace hana = boost::hana; @@ -15,10 +15,11 @@ using hana::test::ct_eq; int main() { { - auto single = hana::experimental::single_view(ct_eq<0>{}); + ct_eq<0> x{}; + auto single = hana::detail::single_view(x); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at(single, hana::size_c<0>), - ct_eq<0>{} + x )); } } diff --git a/test/experimental/view/single/is_empty.cpp b/test/view/single/is_empty.cpp similarity index 79% rename from test/experimental/view/single/is_empty.cpp rename to test/view/single/is_empty.cpp index 4422b3e401..ce73d06dca 100644 --- a/test/experimental/view/single/is_empty.cpp +++ b/test/view/single/is_empty.cpp @@ -3,9 +3,9 @@ // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) #include -#include #include #include +#include namespace hana = boost::hana; @@ -13,7 +13,8 @@ template struct undefined { }; int main() { { - auto single = hana::experimental::single_view(undefined<0>{}); + undefined<0> x{}; + auto single = hana::detail::single_view(x); BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(single))); } } diff --git a/test/experimental/view/single/length.cpp b/test/view/single/length.cpp similarity index 82% rename from test/experimental/view/single/length.cpp rename to test/view/single/length.cpp index 8153f81996..9888bb1c37 100644 --- a/test/experimental/view/single/length.cpp +++ b/test/view/single/length.cpp @@ -4,9 +4,9 @@ #include #include -#include #include #include +#include namespace hana = boost::hana; @@ -14,7 +14,8 @@ template struct undefined { }; int main() { { - auto single = hana::experimental::single_view(undefined<0>{}); + undefined<0> x{}; + auto single = hana::detail::single_view(x); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(single), hana::size_c<1> diff --git a/test/view/single/modifications.cpp b/test/view/single/modifications.cpp new file mode 100644 index 0000000000..4fd55fdb4f --- /dev/null +++ b/test/view/single/modifications.cpp @@ -0,0 +1,18 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + int x = 3; + auto view = hana::detail::single_view(x); + hana::at_c<0>(view) = 93; + + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(view) == 93); + BOOST_HANA_RUNTIME_CHECK(x == 93); +} diff --git a/test/experimental/view/single/unpack.cpp b/test/view/single/unpack.cpp similarity index 79% rename from test/experimental/view/single/unpack.cpp rename to test/view/single/unpack.cpp index ca2398412f..93c0f4d734 100644 --- a/test/experimental/view/single/unpack.cpp +++ b/test/view/single/unpack.cpp @@ -4,8 +4,8 @@ #include #include -#include #include +#include #include namespace hana = boost::hana; @@ -16,10 +16,11 @@ int main() { auto f = hana::test::_injection<0>{}; { - auto single = hana::experimental::single_view(ct_eq<0>{}); + ct_eq<0> x{}; + auto single = hana::detail::single_view(x); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(single, f), - f(ct_eq<0>{}) + f(x) )); } } diff --git a/test/experimental/view/sliced/at.cpp b/test/view/sliced/at.cpp similarity index 79% rename from test/experimental/view/sliced/at.cpp rename to test/view/sliced/at.cpp index c8d201a59d..96471aec88 100644 --- a/test/experimental/view/sliced/at.cpp +++ b/test/view/sliced/at.cpp @@ -5,9 +5,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -20,7 +20,7 @@ int main() { { auto storage = container(ct_eq<0>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at(sliced, hana::size_c<0>), ct_eq<0>{} @@ -29,21 +29,21 @@ int main() { { auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at(sliced, hana::size_c<0>), ct_eq<0>{} )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at(sliced, hana::size_c<0>), ct_eq<1>{} )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at(sliced, hana::size_c<0>), ct_eq<0>{} @@ -54,7 +54,7 @@ int main() { )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at(sliced, hana::size_c<0>), ct_eq<1>{} @@ -65,7 +65,7 @@ int main() { )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at(sliced, hana::size_c<0>), ct_eq<0>{} @@ -78,7 +78,7 @@ int main() { { auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at(sliced, hana::size_c<0>), ct_eq<1>{} diff --git a/test/experimental/view/sliced/is_empty.cpp b/test/view/sliced/is_empty.cpp similarity index 69% rename from test/experimental/view/sliced/is_empty.cpp rename to test/view/sliced/is_empty.cpp index d6f0d267e5..a38fcea9e7 100644 --- a/test/experimental/view/sliced/is_empty.cpp +++ b/test/view/sliced/is_empty.cpp @@ -3,10 +3,10 @@ // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) #include -#include #include #include #include +#include #include namespace hana = boost::hana; @@ -19,31 +19,31 @@ int main() { { auto storage = container(); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::is_empty(sliced)); }{ auto storage = container(undefined<0>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::is_empty(sliced)); }{ auto storage = container(undefined<0>{}, undefined<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::is_empty(sliced)); } { auto storage = container(undefined<0>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(sliced))); }{ auto storage = container(undefined<0>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(sliced))); } { auto storage = container(undefined<0>{}, undefined<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(sliced))); } } diff --git a/test/experimental/view/sliced/length.cpp b/test/view/sliced/length.cpp similarity index 75% rename from test/experimental/view/sliced/length.cpp rename to test/view/sliced/length.cpp index c975960aa3..516202fd39 100644 --- a/test/experimental/view/sliced/length.cpp +++ b/test/view/sliced/length.cpp @@ -4,10 +4,10 @@ #include #include -#include #include #include #include +#include #include namespace hana = boost::hana; @@ -20,7 +20,7 @@ int main() { { auto storage = container(); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(sliced), hana::size_c<0> @@ -29,14 +29,14 @@ int main() { { auto storage = container(undefined<0>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(sliced), hana::size_c<1> )); }{ auto storage = container(undefined<0>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(sliced), hana::size_c<0> @@ -45,21 +45,21 @@ int main() { { auto storage = container(undefined<0>{}, undefined<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(sliced), hana::size_c<1> )); }{ auto storage = container(undefined<0>{}, undefined<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(sliced), hana::size_c<2> )); }{ auto storage = container(undefined<0>{}, undefined<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(sliced), hana::size_c<2> diff --git a/test/view/sliced/modifications.cpp b/test/view/sliced/modifications.cpp new file mode 100644 index 0000000000..880525935a --- /dev/null +++ b/test/view/sliced/modifications.cpp @@ -0,0 +1,62 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include + +#include +namespace hana = boost::hana; + + +int main() { + auto container = ::seq; + + { + auto storage = container(0, 1, 2); + auto view = hana::detail::sliced(storage, hana::range_c); + hana::at_c<0>(view) = 90; + hana::at_c<1>(view) = 91; + hana::at_c<2>(view) = 92; + + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(view) == 90); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(view) == 91); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(view) == 92); + + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage) == 90); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage) == 91); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(storage) == 92); + } + + { + auto storage = container(0, 1, 2); + auto view = hana::detail::sliced(storage, hana::range_c); + hana::at_c<0>(view) = 90; + hana::at_c<1>(view) = 91; + + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(view) == 90); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(view) == 91); + + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage) == 90); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage) == 91); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(storage) == 02); + } + + { + auto storage = container(7, 1, 2); + auto view = hana::detail::sliced(storage, hana::range_c); + hana::at_c<0>(view) = 91; + hana::at_c<1>(view) = 92; + + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(view) == 91); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(view) == 92); + + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage) == 07); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage) == 91); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(storage) == 92); + } +} diff --git a/test/experimental/view/sliced/unpack.cpp b/test/view/sliced/unpack.cpp similarity index 72% rename from test/experimental/view/sliced/unpack.cpp rename to test/view/sliced/unpack.cpp index 710e8246ef..e86979322a 100644 --- a/test/experimental/view/sliced/unpack.cpp +++ b/test/view/sliced/unpack.cpp @@ -4,9 +4,9 @@ #include #include -#include #include #include +#include #include #include @@ -20,7 +20,7 @@ int main() { { auto storage = container(); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f() @@ -29,14 +29,14 @@ int main() { { auto storage = container(ct_eq<0>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f() )); }{ auto storage = container(ct_eq<0>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f(ct_eq<0>{}) @@ -45,35 +45,35 @@ int main() { { auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f() )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f(ct_eq<0>{}) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f(ct_eq<0>{}, ct_eq<1>{}) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f(ct_eq<1>{}) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f(ct_eq<1>{}, ct_eq<0>{}) @@ -82,42 +82,42 @@ int main() { { auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f() )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f(ct_eq<0>{}) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f(ct_eq<1>{}) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f(ct_eq<2>{}) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f(ct_eq<0>{}, ct_eq<2>{}) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f(ct_eq<1>{}, ct_eq<1>{}) @@ -126,7 +126,7 @@ int main() { { auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}); - auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + auto sliced = hana::detail::sliced(storage, hana::tuple_c); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(sliced, f), f(ct_eq<3>{}, ct_eq<1>{}, ct_eq<0>{}, ct_eq<2>{}, ct_eq<2>{}) diff --git a/test/experimental/view/transformed/ap.cpp b/test/view/transformed/ap.cpp similarity index 70% rename from test/experimental/view/transformed/ap.cpp rename to test/view/transformed/ap.cpp index b04d54fe57..3756bbc9e2 100644 --- a/test/experimental/view/transformed/ap.cpp +++ b/test/view/transformed/ap.cpp @@ -5,8 +5,8 @@ #include #include #include -#include #include +#include #include #include @@ -22,8 +22,8 @@ int main() { { auto storage = container(); auto functions = container(); - auto transformed_storage = hana::experimental::transformed(storage, f); - auto transformed_functions = hana::experimental::transformed(functions, hana::id); + auto transformed_storage = hana::detail::transformed(storage, f); + auto transformed_functions = hana::detail::transformed(functions, hana::id); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::ap(transformed_functions, transformed_storage), container() @@ -31,8 +31,8 @@ int main() { }{ auto storage = container(ct_eq<0>{}); auto functions = container(); - auto transformed_storage = hana::experimental::transformed(storage, f); - auto transformed_functions = hana::experimental::transformed(functions, hana::id); + auto transformed_storage = hana::detail::transformed(storage, f); + auto transformed_functions = hana::detail::transformed(functions, hana::id); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::ap(transformed_functions, transformed_storage), container() @@ -40,8 +40,8 @@ int main() { }{ auto storage = container(); auto functions = container(ct_eq<0>{}); - auto transformed_storage = hana::experimental::transformed(storage, f); - auto transformed_functions = hana::experimental::transformed(functions, hana::id); + auto transformed_storage = hana::detail::transformed(storage, f); + auto transformed_functions = hana::detail::transformed(functions, hana::id); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::ap(transformed_functions, transformed_storage), container() @@ -51,8 +51,8 @@ int main() { { auto storage = container(ct_eq<0>{}); auto functions = container(_injection<0>{}); - auto transformed_storage = hana::experimental::transformed(storage, f); - auto transformed_functions = hana::experimental::transformed(functions, hana::id); + auto transformed_storage = hana::detail::transformed(storage, f); + auto transformed_functions = hana::detail::transformed(functions, hana::id); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::ap(transformed_functions, transformed_storage), container(_injection<0>{}(f(ct_eq<0>{}))) @@ -60,8 +60,8 @@ int main() { }{ auto storage = container(ct_eq<0>{}); auto functions = container(_injection<0>{}, _injection<1>{}); - auto transformed_storage = hana::experimental::transformed(storage, f); - auto transformed_functions = hana::experimental::transformed(functions, hana::id); + auto transformed_storage = hana::detail::transformed(storage, f); + auto transformed_functions = hana::detail::transformed(functions, hana::id); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::ap(transformed_functions, transformed_storage), container(_injection<0>{}(f(ct_eq<0>{})), @@ -70,8 +70,8 @@ int main() { }{ auto storage = container(ct_eq<0>{}); auto functions = container(_injection<0>{}, _injection<1>{}, _injection<2>{}); - auto transformed_storage = hana::experimental::transformed(storage, f); - auto transformed_functions = hana::experimental::transformed(functions, hana::id); + auto transformed_storage = hana::detail::transformed(storage, f); + auto transformed_functions = hana::detail::transformed(functions, hana::id); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::ap(transformed_functions, transformed_storage), container(_injection<0>{}(f(ct_eq<0>{})), @@ -83,8 +83,8 @@ int main() { { auto storage = container(ct_eq<0>{}, ct_eq<1>{}); auto functions = container(_injection<0>{}); - auto transformed_storage = hana::experimental::transformed(storage, f); - auto transformed_functions = hana::experimental::transformed(functions, hana::id); + auto transformed_storage = hana::detail::transformed(storage, f); + auto transformed_functions = hana::detail::transformed(functions, hana::id); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::ap(transformed_functions, transformed_storage), container(_injection<0>{}(f(ct_eq<0>{})), @@ -93,8 +93,8 @@ int main() { }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); auto functions = container(_injection<0>{}); - auto transformed_storage = hana::experimental::transformed(storage, f); - auto transformed_functions = hana::experimental::transformed(functions, hana::id); + auto transformed_storage = hana::detail::transformed(storage, f); + auto transformed_functions = hana::detail::transformed(functions, hana::id); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::ap(transformed_functions, transformed_storage), container(_injection<0>{}(f(ct_eq<0>{})), @@ -106,8 +106,8 @@ int main() { { auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); auto functions = container(_injection<0>{}, _injection<1>{}); - auto transformed_storage = hana::experimental::transformed(storage, f); - auto transformed_functions = hana::experimental::transformed(functions, hana::id); + auto transformed_storage = hana::detail::transformed(storage, f); + auto transformed_functions = hana::detail::transformed(functions, hana::id); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::ap(transformed_functions, transformed_storage), container(_injection<0>{}(f(ct_eq<0>{})), diff --git a/test/experimental/view/transformed/at.cpp b/test/view/transformed/at.cpp similarity index 85% rename from test/experimental/view/transformed/at.cpp rename to test/view/transformed/at.cpp index 2379f28788..2fef737ebe 100644 --- a/test/experimental/view/transformed/at.cpp +++ b/test/view/transformed/at.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include @@ -19,14 +19,14 @@ int main() { { auto storage = container(ct_eq<0>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at_c<0>(transformed), f(ct_eq<0>{}) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at_c<0>(transformed), f(ct_eq<0>{}) @@ -37,7 +37,7 @@ int main() { )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at_c<0>(transformed), f(ct_eq<0>{}) @@ -52,7 +52,7 @@ int main() { )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::at_c<0>(transformed), f(ct_eq<0>{}) diff --git a/test/experimental/view/transformed/drop_front.cpp b/test/view/transformed/drop_front.cpp similarity index 78% rename from test/experimental/view/transformed/drop_front.cpp rename to test/view/transformed/drop_front.cpp index 0db64fd41a..11493f36dd 100644 --- a/test/experimental/view/transformed/drop_front.cpp +++ b/test/view/transformed/drop_front.cpp @@ -5,8 +5,8 @@ #include #include #include -#include #include +#include #include #include @@ -20,7 +20,7 @@ int main() { { auto storage = container(); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::drop_front(transformed, hana::size_c<0>), container() @@ -29,14 +29,14 @@ int main() { { auto storage = container(ct_eq<0>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::drop_front(transformed, hana::size_c<0>), container(f(ct_eq<0>{})) )); }{ auto storage = container(ct_eq<0>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::drop_front(transformed, hana::size_c<1>), container() @@ -45,21 +45,21 @@ int main() { { auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::drop_front(transformed, hana::size_c<0>), container(f(ct_eq<0>{}), f(ct_eq<1>{})) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::drop_front(transformed, hana::size_c<1>), container(f(ct_eq<1>{})) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::drop_front(transformed, hana::size_c<2>), container() @@ -68,28 +68,28 @@ int main() { { auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::drop_front(transformed, hana::size_c<0>), container(f(ct_eq<0>{}), f(ct_eq<1>{}), f(ct_eq<2>{})) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::drop_front(transformed, hana::size_c<1>), container(f(ct_eq<1>{}), f(ct_eq<2>{})) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::drop_front(transformed, hana::size_c<2>), container(f(ct_eq<2>{})) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::drop_front(transformed, hana::size_c<3>), container() diff --git a/test/experimental/view/transformed/equal.cpp b/test/view/transformed/equal.cpp similarity index 91% rename from test/experimental/view/transformed/equal.cpp rename to test/view/transformed/equal.cpp index f7723c0cfd..38dad152dd 100644 --- a/test/experimental/view/transformed/equal.cpp +++ b/test/view/transformed/equal.cpp @@ -4,9 +4,9 @@ #include #include -#include #include #include +#include #include namespace hana = boost::hana; @@ -16,7 +16,7 @@ int main() { auto container = ::seq; auto xs = container(0, '1', 2.2); - auto tr = hana::experimental::transformed(xs, hana::id); + auto tr = hana::detail::transformed(xs, hana::id); BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( tr, diff --git a/test/experimental/view/transformed/is_empty.cpp b/test/view/transformed/is_empty.cpp similarity index 75% rename from test/experimental/view/transformed/is_empty.cpp rename to test/view/transformed/is_empty.cpp index aafec8ab50..becbe07be2 100644 --- a/test/experimental/view/transformed/is_empty.cpp +++ b/test/view/transformed/is_empty.cpp @@ -3,9 +3,9 @@ // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) #include -#include #include #include +#include #include namespace hana = boost::hana; @@ -18,19 +18,19 @@ int main() { { auto xs = container(); - auto tr = hana::experimental::transformed(xs, undefined{}); + auto tr = hana::detail::transformed(xs, undefined{}); BOOST_HANA_CONSTANT_CHECK(hana::is_empty(tr)); } { auto xs = container(undefined{}); - auto tr = hana::experimental::transformed(xs, undefined{}); + auto tr = hana::detail::transformed(xs, undefined{}); BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(tr))); } { auto xs = container(undefined{}, undefined{}); - auto tr = hana::experimental::transformed(xs, undefined{}); + auto tr = hana::detail::transformed(xs, undefined{}); BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(tr))); } } diff --git a/test/experimental/view/transformed/laziness.cpp b/test/view/transformed/laziness.cpp similarity index 79% rename from test/experimental/view/transformed/laziness.cpp rename to test/view/transformed/laziness.cpp index c1c9fc4cac..63af0e81a4 100644 --- a/test/experimental/view/transformed/laziness.cpp +++ b/test/view/transformed/laziness.cpp @@ -2,7 +2,7 @@ // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) -#include +#include #include #include @@ -15,6 +15,6 @@ struct undefined { }; int main() { // Make sure we do not evaluate the function unless required auto storage = ::seq(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); - auto transformed = hana::experimental::transformed(storage, undefined{}); + auto transformed = hana::detail::transformed(storage, undefined{}); (void)transformed; } diff --git a/test/experimental/view/transformed/length.cpp b/test/view/transformed/length.cpp similarity index 76% rename from test/experimental/view/transformed/length.cpp rename to test/view/transformed/length.cpp index 516df7da8b..be1539ab33 100644 --- a/test/experimental/view/transformed/length.cpp +++ b/test/view/transformed/length.cpp @@ -4,9 +4,9 @@ #include #include -#include #include #include +#include #include namespace hana = boost::hana; @@ -19,28 +19,28 @@ int main() { { auto storage = container(); - auto transformed = hana::experimental::transformed(storage, undefined<99>{}); + auto transformed = hana::detail::transformed(storage, undefined<99>{}); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(transformed), hana::size_c<0> )); }{ auto storage = container(undefined<0>{}); - auto transformed = hana::experimental::transformed(storage, undefined<99>{}); + auto transformed = hana::detail::transformed(storage, undefined<99>{}); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(transformed), hana::size_c<1> )); }{ auto storage = container(undefined<0>{}, undefined<1>{}); - auto transformed = hana::experimental::transformed(storage, undefined<99>{}); + auto transformed = hana::detail::transformed(storage, undefined<99>{}); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(transformed), hana::size_c<2> )); }{ auto storage = container(undefined<0>{}, undefined<1>{}, undefined<2>{}); - auto transformed = hana::experimental::transformed(storage, undefined<99>{}); + auto transformed = hana::detail::transformed(storage, undefined<99>{}); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::length(transformed), hana::size_c<3> diff --git a/test/experimental/view/transformed/less.cpp b/test/view/transformed/less.cpp similarity index 85% rename from test/experimental/view/transformed/less.cpp rename to test/view/transformed/less.cpp index 562e0a4620..46ee7fcaed 100644 --- a/test/experimental/view/transformed/less.cpp +++ b/test/view/transformed/less.cpp @@ -3,9 +3,9 @@ // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) #include -#include #include #include +#include #include #include @@ -19,14 +19,14 @@ int main() { { auto storage = container(); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( transformed, container() ))); }{ auto storage = container(ct_ord<0>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::less( container(), transformed @@ -41,7 +41,7 @@ int main() { ))); }{ auto storage = container(ct_ord<0>{}, ct_ord<1>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::less( container(), transformed diff --git a/test/experimental/view/transformed/transform.cpp b/test/view/transformed/transform.cpp similarity index 80% rename from test/experimental/view/transformed/transform.cpp rename to test/view/transformed/transform.cpp index 6fbab67895..c38663de3a 100644 --- a/test/experimental/view/transformed/transform.cpp +++ b/test/view/transformed/transform.cpp @@ -4,8 +4,8 @@ #include #include -#include #include +#include #include #include @@ -20,35 +20,35 @@ int main() { { auto storage = container(); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::transform(transformed, g), container() )); }{ auto storage = container(ct_eq<0>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::transform(transformed, g), container(g(f(ct_eq<0>{}))) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::transform(transformed, g), container(g(f(ct_eq<0>{})), g(f(ct_eq<1>{}))) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::transform(transformed, g), container(g(f(ct_eq<0>{})), g(f(ct_eq<1>{})), g(f(ct_eq<2>{}))) )); }{ auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::transform(transformed, g), container(g(f(ct_eq<0>{})), g(f(ct_eq<1>{})), g(f(ct_eq<2>{})), g(f(ct_eq<3>{}))) diff --git a/test/experimental/view/transformed/unpack.cpp b/test/view/transformed/unpack.cpp similarity index 88% rename from test/experimental/view/transformed/unpack.cpp rename to test/view/transformed/unpack.cpp index 6ade5ed2e9..d6fde8e0f5 100644 --- a/test/experimental/view/transformed/unpack.cpp +++ b/test/view/transformed/unpack.cpp @@ -4,8 +4,8 @@ #include #include -#include #include +#include #include #include @@ -18,7 +18,7 @@ int main() { auto g = hana::test::_injection<1>{}; auto check = [=](auto ...x) { auto storage = ::seq(x...); - auto transformed = hana::experimental::transformed(storage, f); + auto transformed = hana::detail::transformed(storage, f); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::unpack(transformed, g),