Skip to content

Instantly share code, notes, and snippets.

@daniel-j-h
Created February 20, 2017 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniel-j-h/51d85effc4f625c6e589cd27511ffd71 to your computer and use it in GitHub Desktop.
Save daniel-j-h/51d85effc4f625c6e589cd27511ffd71 to your computer and use it in GitHub Desktop.
Newtypes
#include <type_traits>
template <typename T, typename Tag> struct NewType {
struct Type : T { using T::T; };
};
using CostMatrix = NewType<Matrix<std::int64_t>, struct CostMatrixTag>::Type;
using TimeMatrix = NewType<Matrix<std::int64_t>, struct TimeMatrixTag>::Type;
static_assert(!std::is_same<CostMatrix, TimeMatrix>::value, "NewType not working");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment