Update FunctionTraits of HttpApiBinder

This commit is contained in:
antao 2018-08-29 18:26:36 +08:00
parent cea61c1530
commit 966dd2e30e
3 changed files with 7 additions and 3 deletions

View File

@ -1,7 +1,7 @@
#include "api_v1_ApiTest.h"
using namespace api::v1;
//add definition of your processing function here
void ApiTest::get(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)>&callback,int p1,std::string p2)
void ApiTest::get(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)>&callback,int p1,std::string &&p2)
{
HttpViewData data;
data.insert("title",std::string("ApiTest::get"));

View File

@ -15,7 +15,7 @@ namespace api
METHOD_LIST_END
//your declaration of processing function maybe like this:
void get(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)>&callback,int p1,std::string p2);
void get(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)>&callback,int p1,std::string &&p2);
void your_method_name(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)>&callback,double p1,int p2) const;
};
}

View File

@ -38,6 +38,10 @@ namespace drogon{
};
template <typename T>
struct BinderArgTypeTraits<T &&>{
static const bool isValid=true;
};
template <typename T>
struct BinderArgTypeTraits<const T &&>{
static const bool isValid=false;
};
template <typename T>
@ -108,7 +112,7 @@ namespace drogon{
{
//call this function recursively until parameter's count equals to the count of target function parameters
static_assert(BinderArgTypeTraits<nth_argument_type<sizeof...(Values)>>::isValid,
"your handler argument type must be value type or const left reference type"
"your handler argument type must be value type or const left reference type or right reference type"
);
typedef typename std::remove_cv<typename std::remove_reference<nth_argument_type<sizeof...(Values)>>::type>::type ValueType;
ValueType value=ValueType();