Closed vinipsmaker closed 6 years ago
It is easier to implement key::erase
as follows:
template <template <typename> class Allocator, typename T>
auto erase(basic_variable<Allocator>& self,
const T& other) -> typename basic_variable<Allocator>::key_iterator
{
switch (self.symbol())
{
case symbol::map:
{
auto where = key::find(self, other);
auto result = where;
++result;
self.erase(where.base());
return result;
}
default:
return self.key_end();
}
}
I've modified the PR to finish the tests and implement like you suggested. The PR is ready for review.
Also, I'll probably do more PRs related to this one.
dynamic::variable{} == boost::string_view{}
should be supported (and then this function should work against boost::string_view
too).dynamic::key_iterator
from a map::iterator
?One more thing: given you're the author of the function, I've committed using your name (git makes this task easy).
Regarding string_view
do notice that we have include/trial/protocol/core/detail/string_view.hpp
to select the right Boost version.
Regarding key::find
there is a private constructor in the iterator_base
class that takes a map::iterator
, but I want to avoid exposing a map::iterator
to key_iterator
conversion in the API.
Regarding
key::find
there is a private constructor in theiterator_base
class that takes amap::iterator
Nice.
but I want to avoid exposing a
map::iterator
tokey_iterator
conversion in the API.
Agreed.
What about a friend function living in detail
namespace? It'd make it easy to access it across our free functions that are intended to be used with dynamic::variable
.
Could you give me a hint on how to create a
dynamic::key_iterator
from amap::iterator
? I understood thecurrent
union containing the iterator, but I could make use of a suggestion on where to add such conversion (add a new constructor tokey_iterator
, make the new algorithm a friend function...).