Created
February 20, 2017 14:33
-
-
Save daniel-j-h/51d85effc4f625c6e589cd27511ffd71 to your computer and use it in GitHub Desktop.
Newtypes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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