1 #ifndef fhiclcpp_stdmap_shims_h 2 #define fhiclcpp_stdmap_shims_h 10 #include <type_traits> 19 class Compare = std::less<Key>,
20 class Allocator = std::allocator<std::pair<const Key, T>>>
23 using mapmap_t = std::map<const Key, T, Compare, Allocator>;
24 using listmap_t = std::list<std::pair<const Key, T>, Allocator>;
26 static_assert(std::is_same_v<
typename mapmap_t::key_type,
27 typename listmap_t::value_type::first_type>,
28 "type mismatch for key_type");
29 static_assert(std::is_same_v<
typename mapmap_t::mapped_type,
30 typename listmap_t::value_type::second_type>,
31 "type mismatch for mapped_type");
32 static_assert(std::is_same_v<
typename mapmap_t::value_type,
33 typename listmap_t::value_type>,
34 "type mismatch for value_type");
35 static_assert(std::is_same_v<
typename mapmap_t::size_type,
36 typename listmap_t::size_type>,
37 "type mismatch for size_type");
47 template <
class Category,
49 class Distance = std::ptrdiff_t,
51 class Reference = TT&>
60 return isSnippetMode() ? *_iters.listmap_iter : *_iters.mapmap_iter;
65 return isSnippetMode() ? &*_iters.listmap_iter : &*_iters.mapmap_iter;
69 return isSnippetMode() ? &*_iters.listmap_iter : &*_iters.mapmap_iter;
76 *(_iters.mapmap_iter++);
93 template <
typename II>
94 std::enable_if_t<std::is_same_v<typename mapmap_t::iterator, II>, II>
get(
97 return _iters.mapmap_iter;
100 template <
typename II>
101 std::enable_if_t<std::is_same_v<typename listmap_t::iterator, II>, II>
104 return _iters.listmap_iter;
107 template <
typename IIL,
typename IIR>
108 friend std::enable_if_t<
109 !std::is_same_v<IIL, IIR> &&
110 std::is_same_v<std::remove_const_t<typename IIL::type>,
111 std::remove_const_t<typename IIR::type>>,
115 template <
typename IIL,
typename IIR>
116 friend std::enable_if_t<
117 !std::is_same_v<IIL, IIR> &&
118 std::is_same_v<std::remove_const_t<typename IIL::type>,
119 std::remove_const_t<typename IIR::type>>,
139 if (element.first == key)
140 return element.second;
199 [&
key](
auto& element) {
return element.first ==
key; });
201 throw std::out_of_range(
"Key <" + key +
"> not found.");
212 auto it = std::find_if(
215 [&
key](
auto const& element) {
return element.first ==
key; });
217 throw std::out_of_range(
"Key <" + key +
"> not found.");
230 return element.first ==
key;
246 [&
key](
auto const& element) {
return element.first ==
key; });
248 return maps.
mapmap.find(key);
256 auto erase_count =
size_t{0};
261 if (key == i->first) {
307 template <
class... Args>
308 std::pair<iterator, bool>
322 template <
typename IIL,
typename IIR>
323 std::enable_if_t<!std::is_same_v<IIL, IIR> &&
324 std::is_same_v<std::remove_const_t<typename IIL::type>,
325 std::remove_const_t<typename IIR::type>>,
330 left._iters.listmap_iter == right._iters.listmap_iter :
331 left._iters.mapmap_iter == right._iters.mapmap_iter;
334 template <
typename IIL,
typename IIR>
335 std::enable_if_t<!std::is_same_v<IIL, IIR> &&
336 std::is_same_v<std::remove_const_t<typename IIL::type>,
337 std::remove_const_t<typename IIR::type>>,
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
size_t erase(Key const &key)
bool isSnippetMode(bool m)
listmap_t::iterator listmap_iter
bool operator!=(iter other) const
std::pair< iterator, bool > emplace(Args &&...args)
iter(typename listmap_t::iterator it)
const_iterator begin() const
TT const * operator->() const
std::enable_if_t< std::is_same_v< typename mapmap_t::iterator, II >, II > get(II)
iter(typename mapmap_t::iterator it)
const_iterator cbegin() const
mapmap_t::iterator mapmap_iter
T const & at(Key const &key) const
std::enable_if_t<!std::is_same_v< IIL, IIR > &&std::is_same_v< std::remove_const_t< typename IIL::type >, std::remove_const_t< typename IIR::type > >, bool > operator!=(IIL left, IIR right)
std::enable_if_t<!std::is_same_v< IIL, IIR > &&std::is_same_v< std::remove_const_t< typename IIL::type >, std::remove_const_t< typename IIR::type > >, bool > operator==(IIL left, IIR right)
bool operator==(iter other) const
iterator erase(iterator it)
T & operator[](Key const &key)
const_iterator end() const
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
std::list< std::pair< const Key, T >, Allocator > listmap_t
const_iterator cend() const
iterator find(Key const &key)
typename mapmap_t::size_type size_type
std::input_iterator_tag iterator_tag
std::map< const Key, T, Compare, Allocator > mapmap_t
iterator erase(const_iterator &it)
const_iterator find(Key const &key) const