fork download
  1. #include <iomanip>
  2. #include <iostream>
  3. #include <numeric>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. const vector<bool> foo = { true, false, false, false, false, true, false, false };
  10. int i = foo.size() - 1;
  11. const auto bar = accumulate(next(cbegin(foo)), cend(foo), foo.front() ? -(1 << i) : 0, [&](const auto val, const auto it) { return val + (it << --i); });
  12.  
  13. cout << hex << bar;
  14. }
Success #stdin #stdout 0s 4300KB
stdin
Standard input is empty
stdout
ffffff84