/usr/include/boost/hana
NameSizeModeActions
concept/-0755rm
core/-0755rm
detail/-0755rm
experimental/-0755rm
ext/-0755rm
functional/-0755rm
fwd/-0755rm
accessors.hpp15130644editdlrm
adapt_adt.hpp4220644editdlrm
adapt_struct.hpp4370644editdlrm
adjust.hpp16980644editdlrm
adjust_if.hpp25150644editdlrm
all.hpp13270644editdlrm
all_of.hpp15700644editdlrm
and.hpp16670644editdlrm
any.hpp13270644editdlrm
any_of.hpp75310644editdlrm
ap.hpp24960644editdlrm
append.hpp23570644editdlrm
assert.hpp163250644editdlrm
at.hpp16590644editdlrm
at_key.hpp30090644editdlrm
back.hpp15340644editdlrm
basic_tuple.hpp94550644editdlrm
bool.hpp97470644editdlrm
cartesian_product.hpp38600644editdlrm
chain.hpp14880644editdlrm
comparing.hpp12220644editdlrm
concat.hpp27120644editdlrm
concept.hpp13010644editdlrm
config.hpp71520644editdlrm
contains.hpp15600644editdlrm
core.hpp6100644editdlrm
count.hpp14960644editdlrm
count_if.hpp31370644editdlrm
cycle.hpp42750644editdlrm
define_struct.hpp4420644editdlrm
difference.hpp11160644editdlrm
div.hpp38040644editdlrm
drop_back.hpp24750644editdlrm
drop_front.hpp17960644editdlrm
drop_front_exactly.hpp30300644editdlrm
drop_while.hpp31740644editdlrm
duplicate.hpp13920644editdlrm
empty.hpp14000644editdlrm
equal.hpp80120644editdlrm
erase_key.hpp10290644editdlrm
eval.hpp17980644editdlrm
eval_if.hpp33810644editdlrm
extend.hpp14980644editdlrm
extract.hpp12480644editdlrm
fill.hpp22160644editdlrm
filter.hpp44730644editdlrm
find.hpp17320644editdlrm
find_if.hpp40110644editdlrm
first.hpp12420644editdlrm
flatten.hpp17690644editdlrm
fold.hpp3780644editdlrm
fold_left.hpp31280644editdlrm
fold_right.hpp31470644editdlrm
for_each.hpp18630644editdlrm
front.hpp13150644editdlrm
functional.hpp11860644editdlrm
fuse.hpp13090644editdlrm
greater.hpp24010644editdlrm
greater_equal.hpp25520644editdlrm
group.hpp55430644editdlrm
hash.hpp35720644editdlrm
if.hpp18340644editdlrm
index_if.hpp34850644editdlrm
insert.hpp16200644editdlrm
insert_range.hpp21710644editdlrm
integral_constant.hpp3890644editdlrm
intersection.hpp11000644editdlrm
intersperse.hpp25860644editdlrm
is_disjoint.hpp20400644editdlrm
is_empty.hpp12440644editdlrm
is_subset.hpp29190644editdlrm
keys.hpp13070644editdlrm
lazy.hpp79470644editdlrm
length.hpp15540644editdlrm
less.hpp53220644editdlrm
less_equal.hpp24850644editdlrm
lexicographical_compare.hpp43440644editdlrm
lift.hpp15000644editdlrm
map.hpp225930644editdlrm
max.hpp17590644editdlrm
maximum.hpp33480644editdlrm
members.hpp19700644editdlrm
min.hpp17590644editdlrm
minimum.hpp33530644editdlrm
minus.hpp40050644editdlrm
mod.hpp38040644editdlrm
monadic_compose.hpp15830644editdlrm
monadic_fold_left.hpp48620644editdlrm
monadic_fold_right.hpp48820644editdlrm
mult.hpp37470644editdlrm
negate.hpp18570644editdlrm
none.hpp13400644editdlrm
none_of.hpp15320644editdlrm
not.hpp22170644editdlrm
not_equal.hpp19820644editdlrm
one.hpp24320644editdlrm
optional.hpp154220644editdlrm
or.hpp18600644editdlrm
ordering.hpp12310644editdlrm
pair.hpp80480644editdlrm
partition.hpp41990644editdlrm
permutations.hpp25990644editdlrm
plus.hpp37590644editdlrm
power.hpp19540644editdlrm
prefix.hpp15970644editdlrm
prepend.hpp23720644editdlrm
product.hpp17010644editdlrm
range.hpp99100644editdlrm
remove.hpp16950644editdlrm
remove_at.hpp29890644editdlrm
remove_if.hpp16440644editdlrm
remove_range.hpp38850644editdlrm
repeat.hpp17930644editdlrm
replace.hpp17970644editdlrm
replace_if.hpp17640644editdlrm
replicate.hpp22820644editdlrm
reverse.hpp18020644editdlrm
reverse_fold.hpp11440644editdlrm
scan_left.hpp50600644editdlrm
scan_right.hpp51380644editdlrm
second.hpp12530644editdlrm
set.hpp118540644editdlrm
size.hpp3750644editdlrm
slice.hpp34070644editdlrm
sort.hpp88550644editdlrm
span.hpp26290644editdlrm
string.hpp123100644editdlrm
suffix.hpp15830644editdlrm
sum.hpp16610644editdlrm
symmetric_difference.hpp13940644editdlrm
take_back.hpp25190644editdlrm
take_front.hpp24710644editdlrm
take_while.hpp17760644editdlrm
tap.hpp16160644editdlrm
then.hpp16880644editdlrm
traits.hpp101720644editdlrm
transform.hpp24110644editdlrm
tuple.hpp116510644editdlrm
type.hpp100820644editdlrm
unfold_left.hpp22040644editdlrm
unfold_right.hpp22240644editdlrm
union.hpp10300644editdlrm
unique.hpp23610644editdlrm
unpack.hpp51750644editdlrm
value.hpp15610644editdlrm
version.hpp20320644editdlrm
while.hpp44410644editdlrm
zero.hpp24540644editdlrm
zip.hpp14620644editdlrm
zip_shortest.hpp16040644editdlrm
zip_shortest_with.hpp21160644editdlrm
zip_with.hpp22920644editdlrm
Edit: /usr/include/boost/hana/map.hpp (22593B)
/*! @file Defines `boost::hana::map`. @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_MAP_HPP #define BOOST_HANA_MAP_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 #include #include #include #include #include #include #include #include #include #include #include #include BOOST_HANA_NAMESPACE_BEGIN ////////////////////////////////////////////////////////////////////////// // operators ////////////////////////////////////////////////////////////////////////// namespace detail { template <> struct comparable_operators { static constexpr bool value = true; }; } ////////////////////////////////////////////////////////////////////////// // map ////////////////////////////////////////////////////////////////////////// //! @cond namespace detail { template struct storage_is_default_constructible; template struct storage_is_default_constructible> { static constexpr bool value = detail::fast_and< BOOST_HANA_TT_IS_CONSTRUCTIBLE(T)... >::value; }; template struct storage_is_copy_constructible; template struct storage_is_copy_constructible> { static constexpr bool value = detail::fast_and< BOOST_HANA_TT_IS_CONSTRUCTIBLE(T, T const&)... >::value; }; template struct storage_is_move_constructible; template struct storage_is_move_constructible> { static constexpr bool value = detail::fast_and< BOOST_HANA_TT_IS_CONSTRUCTIBLE(T, T&&)... >::value; }; template struct storage_is_copy_assignable; template struct storage_is_copy_assignable> { static constexpr bool value = detail::fast_and< BOOST_HANA_TT_IS_ASSIGNABLE(T, T const&)... >::value; }; template struct storage_is_move_assignable; template struct storage_is_move_assignable> { static constexpr bool value = detail::fast_and< BOOST_HANA_TT_IS_ASSIGNABLE(T, T&&)... >::value; }; template struct map_impl final : detail::searchable_operators> , detail::operators::adl> { using hash_table_type = HashTable; using storage_type = Storage; Storage storage; using hana_tag = map_tag; template ::type...> >::value >::type> explicit constexpr map_impl(P&& ...pairs) : storage{static_cast(pairs)...} { } explicit constexpr map_impl(Storage&& xs) : storage(static_cast(xs)) { } template ::value >::type> constexpr map_impl() : storage() { } template ::value >::type> constexpr map_impl(map_impl const& other) : storage(other.storage) { } template ::value >::type> constexpr map_impl(map_impl&& other) : storage(static_cast(other.storage)) { } template ::value >::type> constexpr map_impl& operator=(map_impl&& other) { storage = static_cast(other.storage); return *this; } template ::value >::type> constexpr map_impl& operator=(map_impl const& other) { storage = other.storage; return *this; } // Prevent the compiler from defining the default copy and move // constructors, which interfere with the SFINAE above. ~map_impl() = default; }; //! @endcond template struct KeyAtIndex { template using apply = decltype(hana::first(hana::at_c(std::declval()))); }; template struct make_map_type { using Storage = hana::basic_tuple; using HashTable = typename detail::make_hash_table< detail::KeyAtIndex::template apply, sizeof...(Pairs) >::type; using type = detail::map_impl; }; } ////////////////////////////////////////////////////////////////////////// // make ////////////////////////////////////////////////////////////////////////// template <> struct make_impl { template static constexpr auto apply(Pairs&& ...pairs) { #if defined(BOOST_HANA_CONFIG_ENABLE_DEBUG_MODE) static_assert(detail::fast_and::value...>::value, "hana::make_map(pairs...) requires all the 'pairs' to be Products"); static_assert(detail::fast_and< hana::Comparable::value... >::value, "hana::make_map(pairs...) requires all the keys to be Comparable"); static_assert(detail::fast_and< hana::Constant< decltype(hana::equal(hana::first(pairs), hana::first(pairs))) >::value... >::value, "hana::make_map(pairs...) requires all the keys to be " "Comparable at compile-time"); //! @todo //! This can be implemented more efficiently by doing the check //! inside each bucket instead. static_assert(!detail::has_duplicates::value, "hana::make_map({keys, values}...) requires all the keys to be unique"); static_assert(!detail::has_duplicates::value, "hana::make_map({keys, values}...) requires all the keys to have different hashes"); #endif using Map = typename detail::make_map_type::type...>::type; return Map{hana::make_basic_tuple(static_cast(pairs)...)}; } }; ////////////////////////////////////////////////////////////////////////// // keys ////////////////////////////////////////////////////////////////////////// template <> struct keys_impl { template static constexpr decltype(auto) apply(Map&& map) { return hana::transform(static_cast(map).storage, hana::first); } }; ////////////////////////////////////////////////////////////////////////// // values ////////////////////////////////////////////////////////////////////////// //! @cond template constexpr decltype(auto) values_t::operator()(Map&& map) const { return hana::transform(static_cast(map).storage, hana::second); } //! @endcond ////////////////////////////////////////////////////////////////////////// // insert ////////////////////////////////////////////////////////////////////////// template <> struct insert_impl { template static constexpr auto helper(Map&& map, Pair&& pair, ...) { using RawMap = typename std::remove_reference::type; using HashTable = typename RawMap::hash_table_type; using NewHashTable = typename detail::bucket_insert< HashTable, decltype(hana::first(pair)), decltype(hana::length(map.storage))::value >::type; using NewStorage = decltype( hana::append(static_cast(map).storage, static_cast(pair)) ); return detail::map_impl( hana::append(static_cast(map).storage, static_cast(pair)) ); } template static constexpr auto helper(Map&& map, Pair&&, hana::optional>) { return static_cast(map); } //! @todo //! Here, we insert only if the key is not already in the map. //! This should be handled by `bucket_insert`, and that would also //! be more efficient. template static constexpr auto apply(Map&& map, Pair&& pair) { using RawMap = typename std::remove_reference::type; using Storage = typename RawMap::storage_type; using HashTable = typename RawMap::hash_table_type; using Key = decltype(hana::first(pair)); using MaybeIndex = typename detail::find_index< HashTable, Key, detail::KeyAtIndex::template apply >::type; return helper(static_cast(map), static_cast(pair), MaybeIndex{}); } }; ////////////////////////////////////////////////////////////////////////// // erase_key ////////////////////////////////////////////////////////////////////////// template <> struct erase_key_impl { //! @todo //! We could implement some kind of `bucket_erase` metafunction //! that would be much more efficient than this. template static constexpr auto erase_key_helper(Map&& map, Key const&, hana::false_) { return static_cast(map); } template static constexpr auto erase_key_helper(Map&& map, Key const& key, hana::true_) { return hana::unpack( hana::remove_if(static_cast(map).storage, hana::on(hana::equal.to(key), hana::first)), hana::make_map ); } template static constexpr auto apply_impl(Map&& map, Key const& key, hana::false_) { return erase_key_helper(static_cast(map), key, hana::contains(map, key)); } template static constexpr auto apply_impl(Map&& map, Key const&, hana::true_) { return static_cast(map); } template static constexpr auto apply(Map&& map, Key const& key) { constexpr bool is_empty = decltype(hana::length(map))::value == 0; return apply_impl(static_cast(map), key, hana::bool_{}); } }; ////////////////////////////////////////////////////////////////////////// // Comparable ////////////////////////////////////////////////////////////////////////// template <> struct equal_impl { template static constexpr auto equal_helper(M1 const&, M2 const&, hana::false_) { return hana::false_c; } template static constexpr auto equal_helper(M1 const& m1, M2 const& m2, hana::true_) { return hana::all_of(hana::keys(m1), hana::demux(equal)( hana::partial(hana::find, m1), hana::partial(hana::find, m2) )); } template static constexpr auto apply(M1 const& m1, M2 const& m2) { return equal_impl::equal_helper(m1, m2, hana::bool_c< decltype(hana::length(m1.storage))::value == decltype(hana::length(m2.storage))::value >); } }; ////////////////////////////////////////////////////////////////////////// // Searchable ////////////////////////////////////////////////////////////////////////// template <> struct find_impl { template static constexpr auto find_helper(Map&&, ...) { return hana::nothing; } template static constexpr auto find_helper(Map&& map, hana::optional>) { return hana::just(hana::second(hana::at_c(static_cast(map).storage))); } template static constexpr auto apply(Map&& map, Key const&) { using RawMap = typename std::remove_reference::type; using Storage = typename RawMap::storage_type; using HashTable = typename RawMap::hash_table_type; using MaybeIndex = typename detail::find_index< HashTable, Key, detail::KeyAtIndex::template apply >::type; return find_helper(static_cast(map), MaybeIndex{}); } }; template <> struct find_if_impl { template static constexpr auto apply(M&& map, Pred&& pred) { return hana::transform( hana::find_if(static_cast(map).storage, hana::compose(static_cast(pred), hana::first)), hana::second ); } }; template <> struct contains_impl { template static constexpr auto apply(Map const&, Key const&) { using RawMap = typename std::remove_reference::type; using HashTable = typename RawMap::hash_table_type; using Storage = typename RawMap::storage_type; using MaybeIndex = typename detail::find_index< HashTable, Key, detail::KeyAtIndex::template apply >::type; return hana::bool_{}; } }; template <> struct any_of_impl { template static constexpr auto apply(M const& map, Pred const& pred) { return hana::any_of(hana::keys(map), pred); } }; template <> struct is_subset_impl { template struct all_contained { Ys const& ys; template constexpr auto operator()(X const& ...x) const { return hana::bool_c()... >::value>; } }; template static constexpr auto apply(Xs const& xs, Ys const& ys) { auto ys_keys = hana::keys(ys); return hana::unpack(hana::keys(xs), all_contained{ys_keys}); } }; template <> struct at_key_impl { template static constexpr decltype(auto) apply(Map&& map, Key const&) { using RawMap = typename std::remove_reference::type; using HashTable = typename RawMap::hash_table_type; using Storage = typename RawMap::storage_type; using MaybeIndex = typename detail::find_index< HashTable, Key, detail::KeyAtIndex::template apply >::type; static_assert(!decltype(hana::is_nothing(MaybeIndex{}))::value, "hana::at_key(map, key) requires the 'key' to be present in the 'map'"); constexpr std::size_t index = decltype(*MaybeIndex{}){}(); return hana::second(hana::at_c(static_cast(map).storage)); } }; ////////////////////////////////////////////////////////////////////////// // union_ ////////////////////////////////////////////////////////////////////////// template <> struct union_impl { template static constexpr auto apply(Xs&& xs, Ys&& ys) { return hana::fold_left(static_cast(xs), static_cast(ys), hana::insert); } }; ////////////////////////////////////////////////////////////////////////// // intersection_ ////////////////////////////////////////////////////////////////////////// namespace detail { template struct map_insert_if_contains { Ys const& ys; // Second template param will be pair // Get its key and check if it exists, if it does, insert key, value pair. template static constexpr auto helper(Result&& result, Pair&& pair, hana::true_) { return hana::insert(static_cast(result), static_cast(pair)); } template static constexpr auto helper(Result&& result, Pair&&, hana::false_) { return static_cast(result); } template constexpr auto operator()(Result&& result, Pair&& pair) const { constexpr bool keep = hana::value(); return map_insert_if_contains::helper(static_cast(result), static_cast(pair), hana::bool_c); } }; } template <> struct intersection_impl { template static constexpr auto apply(Xs&& xs, Ys const& ys) { return hana::fold_left(static_cast(xs), hana::make_map(), detail::map_insert_if_contains{ys}); } }; ////////////////////////////////////////////////////////////////////////// // difference ////////////////////////////////////////////////////////////////////////// template <> struct difference_impl { template static constexpr auto apply(Xs&& xs, Ys&& ys) { return hana::fold_left( hana::keys(static_cast(ys)), static_cast(xs), hana::erase_key); } }; ////////////////////////////////////////////////////////////////////////// // Foldable ////////////////////////////////////////////////////////////////////////// template <> struct unpack_impl { template static constexpr decltype(auto) apply(M&& map, F&& f) { return hana::unpack(static_cast(map).storage, static_cast(f)); } }; ////////////////////////////////////////////////////////////////////////// // Construction from a Foldable ////////////////////////////////////////////////////////////////////////// template struct to_impl::value>> { template static constexpr decltype(auto) apply(Xs&& xs) { return hana::fold_left( static_cast(xs), hana::make_map(), hana::insert ); } }; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_MAP_HPP