#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <climits>

template <typename IterType>
unsigned long getValue(IterType i1, IterType i2)
{
	unsigned long i = 0;
    std::bitset<8 * sizeof(unsigned long)> b;
	std::for_each(i1, i2, [&](int n) { b.set(i++, n);});
	return b.to_ulong();
}
	
int main() 
{
	std::vector<int> v = {0, 1, 1, 0, 1, 0, 0, 1, 0, 0};
	auto val = getValue(v.rbegin(), v.rend());
    std::cout << val << "\n";;  
    auto val2 = getValue(v.begin(), v.end());
    std::cout << val2;  
}