Suppose:
struct P {
P(int v);
};
int v;
P p = 0; // allow
P q = v; // Fail at compile time
How can achieve that? any template trick?
I am trying to write allocator which has special pointer properties. unfortunately std implementation uses implicit conversion from int to NULL pointer:
{ return __n != 0 ? _M_impl.allocate(__n) : 0; }
my pointer implementation:
http://code.google.com/p/asadchev/source/browse/trunk/projects/boost/cuda/mapped_ptr.hpp
my allocator implementation:
http://code.google.com/p/asadchev/source/browse/trunk/projects/boost/cuda/allocator.hpp
I want to enforce explicit construction using raw pointer to avoid nasty problems.
You can do it but you won’t like it
This will only allow null pointer constants. In other words, zero compile time values.