#include <iostream>
#include <vector>

template<long long X>
class Bitset
{
private:
    std::vector<unsigned char> bits = std::vector<unsigned char> ((X+7)/8);

public:
    /* constructors */

    class BitProxy
    {
    private:
        unsigned char &bit;

    public:
        BitProxy(unsigned char &bit) : bit(bit) {}

        BitProxy& operator=(unsigned char x) { bit = x; return *this; }
        operator unsigned char() const { return bit; }
    };

    BitProxy operator[](size_t index) { return BitProxy(bits[index]); }

    friend std::ostream& operator<< (std::ostream &output, const BitProxy &x)
	{
    	output << static_cast<short>(static_cast<unsigned char>(x));
	    return output;
	}
};

int main()
{
	Bitset<1> a;
	a[0] = 0xff;
	std::cout << a[0] << std::endl;
	std::cout << 'a' << std::endl;
	return 0;
}