@@ -337,7 +337,7 @@ class single_subscription_map
337337 }
338338
339339 // Remove a value at the specified subscription path
340- void remove (MQTT_NS::string_view subscription) {
340+ void erase (MQTT_NS::string_view subscription) {
341341 auto path = this ->find_subscription (subscription);
342342 if (path.empty ()) {
343343 return ;
@@ -347,7 +347,7 @@ class single_subscription_map
347347 }
348348
349349 // Remove a value using a handle
350- void remove (handle h) {
350+ void erase (handle h) {
351351 auto path = this ->handle_to_iterators (h);
352352 if (!path.empty ()) {
353353 this ->remove_subscription (path);
@@ -399,12 +399,12 @@ class multiple_subscription_map
399399
400400 auto & subscription_set = h_iter->second .value ;
401401 bool insert_result = subscription_set.insert (std::move (value)).second ;
402- return std::make_pair (this -> path_to_handle (path) , insert_result);
402+ return std::make_pair (h , insert_result);
403403 }
404404
405405 // Remove a value at the specified subscription path
406406 // returns the value of the removed element (if found)
407- boost::optional<Value> remove (MQTT_NS::string_view subscription, Value const & value) {
407+ size_t remove (MQTT_NS::string_view subscription, Value const & value) {
408408 // Find the subscription in the map
409409 auto path = this ->find_subscription (subscription);
410410 if (path.empty ()) {
@@ -413,25 +413,12 @@ class multiple_subscription_map
413413
414414 // Remove the specified value
415415 auto & subscription_set = path.back ()->second .value ;
416- auto subscription_iter = subscription_set.find (value);
417- if (subscription_iter != subscription_set.end ()) {
418- auto result = boost::make_optional (*subscription_iter);
419- subscription_set.erase (subscription_iter);
420-
421- // Remove the subscription when all entries are removed
422- if (subscription_set.empty ()) {
423- this ->remove_subscription (path);
424- }
425-
426- return result;
427- }
428-
429- return boost::optional<Value>();
416+ return subscription_set.erase (value);
430417 }
431418
432419 // Remove a value at the specified handle
433420 // returns the value of the removed element (if found)
434- boost::optional<Value> remove (handle h, Value const & value) {
421+ size_t erase (handle h, Value const & value) {
435422 if (h.empty ()) {
436423 throw std::runtime_error (" Invalid handle was specified" );
437424 }
@@ -443,20 +430,7 @@ class multiple_subscription_map
443430 }
444431
445432 auto & subscription_set = h_iter->second .value ;
446- auto subscription_iter = subscription_set.find (value);
447- if (subscription_iter != subscription_set.end ()) {
448- auto result = boost::make_optional (*subscription_iter);
449- subscription_set.erase (subscription_iter);
450-
451- // Remove the subscription when all entries are removed
452- if (subscription_set.empty ()) {
453- this ->remove_subscription (this ->handle_to_iterators (h));
454- }
455-
456- return result;
457- }
458-
459- return boost::optional<Value>();
433+ return subscription_set.erase (value);
460434 }
461435
462436 // Find all subscriptions that match the specified topic
0 commit comments