base_type; \
typedef typename base_type::pointer_type pointer_type; \
typedef typename base_type::index_type index_type; \
#define _DEFINE_VALPTRIDX_SUBTYPE_CTOR2(N) \
N##_template_t(pointer_type t, index_type s) : \
base_type(t, s) \
{ \
} \
#define _DEFINE_VALPTRIDX_SUBTYPE_USERTYPE(name,base) \
struct name : public base { \
name() DXX_CXX11_EXPLICIT_DELETE; \
DXX_INHERIT_CONSTRUCTORS(name, base); \
} \
#define _DEFINE_VALPTRIDX_SUBTYPE_USERTYPES(N,P) \
_DEFINE_VALPTRIDX_SUBTYPE_USERTYPE(N##_t, N##_template_t); \
_DEFINE_VALPTRIDX_SUBTYPE_USERTYPE(c##N##_t, N##_template_t
); \
#ifdef DXX_HAVE_BUILTIN_CONSTANT_P
#define DXX_VALPTRIDX_STATIC_CHECK(I,E,F,S) \
if (dxx_builtin_constant_p(I) && !(E)) { \
void F() __attribute_error(S); \
F(); \
}
#else
#define DXX_VALPTRIDX_STATIC_CHECK(I,E,F,S) \
#endif
#define DEFINE_VALPTRIDX_SUBTYPE(N,P,I,A) \
_DEFINE_VALPTRIDX_SUBTYPE_HEADER(N,I) \
{ \
_DEFINE_VALPTRIDX_SUBTYPE_TYPEDEFS(I) \
_DEFINE_VALPTRIDX_SUBTYPE_CTOR2(N) \
N##_template_t(pointer_type t) : \
base_type(t, t-A) \
{ \
DXX_VALPTRIDX_STATIC_CHECK(t, t, dxx_trap_constant_null_pointer, "NULL pointer used"); \
} \
N##_template_t(index_type s) : \
base_type(&A[s], s) \
{ \
DXX_VALPTRIDX_STATIC_CHECK(s, static_cast(s) < A.size(), dxx_trap_constant_invalid_index, "invalid index used in array subscript"); \
} \
template \
N##_template_t(const P##_magic_constant_t &) : \
base_type(static_cast(i) < A.size() ? &A[i] : NULL, i) \
{ \
} \
}; \
\
_DEFINE_VALPTRIDX_SUBTYPE_USERTYPES(N,P); \
\
static inline N##_t N(N##_t::pointer_type o, N##_t::index_type i) { return N##_t(o, i); } \
static inline c##N##_t N(c##N##_t::pointer_type o, c##N##_t::index_type i) { return c##N##_t(o, i); } \