Skip to content

Instantly share code, notes, and snippets.

View mjschutz's full-sized avatar
🏠
Working from home

Mauro Joel Schütz mjschutz

🏠
Working from home
View GitHub Profile
@mjschutz
mjschutz / NoPtrType.cpp
Created October 29, 2015 17:19
Class to manipulate type or pointer type as a non-pointer value without using std::remove_reference with release if pointer type
template <typename Tp>
struct NoPtrType {
typedef Tp noref_type;
static inline Tp read(Tp value) { return value; }
static inline Tp write(Tp& value, noref_type const& in_value) { value = in_value; return in_value; }
static inline void release_if_pointer(Tp const&) {}
};
template <typename Tp>
struct NoPtrType<Tp*> {