summaryrefslogtreecommitdiff
path: root/boost/hana/map.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-09-13 11:05:34 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-09-13 11:06:28 +0900
commit34bd32e225e2a8a94104489b31c42e5801cc1f4a (patch)
treed021b579a0c190354819974e1eaf0baa54b551f3 /boost/hana/map.hpp
parentf763a99a501650eff2c60288aa6f10ef916d769e (diff)
downloadboost-34bd32e225e2a8a94104489b31c42e5801cc1f4a.tar.gz
boost-34bd32e225e2a8a94104489b31c42e5801cc1f4a.tar.bz2
boost-34bd32e225e2a8a94104489b31c42e5801cc1f4a.zip
Imported Upstream version 1.63.0upstream/1.63.0
Change-Id: Iac85556a04b7e58d63ba636dedb0986e3555714a Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/hana/map.hpp')
-rw-r--r--boost/hana/map.hpp69
1 files changed, 38 insertions, 31 deletions
diff --git a/boost/hana/map.hpp b/boost/hana/map.hpp
index 4aecb68482..3161d9b777 100644
--- a/boost/hana/map.hpp
+++ b/boost/hana/map.hpp
@@ -53,6 +53,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/hana/value.hpp>
#include <cstddef>
+#include <type_traits>
#include <utility>
@@ -71,33 +72,39 @@ BOOST_HANA_NAMESPACE_BEGIN
// map
//////////////////////////////////////////////////////////////////////////
//! @cond
- template <typename HashTable, typename Storage>
- struct map
- : detail::searchable_operators<map<HashTable, Storage>>
- , detail::operators::adl<map<HashTable, Storage>>
- {
- using hash_table_type = HashTable;
- using storage_type = Storage;
-
- Storage storage;
-
- using hana_tag = map_tag;
-
- explicit constexpr map(Storage const& xs)
- : storage(xs)
- { }
-
- explicit constexpr map(Storage&& xs)
- : storage(static_cast<Storage&&>(xs))
- { }
-
- constexpr map() = default;
- constexpr map(map const& other) = default;
- constexpr map(map&& other) = default;
- };
- //! @endcond
-
namespace detail {
+ template <typename HashTable, typename Storage>
+ struct map_impl
+ : detail::searchable_operators<map_impl<HashTable, Storage>>
+ , detail::operators::adl<map_impl<HashTable, Storage>>
+ {
+ using hash_table_type = HashTable;
+ using storage_type = Storage;
+
+ Storage storage;
+
+ using hana_tag = map_tag;
+
+ template <typename ...P, typename = typename std::enable_if<
+ std::is_same<
+ Storage,
+ hana::basic_tuple<typename detail::decay<P>::type...>
+ >::value
+ >::type>
+ explicit constexpr map_impl(P&& ...pairs)
+ : storage{static_cast<P&&>(pairs)...}
+ { }
+
+ explicit constexpr map_impl(Storage&& xs)
+ : storage(static_cast<Storage&&>(xs))
+ { }
+
+ constexpr map_impl() = default;
+ constexpr map_impl(map_impl const& other) = default;
+ constexpr map_impl(map_impl&& other) = default;
+ };
+ //! @endcond
+
template <typename Storage>
struct KeyAtIndex {
template <std::size_t i>
@@ -117,12 +124,12 @@ BOOST_HANA_NAMESPACE_BEGIN
"hana::make_map(pairs...) requires all the 'pairs' to be Products");
static_assert(detail::fast_and<
- Comparable<decltype(hana::first(pairs))>::value...
+ hana::Comparable<decltype(hana::first(pairs))>::value...
>::value,
"hana::make_map(pairs...) requires all the keys to be Comparable");
static_assert(detail::fast_and<
- Constant<
+ hana::Constant<
decltype(hana::equal(hana::first(pairs), hana::first(pairs)))
>::value...
>::value,
@@ -144,9 +151,9 @@ BOOST_HANA_NAMESPACE_BEGIN
detail::KeyAtIndex<Storage>::template apply, sizeof...(Pairs)
>::type;
- return map<HashTable, Storage>(
+ return detail::map_impl<HashTable, Storage>{
hana::make_basic_tuple(static_cast<Pairs&&>(pairs)...)
- );
+ };
}
};
@@ -189,7 +196,7 @@ BOOST_HANA_NAMESPACE_BEGIN
using NewStorage = decltype(
hana::append(static_cast<Map&&>(map).storage, static_cast<Pair&&>(pair))
);
- return hana::map<NewHashTable, NewStorage>(
+ return detail::map_impl<NewHashTable, NewStorage>(
hana::append(static_cast<Map&&>(map).storage, static_cast<Pair&&>(pair))
);
}