Update FunctionTraits of HttpApiBinder
This commit is contained in:
parent
cea61c1530
commit
966dd2e30e
|
@ -1,7 +1,7 @@
|
||||||
#include "api_v1_ApiTest.h"
|
#include "api_v1_ApiTest.h"
|
||||||
using namespace api::v1;
|
using namespace api::v1;
|
||||||
//add definition of your processing function here
|
//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;
|
HttpViewData data;
|
||||||
data.insert("title",std::string("ApiTest::get"));
|
data.insert("title",std::string("ApiTest::get"));
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace api
|
||||||
|
|
||||||
METHOD_LIST_END
|
METHOD_LIST_END
|
||||||
//your declaration of processing function maybe like this:
|
//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;
|
void your_method_name(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)>&callback,double p1,int p2) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,10 @@ namespace drogon{
|
||||||
};
|
};
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct BinderArgTypeTraits<T &&>{
|
struct BinderArgTypeTraits<T &&>{
|
||||||
|
static const bool isValid=true;
|
||||||
|
};
|
||||||
|
template <typename T>
|
||||||
|
struct BinderArgTypeTraits<const T &&>{
|
||||||
static const bool isValid=false;
|
static const bool isValid=false;
|
||||||
};
|
};
|
||||||
template <typename T>
|
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
|
//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,
|
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;
|
typedef typename std::remove_cv<typename std::remove_reference<nth_argument_type<sizeof...(Values)>>::type>::type ValueType;
|
||||||
ValueType value=ValueType();
|
ValueType value=ValueType();
|
||||||
|
|
Loading…
Reference in New Issue