#ifndef TINYSTL_TRAITS_H
#define TINYSTL_TRAITS_H
#include "new.h"
#if defined(__GNUC__) && defined(__is_pod)
# define TINYSTL_TRY_POD_OPTIMIZATION(t) __is_pod(t)
#elif defined(_MSC_VER)
# define TINYSTL_TRY_POD_OPTIMIZATION(t) (!__is_class(t) || __is_pod(t))
#else
# define TINYSTL_TRY_POD_OPTIMIZATION(t) false
#endif
namespace tinystl {
template<typename T, bool pod = TINYSTL_TRY_POD_OPTIMIZATION(T)> struct pod_traits {};
template<typename T, T t> struct swap_holder;
template<typename T>
static inline void move_impl(T& a, T& b, ...) {
a = b;
}
template<typename T>
static inline void move_impl(T& a, T& b, T*, swap_holder<void (T::*)(T&), &T::swap>* = 0) {
a.swap(b);
}
template<typename T>
static inline void move(T& a, T&b) {
move_impl(a, b, (T*)0);
}
template<typename T>
static inline void move_construct_impl(T* a, T& b, ...) {
new(placeholder(), a) T(b);
}
template<typename T>
static inline void move_construct_impl(T* a, T& b, void*, swap_holder<void (T::*)(T&), &T::swap>* = 0) {
new(placeholder(), a) T;
a->swap(b);
}
template<typename T>
static inline void move_construct_impl(T* a, T& b, T*, typename T::tinystl_nomove_construct* = 0) {
new(placeholder(), a) T(b);
}
template<typename T>
static inline void move_construct(T* a, T& b) {
move_construct_impl(a, b, (T*)0);
}
}
#endif