peerplays-fc/include/fc/utility.hpp
Daniel Larimer 3d56a96d4e major updates to stream,reflect,value,and json
- removed polymorphic reflection, made static_reflect default because
  there are cases such as deserializing an array that you need more
  information than the runtime reflection can provide such as the
  ability to resize arrays and know the array content type.

- refactored iostream, sstream, fstream to be much simpler, fewer
  indirections, and fixed getline.

- json parsing works using code from mace.
- value is reimplemented based upon mace::rpc::value and no longer uses
  the runtime reflection that was removed.

- moved the typename utility to its own header
2012-10-21 02:28:59 -04:00

46 lines
1.4 KiB
C++

#ifndef _FC_UTILITY_HPP_
#define _FC_UTILITY_HPP_
#include <stdint.h>
#include <new>
#define nullptr 0
typedef decltype(sizeof(int)) size_t;
namespace std {
typedef decltype(sizeof(int)) size_t;
}
namespace fc {
template<typename T> struct remove_reference { typedef T type; };
template<typename T> struct remove_reference<T&> { typedef T type; };
template<typename T> struct remove_reference<const T&> { typedef const T type; };
template<typename T> struct remove_reference<T&&> { typedef T type; };
template<typename T>
typename fc::remove_reference<T>::type&& move( T&& t ) { return static_cast<typename fc::remove_reference<T>::type&&>(t); }
template<typename T, typename U>
inline T&& forward( U&& u ) { return static_cast<T&&>(u); }
struct true_type { enum _value { value = 1 }; };
struct false_type { enum _value { value = 0 }; };
namespace detail {
template<typename T> fc::true_type is_class_helper(void(T::*)());
template<typename T> fc::false_type is_class_helper(...);
}
template<typename T>
struct is_class { typedef decltype(detail::is_class_helper<T>(0)) type; enum value_enum { value = type::value }; };
template<typename T>
const T& min( const T& a, const T& b ) { return a < b ? a: b; }
template<typename T>
void swap( T& a, T& b ) {
T tmp = fc::move(a);
a = fc::move(b);
b = fc::move(tmp);
}
}
#endif // _FC_UTILITY_HPP_