Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions hdr/sqlite_modern_cpp/utility/function_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,7 @@ namespace sqlite {
>
struct function_traits<
ReturnType(ClassType::*)(Arguments...) const
> {
typedef ReturnType result_type;

template <std::size_t Index>
using argument = typename std::tuple_element<
Index,
std::tuple<Arguments...>
>::type;

static const std::size_t arity = sizeof...(Arguments);
};
> : function_traits<ReturnType(*)(Arguments...)> { };

/* support the non-const operator ()
* this will work with user defined functors */
Expand All @@ -41,6 +31,14 @@ namespace sqlite {
>
struct function_traits<
ReturnType(ClassType::*)(Arguments...)
> : function_traits<ReturnType(*)(Arguments...)> { };

template <
typename ReturnType,
typename... Arguments
>
struct function_traits<
ReturnType(*)(Arguments...)
> {
typedef ReturnType result_type;

Expand Down
5 changes: 4 additions & 1 deletion tests/functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
using namespace sqlite;
using namespace std;

int add_integers(int i, int j) {
return i+j;
}
int main()
{
try
Expand All @@ -13,7 +16,7 @@ int main()

db.define("my_new_concat", [](std::string i, std::string j) {return i+j;});
db.define("my_new_concat", [](std::string i, std::string j, std::string k) {return i+j+k;});
db.define("add_integers", [](int i, int j) {return i+j;});
db.define("add_integers", &add_integers);
std::string test1, test3;
int test2 = 0;
db << "select my_new_concat('Hello ','world!')" >> test1;
Expand Down