選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

64 行
2.0 KiB

  1. #pragma once
  2. #include "field.h"
  3. namespace cpphibernate {
  4. namespace mariadb {
  5. namespace __impl
  6. {
  7. /* fields_builder */
  8. template<typename X, typename>
  9. struct fields_builder
  10. {
  11. template<typename... T_args>
  12. static constexpr decltype(auto) apply(T_args&&... args)
  13. { static_assert(sizeof...(args) == -1, "Invalid parameters for mariadb::make_fields(...)!"); }
  14. };
  15. template<typename T_owner, typename T_schema, typename T_table>
  16. struct fields_builder<
  17. mp::list<T_owner, T_schema, T_table>,
  18. mp::enable_if_t<
  19. mp::is_same_v<table_t, mp::decay_t<T_owner>>
  20. && schema::is_schema_v<mp::decay_t<T_schema>>
  21. && schema::is_table_v<mp::decay_t<T_table>>>>
  22. {
  23. template<typename T_index>
  24. static constexpr void emplace(
  25. fields_t& result,
  26. const table_t& owner,
  27. const T_schema& schema,
  28. const T_table& table,
  29. T_index&& index)
  30. {
  31. result.emplace_back(make_field(owner, schema, table, table.fields[index]));
  32. }
  33. template<size_t... I>
  34. static auto helper(
  35. const table_t& owner,
  36. const T_schema& schema,
  37. const T_table& table,
  38. std::index_sequence<I...>&&)
  39. {
  40. fields_t ret;
  41. int dummy[] = { 0, (emplace(ret, owner, schema, table, hana::size_c<I>), void(), 0)... };
  42. (void) dummy;
  43. return ret;
  44. }
  45. static constexpr decltype(auto) apply(
  46. const table_t& owner, const T_schema& schema, const T_table& table)
  47. {
  48. using size = decltype(hana::size(table.fields));
  49. return helper(owner, schema, table, std::make_index_sequence<size::value> { });
  50. }
  51. };
  52. }
  53. } }