Navigation Menu

Skip to content

Commit

Permalink
Disable unused traits.
Browse files Browse the repository at this point in the history
These traits are not compilable with g++-4.7.
  • Loading branch information
s-yata committed Jun 5, 2013
1 parent 7fbf787 commit aaf6e61
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 52 deletions.
74 changes: 37 additions & 37 deletions lib/grnxx/traits.hpp
Expand Up @@ -37,51 +37,51 @@ template <> struct PreferredArgument<GeoPoint> {
using Type = GeoPoint;
};

// Check if operator<() is defined or not.
struct HasLessHelper {
template <typename T>
static auto check(T *p) -> decltype(p->operator<(*p), std::true_type());
template <typename T>
static auto check(T *p) -> decltype(operator<(*p, *p), std::true_type());
template <typename>
static auto check(...) -> decltype(std::false_type());
};
// Check if T has operator<() or not.
template <typename T>
struct HasLess {
static constexpr bool value() {
return std::conditional<std::is_scalar<T>::value, std::true_type,
decltype(HasLessHelper::check<T>(0))>::type::value;
}
};
//// Check if operator<() is defined or not.
//struct HasLessHelper {
// template <typename T>
// static auto check(T *p) -> decltype(p->operator<(*p), std::true_type());
// template <typename T>
// static auto check(T *p) -> decltype(operator<(*p, *p), std::true_type());
// template <typename>
// static auto check(...) -> decltype(std::false_type());
//};
//// Check if T has operator<() or not.
//template <typename T>
//struct HasLess {
// static constexpr bool value() {
// return std::conditional<std::is_scalar<T>::value, std::true_type,
// decltype(HasLessHelper::check<T>(0))>::type::value;
// }
//};

// Check if T has starts_with() or not.
struct HasStartsWithHelper {
template <typename T>
static auto check(T *p) -> decltype(p->starts_with(*p), std::true_type());
template <typename>
static auto check(...) -> decltype(std::false_type());
};
// Check if T has operator<() or not.
template <typename T>
struct HasStartsWith {
static constexpr bool value() {
return decltype(HasStartsWithHelper::check<T>(0))::value;
}
};
//// Check if T has starts_with() or not.
//struct HasStartsWithHelper {
// template <typename T>
// static auto check(T *p) -> decltype(p->starts_with(*p), std::true_type());
// template <typename>
// static auto check(...) -> decltype(std::false_type());
//};
//// Check if T has operator<() or not.
//template <typename T>
//struct HasStartsWith {
// static constexpr bool value() {
// return decltype(HasStartsWithHelper::check<T>(0))::value;
// }
//};

// Type traits.
template <typename T>
struct Traits {
using Type = T;
using ArgumentType = typename PreferredArgument<T>::Type;

static constexpr bool has_less() {
return HasLess<T>::value();
}
static constexpr bool has_starts_with() {
return HasStartsWith<T>::value();
}
// static constexpr bool has_less() {
// return HasLess<T>::value();
// }
// static constexpr bool has_starts_with() {
// return HasStartsWith<T>::value();
// }
};

} // namespace grnxx
Expand Down
30 changes: 15 additions & 15 deletions test/test_traits.cpp
Expand Up @@ -55,19 +55,19 @@ void test_argument_type() {
typename grnxx::Traits<Point>::ArgumentType>::value));
}

void test_has_less() {
assert(grnxx::Traits<int>::has_less());
assert(!grnxx::Traits<Point>::has_less());
assert(grnxx::Traits<Something>::has_less());
assert(grnxx::Traits<Something2>::has_less());
}

void test_has_starts_with() {
assert(!grnxx::Traits<int>::has_starts_with());
assert(!grnxx::Traits<Point>::has_starts_with());
assert(grnxx::Traits<Something>::has_starts_with());
assert(!grnxx::Traits<Something2>::has_starts_with());
}
//void test_has_less() {
// assert(grnxx::Traits<int>::has_less());
// assert(!grnxx::Traits<Point>::has_less());
// assert(grnxx::Traits<Something>::has_less());
// assert(grnxx::Traits<Something2>::has_less());
//}

//void test_has_starts_with() {
// assert(!grnxx::Traits<int>::has_starts_with());
// assert(!grnxx::Traits<Point>::has_starts_with());
// assert(grnxx::Traits<Something>::has_starts_with());
// assert(!grnxx::Traits<Something2>::has_starts_with());
//}

} // namespace

Expand All @@ -78,8 +78,8 @@ int main() {

test_type();
test_argument_type();
test_has_less();
test_has_starts_with();
// test_has_less();
// test_has_starts_with();

return 0;
}

0 comments on commit aaf6e61

Please sign in to comment.