[Groonga-commit] groonga/grnxx at 55ff92b [master] Add has_starts_with().

Back to archive index

susumu.yata null+****@clear*****
Wed May 15 13:04:31 JST 2013


susumu.yata	2013-05-15 13:04:31 +0900 (Wed, 15 May 2013)

  New Revision: 55ff92b1684ad4c741fb27bf56cce484a0d34219
  https://github.com/groonga/grnxx/commit/55ff92b1684ad4c741fb27bf56cce484a0d34219

  Message:
    Add has_starts_with().

  Modified files:
    lib/grnxx/traits.hpp

  Modified: lib/grnxx/traits.hpp (+21 -1)
===================================================================
--- lib/grnxx/traits.hpp    2013-05-15 13:04:11 +0900 (f7cec8e)
+++ lib/grnxx/traits.hpp    2013-05-15 13:04:31 +0900 (e7570c2)
@@ -51,7 +51,23 @@ 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))>::value;
+                            decltype(HasLessHelper::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 std::conditional<std::is_scalar<T>::value, std::true_type,
+                            decltype(HasStartsWithHelper::check<T>(0))>::value;
   }
 };
 
@@ -60,9 +76,13 @@ template <typename T>
 struct Traits {
   using Type = T;
   using ArgumentType = typename PreferredArgument<T>::Type;
+
   static constexpr bool hass_less() {
     return HasLess<T>::value();
   }
+  static constexpr bool has_starts_with() {
+    return HasStartsWith<T>::value();
+  }
 };
 
 }  // namespace grnxx
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index