我正在调用的api使用HTTP代码400返回验证错误的json对象.我使用PHP的curl库实现了客户端,但是在错误时curl_exec返回false.如何在出错时获取响应正文?
请注意,我正在设置 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
我正在尝试使用嵌套的constexpr lambdas创建一个curried接口,但编译器不认为它是一个常量表达式.
namespace hana = boost::hana;
using namespace hana::literals;
struct C1 {};
template < typename T,
std::size_t size >
struct Array {};
constexpr auto array_ = [] (auto size) {
return [=] (auto type) {
return hana::type_c<Array<typename decltype(type)::type, size()>>;
};
};
int main() {
constexpr auto c1 = hana::type_c<C1>;
constexpr auto test = hana::type_c<Array<typename decltype(c1)::type, hana::size_c<100>()>>;
constexpr auto test2 = array_(hana::size_c<100>)(c1);
}
Run Code Online (Sandbox Code Playgroud)
我之前发布了一个问题,因为我找到了一个不同的最小例子,但这还不够.
错误:
test2.cpp: In instantiation of ‘<lambda(auto:1)>::<lambda(auto:2)> [with auto:2 = boost::hana::type_impl<C1>::_; auto:1 = boost::hana::integral_constant<long unsigned int, 100>]’:
test2.cpp:31:54: …Run Code Online (Sandbox Code Playgroud) 我正在尝试hana::type使用一对来访问hana::second...
namespace hana = boost::hana;
using namespace hana::literals;
struct Key {};
struct Foo {};
int main() {
auto test = hana::make_tuple(
hana::make_pair(
hana::type_c<Key>,
hana::type_c<Foo>));
typename decltype(hana::type_c<Foo>)::type finalTest; //Ok
typename decltype(hana::second(test[0_c]))::type finalTest2; //Error
}
Run Code Online (Sandbox Code Playgroud)
但是我收到以下编译器错误:
stacktest.cpp: In function ‘int main()’:
stacktest.cpp:17:12: error: decltype evaluates to ‘boost::hana::type_impl<Foo>::_&’, which is not a class or enumeration type
typename decltype(hana::second(test[0_c]))::type finalTest2;
Run Code Online (Sandbox Code Playgroud)
为什么不按预期hana::second返回包含的结果hana::type?