This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/smc/ParticleAssertions.h
2017-11-15 17:46:06 +01:00

70 lines
1.4 KiB
C++

#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