diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/hana/example/map | |
parent | Initial commit. (diff) | |
download | ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/hana/example/map')
-rw-r--r-- | src/boost/libs/hana/example/map/comparable.cpp | 28 | ||||
-rw-r--r-- | src/boost/libs/hana/example/map/difference.cpp | 45 | ||||
-rw-r--r-- | src/boost/libs/hana/example/map/erase_key.cpp | 33 | ||||
-rw-r--r-- | src/boost/libs/hana/example/map/foldable.cpp | 39 | ||||
-rw-r--r-- | src/boost/libs/hana/example/map/insert.cpp | 32 | ||||
-rw-r--r-- | src/boost/libs/hana/example/map/intersection.cpp | 47 | ||||
-rw-r--r-- | src/boost/libs/hana/example/map/keys.cpp | 30 | ||||
-rw-r--r-- | src/boost/libs/hana/example/map/make.cpp | 29 | ||||
-rw-r--r-- | src/boost/libs/hana/example/map/map.cpp | 76 | ||||
-rw-r--r-- | src/boost/libs/hana/example/map/searchable.cpp | 30 | ||||
-rw-r--r-- | src/boost/libs/hana/example/map/symmetric_difference.cpp | 33 | ||||
-rw-r--r-- | src/boost/libs/hana/example/map/to.cpp | 30 | ||||
-rw-r--r-- | src/boost/libs/hana/example/map/union.cpp | 53 | ||||
-rw-r--r-- | src/boost/libs/hana/example/map/values.cpp | 29 |
14 files changed, 534 insertions, 0 deletions
diff --git a/src/boost/libs/hana/example/map/comparable.cpp b/src/boost/libs/hana/example/map/comparable.cpp new file mode 100644 index 000000000..4c3d348b0 --- /dev/null +++ b/src/boost/libs/hana/example/map/comparable.cpp @@ -0,0 +1,28 @@ +// 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) + +#include <boost/hana/assert.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/pair.hpp> +#include <boost/hana/type.hpp> + +#include <string> +namespace hana = boost::hana; +using namespace std::literals; + + +int main() { + BOOST_HANA_RUNTIME_CHECK( + hana::make_map( + hana::make_pair(hana::char_c<'a'>, "foobar"s), + hana::make_pair(hana::type_c<int&&>, nullptr) + ) + == + hana::make_map( + hana::make_pair(hana::type_c<int&&>, (void*)0), + hana::make_pair(hana::char_c<'a'>, "foobar"s) + ) + ); +} diff --git a/src/boost/libs/hana/example/map/difference.cpp b/src/boost/libs/hana/example/map/difference.cpp new file mode 100644 index 000000000..6b94b0a22 --- /dev/null +++ b/src/boost/libs/hana/example/map/difference.cpp @@ -0,0 +1,45 @@ +// 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) + +#include <boost/hana/assert.hpp> +#include <boost/hana/difference.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/string.hpp> + +#include <string> +namespace hana = boost::hana; + + +static auto m1 = hana::make_map( + hana::make_pair(BOOST_HANA_STRING("key1"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key2"), hana::type_c<std::string>) +); + +static auto m2 = hana::make_map( + hana::make_pair(BOOST_HANA_STRING("key3"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key4"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key5"), hana::type_c<std::string>) +); + +static auto m3 = hana::make_map( + hana::make_pair(BOOST_HANA_STRING("key1"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key4"), hana::type_c<int>), + hana::make_pair(BOOST_HANA_STRING("key2"), hana::type_c<long long>) +); + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::difference(m1, m2) == m1); + + BOOST_HANA_CONSTANT_CHECK(hana::difference(m1, m3) == hana::make_map()); + + BOOST_HANA_CONSTANT_CHECK(hana::difference(m3, m1) == hana::make_map( + hana::make_pair(BOOST_HANA_STRING("key4"), hana::type_c<int>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::difference(m2, m3) == hana::make_map( + hana::make_pair(BOOST_HANA_STRING("key3"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key5"), hana::type_c<std::string>) + )); +} diff --git a/src/boost/libs/hana/example/map/erase_key.cpp b/src/boost/libs/hana/example/map/erase_key.cpp new file mode 100644 index 000000000..2ba407145 --- /dev/null +++ b/src/boost/libs/hana/example/map/erase_key.cpp @@ -0,0 +1,33 @@ +// 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) + +#include <boost/hana/assert.hpp> +#include <boost/hana/erase_key.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/pair.hpp> +#include <boost/hana/string.hpp> +#include <boost/hana/type.hpp> + +#include <string> +namespace hana = boost::hana; +using namespace std::literals; + + +int main() { + auto m = hana::make_map( + hana::make_pair(hana::type_c<int>, "abcd"s), + hana::make_pair(hana::type_c<void>, 1234), + hana::make_pair(BOOST_HANA_STRING("foobar!"), hana::type_c<char>) + ); + + BOOST_HANA_RUNTIME_CHECK( + hana::erase_key(m, BOOST_HANA_STRING("foobar!")) == + hana::make_map( + hana::make_pair(hana::type_c<int>, "abcd"s), + hana::make_pair(hana::type_c<void>, 1234) + ) + ); + + BOOST_HANA_RUNTIME_CHECK(hana::erase_key(m, hana::type_c<char>) == m); +} diff --git a/src/boost/libs/hana/example/map/foldable.cpp b/src/boost/libs/hana/example/map/foldable.cpp new file mode 100644 index 000000000..1884220a3 --- /dev/null +++ b/src/boost/libs/hana/example/map/foldable.cpp @@ -0,0 +1,39 @@ +// 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) + +#include <boost/hana/assert.hpp> +#include <boost/hana/first.hpp> +#include <boost/hana/fold_left.hpp> +#include <boost/hana/insert.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/pair.hpp> +#include <boost/hana/second.hpp> +#include <boost/hana/type.hpp> +namespace hana = boost::hana; + + +int main() { + // Given a map of (key, value) pairs, returns a map of (value, key) pairs. + // This requires both the keys and the values to be compile-time Comparable. + auto invert = [](auto map) { + return hana::fold_left(map, hana::make_map(), [](auto map, auto pair) { + return hana::insert(map, hana::make_pair(hana::second(pair), hana::first(pair))); + }); + }; + + auto m = hana::make_map( + hana::make_pair(hana::type_c<int>, hana::int_c<1>), + hana::make_pair(hana::type_c<float>, hana::int_c<2>), + hana::make_pair(hana::int_c<3>, hana::type_c<void>) + ); + + BOOST_HANA_CONSTANT_CHECK(invert(m) == + hana::make_map( + hana::make_pair(hana::int_c<1>, hana::type_c<int>), + hana::make_pair(hana::int_c<2>, hana::type_c<float>), + hana::make_pair(hana::type_c<void>, hana::int_c<3>) + ) + ); +} diff --git a/src/boost/libs/hana/example/map/insert.cpp b/src/boost/libs/hana/example/map/insert.cpp new file mode 100644 index 000000000..80aff7d5f --- /dev/null +++ b/src/boost/libs/hana/example/map/insert.cpp @@ -0,0 +1,32 @@ +// 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) + +#include <boost/hana/assert.hpp> +#include <boost/hana/insert.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/pair.hpp> +#include <boost/hana/type.hpp> + +#include <string> +namespace hana = boost::hana; +using namespace std::literals; + + +int main() { + auto m = hana::make_map( + hana::make_pair(hana::type_c<int>, "abcd"s), + hana::make_pair(hana::type_c<void>, 1234) + ); + + BOOST_HANA_RUNTIME_CHECK( + hana::insert(m, hana::make_pair(hana::type_c<float>, 'x')) == + hana::make_map( + hana::make_pair(hana::type_c<int>, "abcd"s), + hana::make_pair(hana::type_c<void>, 1234), + hana::make_pair(hana::type_c<float>, 'x') + ) + ); + + BOOST_HANA_RUNTIME_CHECK(hana::insert(m, hana::make_pair(hana::type_c<void>, 'x')) == m); +} diff --git a/src/boost/libs/hana/example/map/intersection.cpp b/src/boost/libs/hana/example/map/intersection.cpp new file mode 100644 index 000000000..1be8bf0b9 --- /dev/null +++ b/src/boost/libs/hana/example/map/intersection.cpp @@ -0,0 +1,47 @@ +// 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) + +#include <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/intersection.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/string.hpp> + +#include <string> +namespace hana = boost::hana; +using namespace hana::literals; + + +static auto m1 = hana::make_map( + hana::make_pair(BOOST_HANA_STRING("key1"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key2"), hana::type_c<std::string>) +); + +static auto m2 = hana::make_map( + hana::make_pair(BOOST_HANA_STRING("key3"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key4"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key5"), hana::type_c<std::string>) +); + +BOOST_HANA_CONSTANT_CHECK(hana::intersection(m1, m2) == hana::make_map()); + +static auto m3 = hana::make_map( + hana::make_pair(hana::type_c<int>, hana::int_c<1>), + hana::make_pair(hana::type_c<bool>, hana::bool_c<true>), + hana::make_pair(hana::type_c<std::string>, BOOST_HANA_STRING("hana")), + hana::make_pair(hana::type_c<float>, hana::int_c<100>) +); + +static auto m4 = hana::make_map( + hana::make_pair(hana::type_c<char>, hana::char_c<'c'>), + hana::make_pair(hana::type_c<bool>, hana::bool_c<false>), + hana::make_pair(hana::type_c<std::string>, BOOST_HANA_STRING("boost")) +); + +BOOST_HANA_CONSTANT_CHECK(hana::intersection(m3, m4) == hana::make_map( + hana::make_pair(hana::type_c<bool>, hana::bool_c<true>), + hana::make_pair(hana::type_c<std::string>, BOOST_HANA_STRING("hana")) +)); + +int main() { } diff --git a/src/boost/libs/hana/example/map/keys.cpp b/src/boost/libs/hana/example/map/keys.cpp new file mode 100644 index 000000000..073d6dec6 --- /dev/null +++ b/src/boost/libs/hana/example/map/keys.cpp @@ -0,0 +1,30 @@ +// 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) + +#include <boost/hana/assert.hpp> +#include <boost/hana/contains.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/keys.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/pair.hpp> +#include <boost/hana/permutations.hpp> +#include <boost/hana/tuple.hpp> +#include <boost/hana/type.hpp> + +#include <string> +namespace hana = boost::hana; +using namespace std::literals; + + +int main() { + auto m = hana::make_map( + hana::make_pair(hana::int_c<1>, "foobar"s), + hana::make_pair(hana::type_c<void>, 1234) + ); + + // The order of the keys is unspecified. + BOOST_HANA_CONSTANT_CHECK( + hana::keys(m) ^hana::in^ hana::permutations(hana::make_tuple(hana::int_c<1>, hana::type_c<void>)) + ); +} diff --git a/src/boost/libs/hana/example/map/make.cpp b/src/boost/libs/hana/example/map/make.cpp new file mode 100644 index 000000000..a9660e1cb --- /dev/null +++ b/src/boost/libs/hana/example/map/make.cpp @@ -0,0 +1,29 @@ +// 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) + +#include <boost/hana/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/pair.hpp> +#include <boost/hana/type.hpp> + +#include <string> +namespace hana = boost::hana; +using namespace std::literals; + + +int main() { + BOOST_HANA_RUNTIME_CHECK( + hana::make_map( + hana::make_pair(hana::int_c<1>, "foobar"s), + hana::make_pair(hana::type_c<void>, 1234) + ) + == + hana::make<hana::map_tag>( + hana::make_pair(hana::int_c<1>, "foobar"s), + hana::make_pair(hana::type_c<void>, 1234) + ) + ); +} diff --git a/src/boost/libs/hana/example/map/map.cpp b/src/boost/libs/hana/example/map/map.cpp new file mode 100644 index 000000000..a04ecfd73 --- /dev/null +++ b/src/boost/libs/hana/example/map/map.cpp @@ -0,0 +1,76 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. + +#include <boost/hana/assert.hpp> +#include <boost/hana/at_key.hpp> +#include <boost/hana/contains.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/pair.hpp> +#include <boost/hana/string.hpp> + +#include <functional> +#include <string> +#include <vector> +namespace hana = boost::hana; + + +template <typename ...Events> +struct event_system { + using Callback = std::function<void()>; + hana::map<hana::pair<Events, std::vector<Callback>>...> map_; + + template <typename Event, typename F> + void on(Event e, F handler) { + auto is_known_event = hana::contains(map_, e); + static_assert(is_known_event, + "trying to add a handler to an unknown event"); + + map_[e].push_back(handler); + } + + template <typename Event> + void trigger(Event e) const { + auto is_known_event = hana::contains(map_, e); + static_assert(is_known_event, + "trying to trigger an unknown event"); + + for (auto& handler : this->map_[e]) + handler(); + } +}; + +template <typename ...Events> +event_system<Events...> make_event_system(Events ...events) { + return {}; +} + + +int main() { + auto events = make_event_system( + BOOST_HANA_STRING("foo"), + BOOST_HANA_STRING("bar"), + BOOST_HANA_STRING("baz") + ); + + std::vector<std::string> triggered_events; + events.on(BOOST_HANA_STRING("foo"), [&] { + triggered_events.push_back("foo:1"); + }); + events.on(BOOST_HANA_STRING("foo"), [&] { + triggered_events.push_back("foo:2"); + }); + events.on(BOOST_HANA_STRING("bar"), [&] { + triggered_events.push_back("bar:1"); + }); + events.on(BOOST_HANA_STRING("baz"), [&] { + triggered_events.push_back("baz:1"); + }); + + events.trigger(BOOST_HANA_STRING("foo")); + events.trigger(BOOST_HANA_STRING("bar")); + events.trigger(BOOST_HANA_STRING("baz")); + + BOOST_HANA_RUNTIME_CHECK(triggered_events == std::vector<std::string>{ + "foo:1", "foo:2", "bar:1", "baz:1" + }); +} diff --git a/src/boost/libs/hana/example/map/searchable.cpp b/src/boost/libs/hana/example/map/searchable.cpp new file mode 100644 index 000000000..4f51e704e --- /dev/null +++ b/src/boost/libs/hana/example/map/searchable.cpp @@ -0,0 +1,30 @@ +// 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) + +#include <boost/hana/assert.hpp> +#include <boost/hana/at_key.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/find.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/optional.hpp> +#include <boost/hana/pair.hpp> +#include <boost/hana/type.hpp> +namespace hana = boost::hana; + + +constexpr auto m = hana::make_map( + hana::make_pair(hana::type_c<int>, 'i'), + hana::make_pair(hana::type_c<float>, 'f') +); +static_assert(hana::find(m, hana::type_c<int>) == hana::just('i'), ""); +static_assert(hana::find(m, hana::type_c<float>) == hana::just('f'), ""); +BOOST_HANA_CONSTANT_CHECK(hana::find(m, hana::type_c<void>) == hana::nothing); +BOOST_HANA_CONSTANT_CHECK(hana::find(m, hana::int_c<3>) == hana::nothing); + +// operator[] is equivalent to at_key +static_assert(m[hana::type_c<int>] == 'i', ""); +static_assert(m[hana::type_c<float>] == 'f', ""); + +int main() { } diff --git a/src/boost/libs/hana/example/map/symmetric_difference.cpp b/src/boost/libs/hana/example/map/symmetric_difference.cpp new file mode 100644 index 000000000..0f9784756 --- /dev/null +++ b/src/boost/libs/hana/example/map/symmetric_difference.cpp @@ -0,0 +1,33 @@ +// 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) + +#include <boost/hana/assert.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/symmetric_difference.hpp> + +namespace hana = boost::hana; + + +constexpr auto m1 = hana::make_map( + hana::make_pair(hana::type_c<int>, 1), + hana::make_pair(hana::type_c<bool>, hana::true_c) +); + +constexpr auto m2 = hana::make_map( + hana::make_pair(hana::type_c<float>, 1.0), + hana::make_pair(hana::type_c<long long>, 2LL), + hana::make_pair(hana::type_c<int>, 3) +); + +constexpr auto result_m = hana::make_map( + hana::make_pair(hana::type_c<bool>, hana::true_c), + hana::make_pair(hana::type_c<float>, 1.0), + hana::make_pair(hana::type_c<long long>, 2LL) +); + +int main() { + BOOST_HANA_RUNTIME_CHECK( + hana::symmetric_difference(m1, m2) == result_m + ); +} diff --git a/src/boost/libs/hana/example/map/to.cpp b/src/boost/libs/hana/example/map/to.cpp new file mode 100644 index 000000000..550c7665e --- /dev/null +++ b/src/boost/libs/hana/example/map/to.cpp @@ -0,0 +1,30 @@ +// 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) + +#include <boost/hana/assert.hpp> +#include <boost/hana/core/to.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/pair.hpp> +#include <boost/hana/tuple.hpp> +#include <boost/hana/type.hpp> + +#include <string> +namespace hana = boost::hana; +using namespace std::literals; + + +int main() { + auto xs = hana::make_tuple( + hana::make_pair(hana::type_c<int>, "abcd"s), + hana::make_pair(hana::type_c<void>, 1234), + hana::make_pair(hana::type_c<int>, nullptr) + ); + + BOOST_HANA_RUNTIME_CHECK( + hana::to<hana::map_tag>(xs) == hana::make_map( + hana::make_pair(hana::type_c<int>, "abcd"s), + hana::make_pair(hana::type_c<void>, 1234) + ) + ); +} diff --git a/src/boost/libs/hana/example/map/union.cpp b/src/boost/libs/hana/example/map/union.cpp new file mode 100644 index 000000000..d214b34df --- /dev/null +++ b/src/boost/libs/hana/example/map/union.cpp @@ -0,0 +1,53 @@ +// 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) + +#include <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/string.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/type.hpp> +#include <boost/hana/union.hpp> + +#include <string> +namespace hana = boost::hana; +using namespace hana::literals; + + +static auto m1 = hana::make_map( + hana::make_pair(BOOST_HANA_STRING("key1"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key2"), hana::type_c<std::string>) +); + +static auto m2 = hana::make_map( + hana::make_pair(BOOST_HANA_STRING("key3"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key4"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key5"), hana::type_c<std::string>) +); + +BOOST_HANA_CONSTANT_CHECK(hana::union_(m1, m2) == hana::make_map( + hana::make_pair(BOOST_HANA_STRING("key1"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key2"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key3"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key4"), hana::type_c<std::string>), + hana::make_pair(BOOST_HANA_STRING("key5"), hana::type_c<std::string>) +)); + +constexpr auto m3 = hana::make_map( + hana::make_pair(hana::type_c<int>, hana::int_c<1>), + hana::make_pair(hana::type_c<bool>, hana::bool_c<true>) +); + +constexpr auto m4 = hana::make_map( + hana::make_pair(hana::type_c<char>, hana::char_c<'c'>), + hana::make_pair(hana::type_c<bool>, hana::bool_c<false>) +); + +BOOST_HANA_CONSTANT_CHECK(hana::union_(m3, m4) == hana::make_map( + hana::make_pair(hana::type_c<int>, hana::int_c<1>), + hana::make_pair(hana::type_c<bool>, hana::bool_c<false>), + hana::make_pair(hana::type_c<char>, hana::char_c<'c'>) +)); + +int main() { } diff --git a/src/boost/libs/hana/example/map/values.cpp b/src/boost/libs/hana/example/map/values.cpp new file mode 100644 index 000000000..4bbfb92f5 --- /dev/null +++ b/src/boost/libs/hana/example/map/values.cpp @@ -0,0 +1,29 @@ +// 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) + +#include <boost/hana/assert.hpp> +#include <boost/hana/contains.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/pair.hpp> +#include <boost/hana/permutations.hpp> +#include <boost/hana/tuple.hpp> +#include <boost/hana/type.hpp> + +#include <string> +namespace hana = boost::hana; +using namespace std::literals; + + +int main() { + auto m = hana::make_map( + hana::make_pair(hana::int_c<1>, "foobar"s), + hana::make_pair(hana::type_c<void>, 1234) + ); + + // The order of the values is unspecified. + BOOST_HANA_RUNTIME_CHECK( + hana::values(m) ^hana::in^ hana::permutations(hana::make_tuple("foobar"s, 1234)) + ); +} |