#include <iostream>
#include <vector>
using namespace std;
class Foo
{
};
template <typename T>
class SecretPointer
{
    T* m_pointer;
public:
    SecretPointer(T* obj) : m_pointer(obj)
    {
    }
    T* getPtr() const
    {
        return m_pointer;
    }
    void setPointerBit(const bool value)
    {
        if(value)
            m_pointer = (T*)((int)m_pointer | value);
        else
            m_pointer = (T*)((int)m_pointer & ~1);
    }
    bool getPointerBit()
    {
        return ((int)m_pointer & 1);
    }
};
int main()
{
    std::vector<SecretPointer<Foo>> arr;
    SecretPointer<Foo> ptr = new Foo();
    ptr.setPointerBit(true);
    bool isT = ptr.getPointerBit();
    arr.push_back(new Foo());
    arr.push_back(new Foo());
    arr.push_back(new Foo());
    arr.push_back(ptr);
    arr.push_back(new Foo());
    for(auto& it : arr)
    {
        cout << "Secret values: " << it.getPointerBit() << " sizeof : " << sizeof(it) << endl;
    }
}
I just find for myself that every pointer has not significant bit. I read that this technology used in red-black trees algorithms.
What about sphere of application of this trick?
Where can I use with with confidence that all is fine?
 
     
     
    