小编Jas*_*ice的帖子

使用PHP curl如何获得400响应的响应主体

我正在调用的api使用HTTP代码400返回验证错误的json对象.我使用PHP的curl库实现了客户端,但是在错误时curl_exec返回false.如何在出错时获取响应正文?

请注意,我正在设置 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

php curl

17
推荐指数
3
解决办法
8449
查看次数

为什么这个嵌套的lambda不被认为是constexpr?

我正在尝试使用嵌套的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)

c++ lambda metaprogramming boost-hana c++17

7
推荐指数
2
解决办法
982
查看次数

hana :: second不能推断出类型

我正在尝试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

c++ metaprogramming boost-hana

3
推荐指数
1
解决办法
143
查看次数

标签 统计

boost-hana ×2

c++ ×2

metaprogramming ×2

c++17 ×1

curl ×1

lambda ×1

php ×1