Classes | Namespaces | Macros | Functions
TypesafePtr.h File Reference
#include "Exception.h"
#include <memory>
#include <iosfwd>
#include <map>
#include <utility>
#include <mutex>
#include <cstdio>
#include <array>
#include <cstring>
#include <type_traits>
#include <climits>
#include <initializer_list>

Classes

class  PLMD::TypesafePtr
 

Namespaces

 PLMD
 

Macros

#define __PLUMED_WRAPPER_TYPESAFEPTR(type, code, size)
 Macro that uses __PLUMED_WRAPPER_TYPESAFEPTR_INNER to generate constructors with all possible pointer-const combinations. More...
 
#define __PLUMED_WRAPPER_TYPESAFEPTR_EMPTY(type, code)   __PLUMED_WRAPPER_TYPESAFEPTR(type,code,0)
 Macro that generates the constructors from empy types (those of which sizeof cannot be computed) More...
 
#define __PLUMED_WRAPPER_TYPESAFEPTR_INNER(type, type_, flags_)
 Macro that generate a constructor with given type and flags. More...
 
#define __PLUMED_WRAPPER_TYPESAFEPTR_SIZED(type, code)
 Macro that generates the constructors from sized types (those of which sizeof can be computed). More...
 

Functions

template<class T >
std::size_t PLMD::typesafePtrSizeof ()
 
template<>
std::size_t PLMD::typesafePtrSizeof< const void > ()
 
template<>
std::size_t PLMD::typesafePtrSizeof< void > ()
 
static bool PLMD::typesafePtrSkipCheck ()
 

Macro Definition Documentation

◆ __PLUMED_WRAPPER_TYPESAFEPTR

#define __PLUMED_WRAPPER_TYPESAFEPTR (   type,
  code,
  size 
)
Value:
__PLUMED_WRAPPER_TYPESAFEPTR_INNER(type, type, size | (0x10000*(code)) | (0x2000000*2)) \
__PLUMED_WRAPPER_TYPESAFEPTR_INNER(type, type const, size | (0x10000*(code)) | (0x2000000*3)) \
__PLUMED_WRAPPER_TYPESAFEPTR_INNER(type*,type*, size | (0x10000*(code)) | (0x2000000*4)) \
__PLUMED_WRAPPER_TYPESAFEPTR_INNER(type*,type*const, size | (0x10000*(code)) | (0x2000000*5)) \
__PLUMED_WRAPPER_TYPESAFEPTR_INNER(type*,type const*, size | (0x10000*(code)) | (0x2000000*6)) \
__PLUMED_WRAPPER_TYPESAFEPTR_INNER(type*,type const*const, size | (0x10000*(code)) | (0x2000000*7))

Macro that uses __PLUMED_WRAPPER_TYPESAFEPTR_INNER to generate constructors with all possible pointer-const combinations.

◆ __PLUMED_WRAPPER_TYPESAFEPTR_EMPTY

#define __PLUMED_WRAPPER_TYPESAFEPTR_EMPTY (   type,
  code 
)    __PLUMED_WRAPPER_TYPESAFEPTR(type,code,0)

Macro that generates the constructors from empy types (those of which sizeof cannot be computed)

◆ __PLUMED_WRAPPER_TYPESAFEPTR_INNER

#define __PLUMED_WRAPPER_TYPESAFEPTR_INNER (   type,
  type_,
  flags_ 
)
Value:
TypesafePtr(type_*ptr, std::size_t nelem=0, const std::size_t* shape=nullptr) : \
ptr((void*)const_cast<type*>(ptr)), \
nelem(nelem), \
flags(flags_) \
{ \
init_shape(shape); \
buffer[0]='\0'; \
}

Macro that generate a constructor with given type and flags.

◆ __PLUMED_WRAPPER_TYPESAFEPTR_SIZED

#define __PLUMED_WRAPPER_TYPESAFEPTR_SIZED (   type,
  code 
)
Value:
__PLUMED_WRAPPER_TYPESAFEPTR(type,code,sizeof(type)) \
TypesafePtr(type val, std::size_t nelem=0, const std::size_t* shape=nullptr): \
nelem(1), \
flags(sizeof(type) | (0x10000*(code)) | (0x2000000*1)) \
{ \
plumed_assert(sizeof(type)<=32); \
ptr=&buffer[0]; \
flags=sizeof(type) | (0x10000*(code)) | (0x2000000*1); \
std::memcpy(&buffer[0],&val,sizeof(type)); \
init_shape(shape); \
}

Macro that generates the constructors from sized types (those of which sizeof can be computed).

In addition to generating constructors with all pointer types, it generates a constructor to allow pass-by-value

__PLUMED_WRAPPER_TYPESAFEPTR
#define __PLUMED_WRAPPER_TYPESAFEPTR(type, code, size)
Macro that uses __PLUMED_WRAPPER_TYPESAFEPTR_INNER to generate constructors with all possible pointer...
Definition: TypesafePtr.h:135
__PLUMED_WRAPPER_TYPESAFEPTR_INNER
#define __PLUMED_WRAPPER_TYPESAFEPTR_INNER(type, type_, flags_)
Macro that generate a constructor with given type and flags.
Definition: TypesafePtr.h:123
PLMD::lapack::val
double val
Definition: lapack.cpp:3556