strongdef: actually use tagging for disambiguation...

This commit is contained in:
Danny Robson 2015-11-19 15:06:23 +11:00
parent 37268d6215
commit 99d025af4d
3 changed files with 6 additions and 6 deletions

View File

@ -23,4 +23,4 @@ using util::strongdef;
// This instantiation is not meant to be exported, only being used as a local
// compilation error canary.
template struct util::strongdef<unsigned>;
template struct util::strongdef<unsigned,void>;

View File

@ -22,7 +22,7 @@
namespace util {
/// A transparent wrapper around a (typically lightweight) type for the
/// purposes of overload disambiguation. It acts like a typesafe typedef.
template <typename T>
template <typename T,typename Tag>
struct strongdef {
public:
using value_type = T;
@ -45,9 +45,9 @@ namespace util {
namespace std {
template <typename T>
struct numeric_limits<util::strongdef<T>> {
using value_type = typename util::strongdef<T>::value_type;
template <typename T, typename Tag>
struct numeric_limits<util::strongdef<T,Tag>> {
using value_type = typename util::strongdef<T,Tag>::value_type;
static constexpr bool is_specialized = numeric_limits<value_type>::is_specialized;
static constexpr bool is_signed = numeric_limits<value_type>::is_signed;

View File

@ -10,7 +10,7 @@ main (void)
util::TAP::logger tap;
// These tests are less about functional testing, and more about link testing.
strongdef<unsigned> fortytwo (42u);
strongdef<unsigned,void> fortytwo (42u);
tap.expect_eq (fortytwo.data, 42u, "raw data equality");
tap.expect_eq (fortytwo, 42u, "passthrough equality");