69
smc/ParticleAssertions.h
Normal file
69
smc/ParticleAssertions.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#ifndef PARTICLEASSERTIONS_H
|
||||
#define PARTICLEASSERTIONS_H
|
||||
|
||||
namespace SMC {
|
||||
|
||||
/** check whether T provides a += operator */
|
||||
template <typename T>
|
||||
class HasOperatorPlusEq {
|
||||
|
||||
typedef char one;
|
||||
typedef long two;
|
||||
|
||||
template <typename C> static one test( decltype(&C::operator+=) ) ;
|
||||
template <typename C> static two test(...);
|
||||
|
||||
public:
|
||||
enum { value = sizeof(test<T>(0)) == sizeof(one) };
|
||||
|
||||
};
|
||||
|
||||
/** check whether T provides a /= operator */
|
||||
template <typename T>
|
||||
class HasOperatorDivEq {
|
||||
|
||||
typedef char one;
|
||||
typedef long two;
|
||||
|
||||
template <typename C> static one test( decltype(&C::operator/=) ) ;
|
||||
template <typename C> static two test(...);
|
||||
|
||||
public:
|
||||
enum { value = sizeof(test<T>(0)) == sizeof(one) };
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** check whether T provides a * operator */
|
||||
template <typename T>
|
||||
class HasOperatorMul {
|
||||
|
||||
typedef char one;
|
||||
typedef long two;
|
||||
|
||||
template <typename C> static one test( decltype(&C::operator*) ) ;
|
||||
template <typename C> static two test(...);
|
||||
|
||||
public:
|
||||
enum { value = sizeof(test<T>(0)) == sizeof(one) };
|
||||
|
||||
};
|
||||
|
||||
/** check whether T provides an assignment operator */
|
||||
template <typename T>
|
||||
class HasOperatorAssign{
|
||||
|
||||
typedef char one;
|
||||
typedef long two;
|
||||
|
||||
template <typename C> static one test( decltype(&C::operator=) ) ;
|
||||
template <typename C> static two test(...);
|
||||
|
||||
public:
|
||||
enum { value = sizeof(test<T>(0)) == sizeof(one) };
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // PARTICLEASSERTIONS_H
|
||||
Reference in New Issue
Block a user