STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ... ATLSTL - Template Software for the Active Template Library COMSTL - The Standard Template Library meets the Component Object Model .netSTL - Standard Template Library meets the Microsoft.NET Common Language Runtime InetSTL - The Standard Template Library meets WinInet MFCSTL - Template Software for the Microsoft Foundation Classes UNIXSTL - Template Software for the UNIX Operating System WinSTL - where the Standard Template Library meets the Win32 API

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Code Modification Macros
[STLSoft]

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

Defines

#define stlsoft_num_elements(ar)
 Evaluates, at compile time, to the number of elements within the given vector entity.

#define stlsoft_raw_offsetof(s, m)   offsetof(s, m)
 Evaluates, at compile time, the offset of a structure/class member.

#define stlsoft_destroy_instance(t, _type, p)   do { (p)->~t(); } while(0)
 Destroys the given instance p of the given type (t and _type).

#define stlsoft_gen_opaque(type)   typedef struct __stlsoft_htype##type{ int i;} const *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_GEN_TRAIT_SPECIALISATION(TR, T, V)
 Used to define a specialisation of a traits type.

#define STLSOFT_SUPPRESS_UNUSED(x)   ((void)x)
 Used to suppress unused variable warnings.


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.


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 t,
_type,
     do { (p)->~t(); } while(0)
 

Destroys the given instance p of the given type (t and _type).

#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:

stlsoft_gen_opaque(HThread)
stlsoft_gen_opaque(HProcess)

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_num_elements ar   
 

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

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.

#define stlsoft_raw_offsetof s,
     offsetof(s, m)
 

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

#define STLSOFT_SUPPRESS_UNUSED      ((void)x)
 

Used to suppress unused variable warnings.


STLSoft Libraries documentation © Synesis Software Pty Ltd, 2001-2004