Add correct bool combiner for net signals #5859

pull sipa wants to merge 1 commits into bitcoin:master from sipa:combiner changing 2 files +34 −2
  1. sipa commented at 11:49 AM on March 6, 2015: member

    Extracted from #5843.

  2. Add correct bool combiner for net signals 9519a9a420
  3. sipa commented at 11:50 AM on March 6, 2015: member

    @gavinandresen No clue how to use that boost::bind inside a type descriptor. Feel free to suggest code.

  4. laanwj commented at 2:22 PM on March 6, 2015: member

    ACK

  5. laanwj added the label Bug on Mar 6, 2015
  6. laanwj added the label Priority Medium on Mar 6, 2015
  7. gavinandresen commented at 11:32 PM on March 6, 2015: contributor

    Tested ACK.

    My c++ kung fu fails me trying to use boost::bind instead of a CombinerAll class. But you could save a couple of lines of code like this:

    diff --git a/src/net.h b/src/net.h
    index e500536..81783ab 100644
    --- a/src/net.h
    +++ b/src/net.h
    @@ -26,6 +26,7 @@
     #include <arpa/inet.h>
     #endif
    
    +#include <boost/algorithm/cxx11/all_of.hpp>
     #include <boost/filesystem/path.hpp>
     #include <boost/foreach.hpp>
     #include <boost/signals2/signal.hpp>
    @@ -83,11 +84,7 @@ struct CombinerAll
         template<typename I>
         bool operator()(I first, I last) const
         {
    -        while (first != last) {
    -            if (!(*first)) return false;
    -            ++first;
    -        }
    -        return true;
    +        return boost::algorithm::all_of_equal<I, bool>(first, last, true);
         }
     };
    

    Take it or leave it, your original code is arguably more readable (doesn't require knowledge of what all_of_equal does).

  8. laanwj commented at 10:56 AM on March 9, 2015: member

    #include &lt;boost/algorithm/cxx11/all_of.hpp>

    I like the shorter, declarative code. But (looking at the include file name) does that require c++11?

  9. gavinandresen commented at 12:52 PM on March 9, 2015: contributor

    This is a boost implementation of functionality already part of C++11 for older C++ compilers.

    Gavin Andresen

    On Mar 9, 2015, at 6:56 AM, Wladimir J. van der Laan notifications@github.com wrote:

    #include

    I like the shorter, declarative code. But (looking at the include file name) does that require c++11?

    — Reply to this email directly or view it on GitHub.

  10. laanwj commented at 9:10 AM on March 11, 2015: member

    Ah, right, a boost-ism that can be changed to a c++11-ism, that's great

  11. jgarzik commented at 1:55 PM on March 11, 2015: contributor

    ut ACK

  12. laanwj merged this on Mar 12, 2015
  13. laanwj closed this on Mar 12, 2015

  14. laanwj referenced this in commit dd4ffcec0e on Mar 12, 2015
  15. random-zebra referenced this in commit 8bbc0650e6 on Jul 1, 2020
  16. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-19 12:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me