Code Modification Macros
[STLSoft]


Detailed Description

These macros are used to help out where compiler differences are so great as to cause great disgusting messes in the class/function implementations.


Defines

#define STLSOFT_GEN_TRAIT_SPECIALISATION(TR, T, V)
 Used to define a specialisation of a traits type.
#define STLSOFT_GEN_TRAIT_SPECIALISATION_WITH_TYPE(TR, T, V, MT)
 Used to define a specialisation of a traits type that contains a member type.
#define stlsoft_throw_0()
 Indicates that the given function/method does not throw any exceptions.
#define stlsoft_throw_1(x1)
 Indicates that the given function/method throws the named type.
#define stlsoft_throw_2(x1, x2)
 Indicates that the given function/method throws the two named types.
#define stlsoft_throw_3(x1, x2, x3)
 Indicates that the given function/method throws the three named types.
#define stlsoft_throw_4(x1, x2, x3, x4)
 Indicates that the given function/method throws the four named types.
#define stlsoft_throw_5(x1, x2, x3, x4, x5)
 Indicates that the given function/method throws the five named types.
#define stlsoft_throw_6(x1, x2, x3, x4, x5, x6)
 Indicates that the given function/method throws the six named types.
#define stlsoft_throw_7(x1, x2, x3, x4, x5, x6, x7)
 Indicates that the given function/method throws the seven named types.
#define stlsoft_throw_8(x1, x2, x3, x4, x5, x6, x7, x8)
 Indicates that the given function/method throws the eight named types.
#define STLSOFT_NUM_ELEMENTS(ar)
 Evaluates, at compile time, to the number of elements within the given vector entity.
#define stlsoft_num_elements(ar)   STLSOFT_NUM_ELEMENTS(ar)
 Evaluates, at compile time, to the number of elements within the given vector entity.
#define STLSOFT_RAW_OFFSETOF(S, M)   stlsoft_reinterpret_cast(stlsoft_ns_qual(ss_size_t), &stlsoft_static_cast(S*, 0)->M)
 Evaluates, at compile time, the offset of the member m in the structure s.
#define stlsoft_raw_offsetof(s, m)   STLSOFT_RAW_OFFSETOF(s, m)
 Evaluates, at compile time, the offset of a structure/class member.
#define STLSOFT_DESTROY_INSTANCE(T1, T2, P)   do { (P)->~T1(); } while(0)
#define stlsoft_destroy_instance(T1, T2, P)   STLSOFT_DESTROY_INSTANCE(T1, T2, P)
 Explicitly destroys an instance.
#define STLSOFT_GEN_OPAQUE(type)   typedef struct __stlsoft_htype##type{ int i;} const* type;
 Generates an opaque type with the name type.
#define stlsoft_gen_opaque(Type)   STLSOFT_GEN_OPAQUE(Type)
 Generates an opaque type with the name Type.
#define STLSOFT_DECLARE_TEMPLATE_PARAM_AS_FRIEND(T)   friend T
 Declares a template (class) parameter to be a friend of the template.
#define STLSOFT_SUPPRESS_UNUSED(x)   (static_cast<void>(x))
 Used to suppress unused variable warnings.
#define STLSOFT_UNNAMED_PARAM(p)   p
 Used to define an unused parameter for C compilation and/or documentation processing, but not for C++ compilation.
#define STLSOFT_SUPPRESS_UNNAMED_PARAM(p)   ((void)p);
 Used to suppress unused parameter warnings (in C compilation) for parameters defined by STLSOFT_UNNAMED_PARAM().


Define Documentation

#define STLSOFT_DECLARE_TEMPLATE_PARAM_AS_FRIEND (  )     friend T

Declares a template (class) parameter to be a friend of the template.

Is it used as follows:

template<typename T>
class Thing
{
  STLSOFT_DECLARE_TEMPLATE_PARAM_AS_FRIEND(T);
private:
  int m_member; // Thing<T>::m_member visible to T
};

Note:
This is contrary to the C++-98 standard. Section 7.1.5.3(2) notes: "...within a class template with a template type-parameter T, the declaration ["]friend class T;["] is ill-formed." However, it gives the expected behaviour for all compilers currently supported by STLSoft

#define stlsoft_destroy_instance ( T1,
T2,
 )     STLSOFT_DESTROY_INSTANCE(T1, T2, P)

Explicitly destroys an instance.

Deprecated:
This is deprecated in favour of STLSOFT_DESTROY_INSTANCE().
Note:
This is a simple #define for STLSOFT_DESTROY_INSTANCE()

#define STLSOFT_DESTROY_INSTANCE ( T1,
T2,
 )     do { (P)->~T1(); } while(0)

Parameters:
T1 The type to be destroyed, as a template parameter (e.g. T)
T2 The type to be destroyed, as a typedef (e.g. value_type)
P Pointer (T*) to the instance to be explicitly destroyed
Destroys the given instance P of the given type (T1 and T2)

Referenced by allocator_base< T, stlsoft::new_allocator< T > >::destroy().

#define stlsoft_gen_opaque ( Type   )     STLSOFT_GEN_OPAQUE(Type)

Generates an opaque type with the name Type.

Deprecated:
This is deprecated in favour of STLSOFT_GEN_OPAQUE().
Note:
This is a simple #define for STLSOFT_GEN_OPAQUE()

#define STLSOFT_GEN_OPAQUE ( type   )     typedef struct __stlsoft_htype##type{ int i;} const* type;

Generates an opaque type with the name type.

For example, the following defines two distinct opaque types:

The two types are incompatible with each other, and with any other types (except that they are both convertible to void const*

#define STLSOFT_GEN_TRAIT_SPECIALISATION ( TR,
T,
 ) 

Value:

\
    STLSOFT_TEMPLATE_SPECIALISATION                 \
    struct TR<T>                                    \
    {                                               \
        enum { value = V };                         \
    };
Used to define a specialisation of a traits type.

#define STLSOFT_GEN_TRAIT_SPECIALISATION_WITH_TYPE ( TR,
T,
V,
MT   ) 

Value:

\
    STLSOFT_TEMPLATE_SPECIALISATION                                 \
    struct TR<T>                                                    \
    {                                                               \
        enum { value = V };                                         \
                                                                    \
        typedef MT type;                                            \
    };
Used to define a specialisation of a traits type that contains a member type.

#define stlsoft_num_elements ( ar   )     STLSOFT_NUM_ELEMENTS(ar)

Evaluates, at compile time, to the number of elements within the given vector entity.

Parameters:
ar The array
Deprecated:
This is deprecated in favour of STLSOFT_NUM_ELEMENTS().
Note:
This is a simple #define for STLSOFT_NUM_ELEMENTS()

#define STLSOFT_NUM_ELEMENTS ( ar   ) 

Evaluates, at compile time, to the number of elements within the given vector entity.

Parameters:
ar The array
Is it used as follows:

int               ai[20];
int               i     = 32;
int               *pi   = &i;
std::vector<int>  vi;
size_t            s_ai  = STLSOFT_NUM_ELEMENTS(ai);   // Ok
size_t            s_i   = STLSOFT_NUM_ELEMENTS(i);    // Error
size_t            s_pi  = STLSOFT_NUM_ELEMENTS(pi);   // Error
size_t            s_vi  = STLSOFT_NUM_ELEMENTS(vi);   // Error

Note:
For most of the supported compilers, this macro will reject application to pointer types, or to class types providing operator []. This helps to avoid the common gotcha whereby (sizeof(ar) / sizeof(ar[0])) is applied to such types, without causing a compiler error.

From STLSoft 1.8.3 onwards, the underlying ss_static_array_size function is changed to return reference to const ss_array_size_struct, rather than ss_array_size_struct, so as to avoid Visual C++ (7.1)'s C4686 warning

Referenced by c_str_ptr_GUID_proxy::c_str_ptr_GUID_proxy(), stlsoft::format_bytes(), stlsoft::format_thousands(), invalid_integral_range_policy::operator()(), winstl::w4mo_helper_8(), winstl__control_panel_newinquire(), winstl__IsWindowClassA(), and winstl__IsWindowClassW().

#define stlsoft_raw_offsetof ( s,
 )     STLSOFT_RAW_OFFSETOF(s, m)

Evaluates, at compile time, the offset of a structure/class member.

Deprecated:
This is deprecated in favour of STLSOFT_RAW_OFFSETOF().
Note:
This is a simple #define for STLSOFT_RAW_OFFSETOF()

#define STLSOFT_RAW_OFFSETOF ( S,
 )     stlsoft_reinterpret_cast(stlsoft_ns_qual(ss_size_t), &stlsoft_static_cast(S*, 0)->M)

Evaluates, at compile time, the offset of the member m in the structure s.

Parameters:
S The type of the structure/class
M The name of the member

Referenced by auto_buffer< C, internalBufferSize, winstl::processheap_allocator< C > >::auto_buffer(), window_enable_scope::~window_enable_scope(), window_icon_scope::~window_icon_scope(), and window_visible_scope::~window_visible_scope().

#define STLSOFT_SUPPRESS_UNNAMED_PARAM (  )     ((void)p);

Used to suppress unused parameter warnings (in C compilation) for parameters defined by STLSOFT_UNNAMED_PARAM().

#define STLSOFT_SUPPRESS_UNUSED (  )     (static_cast<void>(x))

 
#define stlsoft_throw_0 (  ) 

Indicates that the given function/method does not throw any exceptions.

#define stlsoft_throw_1 ( x1   ) 

Indicates that the given function/method throws the named type.

#define stlsoft_throw_2 ( x1,
x2   ) 

Indicates that the given function/method throws the two named types.

#define stlsoft_throw_3 ( x1,
x2,
x3   ) 

Indicates that the given function/method throws the three named types.

#define stlsoft_throw_4 ( x1,
x2,
x3,
x4   ) 

Indicates that the given function/method throws the four named types.

#define stlsoft_throw_5 ( x1,
x2,
x3,
x4,
x5   ) 

Indicates that the given function/method throws the five named types.

#define stlsoft_throw_6 ( x1,
x2,
x3,
x4,
x5,
x6   ) 

Indicates that the given function/method throws the six named types.

#define stlsoft_throw_7 ( x1,
x2,
x3,
x4,
x5,
x6,
x7   ) 

Indicates that the given function/method throws the seven named types.

#define stlsoft_throw_8 ( x1,
x2,
x3,
x4,
x5,
x6,
x7,
x8   ) 

Indicates that the given function/method throws the eight named types.

#define STLSOFT_UNNAMED_PARAM (  )     p

Used to define an unused parameter for C compilation and/or documentation processing, but not for C++ compilation.


Generated on Thu Jun 10 08:58:21 2010 for STLSoft by  doxygen 1.5.6