~singpolyma/biboumi

5834dd53f32ff89f5818681a93e416b0a48b6254 — louiz’ 7 years ago 49bb28c
Add a 0 default value for template argument N
M src/database/insert_query.hpp => src/database/insert_query.hpp +9 -9
@@ 53,13 53,13 @@ struct InsertQuery: public Query
  {
    auto statement = this->prepare(db);
    {
      this->bind_param<0>(columns, statement);
      this->bind_param(columns, statement);
      if (sqlite3_step(statement.get()) != SQLITE_DONE)
        log_error("Failed to execute query: ", sqlite3_errmsg(db));
    }
  }

  template <int N, typename... T>
  template <int N=0, typename... T>
  typename std::enable_if<N < sizeof...(T), void>::type
  bind_param(const std::tuple<T...>& columns, Statement& statement)
  {


@@ 69,7 69,7 @@ struct InsertQuery: public Query
    this->bind_param<N+1>(columns, statement);
  }

  template <int N, typename... T>
  template <int N=0, typename... T>
  typename std::enable_if<N == sizeof...(T), void>::type
  bind_param(const std::tuple<T...>&, Statement&)
  {}


@@ 78,11 78,11 @@ struct InsertQuery: public Query
  void insert_values(const std::tuple<T...>& columns)
  {
    this->body += "VALUES (";
    this->insert_value<0>(columns);
    this->insert_value(columns);
    this->body += ")";
  }

  template <int N, typename... T>
  template <int N=0, typename... T>
  typename std::enable_if<N < sizeof...(T), void>::type
  insert_value(const std::tuple<T...>& columns)
  {


@@ 93,7 93,7 @@ struct InsertQuery: public Query
    add_param(*this, std::get<N>(columns));
    this->insert_value<N+1>(columns);
  }
  template <int N, typename... T>
  template <int N=0, typename... T>
  typename std::enable_if<N == sizeof...(T), void>::type
  insert_value(const std::tuple<T...>&)
  { }


@@ 102,11 102,11 @@ struct InsertQuery: public Query
  void insert_col_names(const std::tuple<T...>& columns)
  {
    this->body += " (";
    this->insert_col_name<0>(columns);
    this->insert_col_name(columns);
    this->body += ")\n";
  }

  template <int N, typename... T>
  template <int N=0, typename... T>
  typename std::enable_if<N < sizeof...(T), void>::type
  insert_col_name(const std::tuple<T...>& columns)
  {


@@ 119,7 119,7 @@ struct InsertQuery: public Query

    this->insert_col_name<N+1>(columns);
  }
  template <int N, typename... T>
  template <int N=0, typename... T>
  typename std::enable_if<N == sizeof...(T), void>::type
  insert_col_name(const std::tuple<T...>&)
  {}

M src/database/row.hpp => src/database/row.hpp +3 -3
@@ 23,7 23,7 @@ update_id(std::tuple<T...>& columns, sqlite3* db)
  column.value = static_cast<Id::real_type>(res);
}

template <std::size_t N, typename... T>
template <std::size_t N=0, typename... T>
typename std::enable_if<N < sizeof...(T), void>::type
update_autoincrement_id(std::tuple<T...>& columns, sqlite3* db)
{


@@ 32,7 32,7 @@ update_autoincrement_id(std::tuple<T...>& columns, sqlite3* db)
  update_autoincrement_id<N+1>(columns, db);
}

template <std::size_t N, typename... T>
template <std::size_t N=0, typename... T>
typename std::enable_if<N == sizeof...(T), void>::type
update_autoincrement_id(std::tuple<T...>&, sqlite3*)
{}


@@ 67,7 67,7 @@ struct Row

      query.execute(this->columns, db);

      update_autoincrement_id<0>(this->columns, db);
      update_autoincrement_id(this->columns, db);
    }

    std::tuple<T...> columns;

M src/database/select_query.hpp => src/database/select_query.hpp +3 -3
@@ 53,11 53,11 @@ struct SelectQuery: public Query
        Query("SELECT"),
        table_name(table_name)
    {
      this->insert_col_name<0>();
      this->insert_col_name();
      this->body += " from " + this->table_name;
    }

    template <std::size_t N>
    template <std::size_t N=0>
    typename std::enable_if<N < sizeof...(T), void>::type
    insert_col_name()
    {


@@ 71,7 71,7 @@ struct SelectQuery: public Query

      this->insert_col_name<N+1>();
    }
    template <std::size_t N>
    template <std::size_t N=0>
    typename std::enable_if<N == sizeof...(T), void>::type
    insert_col_name()
    {}

M src/database/table.hpp => src/database/table.hpp +3 -3
@@ 26,7 26,7 @@ class Table
    std::string res{"CREATE TABLE IF NOT EXISTS "};
    res += this->name;
    res += " (\n";
    this->add_column_create<0>(res);
    this->add_column_create(res);
    res += ")";

    log_debug(res);


@@ 58,7 58,7 @@ class Table
  }

 private:
  template <std::size_t N>
  template <std::size_t N=0>
  typename std::enable_if<N < sizeof...(T), void>::type
  add_column_create(std::string& str)
  {


@@ 75,7 75,7 @@ class Table
    add_column_create<N+1>(str);
  }

  template <std::size_t N>
  template <std::size_t N=0>
  typename std::enable_if<N == sizeof...(T), void>::type
  add_column_create(std::string&)
  { }