You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

60 lines
1.5 KiB

  1. #pragma once
  2. #include <cpphibernate/misc.h>
  3. #include <cpphibernate/config.h>
  4. #include <cpphibernate/modifier/modifier.h>
  5. #include <cpphibernate/modifier/where/clauses/clause.h>
  6. beg_namespace_cpphibernate_modifier
  7. {
  8. namespace __impl
  9. {
  10. /* where_t */
  11. template<typename T_clause>
  12. struct where_t
  13. : public modifier_t
  14. {
  15. using clause_type = T_clause;
  16. clause_type clause;
  17. constexpr where_t(T_clause&& p_clause)
  18. : clause(std::forward<T_clause>(p_clause))
  19. { }
  20. };
  21. /* where_builder */
  22. template<typename X, typename = void>
  23. struct where_builder
  24. {
  25. template<typename... T_args>
  26. static constexpr decltype(auto) apply(T_args&&... args)
  27. { static_assert(sizeof...(args) == -1, "Invalid parameters for hibernate::modifier::where(...)!"); }
  28. };
  29. template<typename T_clause>
  30. struct where_builder<mp::list<T_clause>, mp::enable_if<is_where_clause<T_clause>>>
  31. {
  32. static constexpr decltype(auto) apply(T_clause&& clause)
  33. { return where_t<T_clause>(std::forward<T_clause>(clause)); }
  34. };
  35. }
  36. /* meta */
  37. template<typename T>
  38. struct is_where
  39. : public mp::is_specialization_of<T, __impl::where_t>
  40. { };
  41. /* make */
  42. constexpr decltype(auto) where = misc::make_generic_predicate<__impl::where_builder> { };
  43. }
  44. end_namespace_cpphibernate_modifier