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 =
typename std::map<const Key, T, Compare, Allocator>;
24 using listmap_t =
typename std::list<std::pair<const Key, T>, Allocator>;
27 std::is_same<
typename mapmap_t::key_type,
28 typename listmap_t::value_type::first_type>::
value,
29 "type mismatch for key_type");
31 std::is_same<
typename mapmap_t::mapped_type,
32 typename listmap_t::value_type::second_type>::
value,
33 "type mismatch for mapped_type");
34 static_assert(std::is_same<
typename mapmap_t::value_type,
35 typename listmap_t::value_type>::
value,
36 "type mismatch for value_type");
37 static_assert(std::is_same<
typename mapmap_t::size_type,
38 typename listmap_t::size_type>::
value,
39 "type mismatch for size_type");
49 template <
class Category,
51 class Distance = std::ptrdiff_t,
53 class Reference = TT&>
62 return isSnippetMode() ? *_iters.listmap_iter : *_iters.mapmap_iter;
67 return isSnippetMode() ? &*_iters.listmap_iter : &*_iters.mapmap_iter;
71 return isSnippetMode() ? &*_iters.listmap_iter : &*_iters.mapmap_iter;
77 *(_iters.mapmap_iter++);
94 template <
typename II>
95 typename std::enable_if<
99 return _iters.mapmap_iter;
102 template <
typename II>
103 typename std::enable_if<
107 return _iters.listmap_iter;
110 template <
typename IIL,
typename IIR>
111 friend typename std::enable_if<
114 typename std::remove_const<typename IIL::type>::type,
115 typename std::remove_const<typename IIR::type>::type>
::value,
119 template <
typename IIL,
typename IIR>
120 friend typename std::enable_if<
123 typename std::remove_const<typename IIL::type>::type,
124 typename std::remove_const<typename IIR::type>::type>
::value,
144 if (element.first == key)
145 return element.second;
205 [&key](
auto& element) {
return element.first == key; });
207 throw std::out_of_range(
"Key <" + key +
"> not found.");
215 at(Key
const& key)
const 218 auto it = std::find_if(
221 [&key](
auto const& element) {
return element.first == key; });
223 throw std::out_of_range(
"Key <" + key +
"> not found.");
236 return element.first == key;
252 [&key](
auto const& element) {
return element.first == key; });
254 return maps.
mapmap.find(key);
262 auto erase_count =
size_t{0};
267 if (key == i->first) {
313 template <
class... Args>
314 std::pair<iterator, bool>
318 _maps.
listmap.emplace_back(std::forward<Args>(args)...);
321 auto result =
_maps.
mapmap.emplace(std::forward<Args>(args)...);
322 return std::make_pair(
iterator{result.first}, result.second);
328 template <
typename IIL,
typename IIR>
329 typename std::enable_if<
331 std::is_same<typename std::remove_const<typename IIL::type>::type,
332 typename std::remove_const<typename IIR::type>::type>
::value,
337 left._iters.listmap_iter == right._iters.listmap_iter :
338 left._iters.mapmap_iter == right._iters.mapmap_iter;
341 template <
typename IIL,
typename IIR>
342 typename std::enable_if<
344 std::is_same<typename std::remove_const<typename IIL::type>::type,
345 typename std::remove_const<typename IIR::type>::type>
::value,
typename std::map< const Key, T, Compare, Allocator > mapmap_t
size_t erase(Key const &key)
bool isSnippetMode(bool m)
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
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< std::is_same< typename mapmap_t::iterator, II >::value, II >::type get(II)
std::enable_if< !std::is_same< IIL, IIR >::value &&std::is_same< typename std::remove_const< typename IIL::type >::type, typename std::remove_const< typename IIR::type >::type >::value, bool >::type operator!=(IIL left, IIR right)
typename std::list< std::pair< const Key, T >, Allocator > listmap_t
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
iter(typename mapmap_t::iterator it)
const_iterator cbegin() const
mapmap_t::iterator mapmap_iter
T const & at(Key const &key) const
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
std::string value(boost::any const &)
bool operator==(iter other) const
iterator erase(iterator it)
T & operator[](Key const &key)
std::enable_if< !std::is_same< IIL, IIR >::value &&std::is_same< typename std::remove_const< typename IIL::type >::type, typename std::remove_const< typename IIR::type >::type >::value, bool >::type operator==(IIL left, IIR right)
const_iterator end() const
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
const_iterator cend() const
iterator find(Key const &key)
typename mapmap_t::size_type size_type
std::input_iterator_tag iterator_tag
iterator erase(const_iterator &it)
const_iterator find(Key const &key) const