I have a template class which takes as its first template argument a foo * pointer. I\'d like to instantiate one of these with a foo located at an absolute address, like so:
First, don't use c-style casts. It doesn't make it explicit what is does.
Second, you will realize that in order to cast an arbitrary number into a pointer, you need to use reinterpret_cast
. This sort of cast is not allowed in constexpr expressions.
Since template parameters are only possible with constant expressions, an arbitrary number as a pointer is not possible.
The case where 0 is possible is because 0 is convertible to nullptr, which is constant expression.