草庐IT

certbot-auto

全部标签

c++ - 数组的 auto_ptr

简而言之,我想知道数组是否有类似auto_ptr的类型。我知道我可以自己推出,我只是确保那里没有什么东西。我也知道vector。但是我不认为我可以使用它们。我正在使用几个WindowsAPI/SDK,例如WindowsMediaSDK、DirectShowAPI,它们是为了取回一些结构来调用一个函数,该函数需要一个指针和一个大小两次。第一次传递NULL作为指针来取回我必须分配的结构的大小,以便接收我正在寻找的数据。例如:CComQIPtrpProps(m_pStreamConfig);DWORDcbType=0;WM_MEDIA_TYPE*pType=NULL;hr=pProps->G

c++ - 数组的 auto_ptr

简而言之,我想知道数组是否有类似auto_ptr的类型。我知道我可以自己推出,我只是确保那里没有什么东西。我也知道vector。但是我不认为我可以使用它们。我正在使用几个WindowsAPI/SDK,例如WindowsMediaSDK、DirectShowAPI,它们是为了取回一些结构来调用一个函数,该函数需要一个指针和一个大小两次。第一次传递NULL作为指针来取回我必须分配的结构的大小,以便接收我正在寻找的数据。例如:CComQIPtrpProps(m_pStreamConfig);DWORDcbType=0;WM_MEDIA_TYPE*pType=NULL;hr=pProps->G

c++ - auto 和 decltype 的关系

是autox=initializer;相当于decltype(initializer)x=initializer;或decltype((initializer))x=initializer;或者两者都没有? 最佳答案 decltype还考虑表达式是rvalue还是lvalue。Wikipediasays,Thetypedenotedbydecltypecanbedifferentfromthetypededucedbyauto.#includeintmain(){conststd::vectorv(1);autoa=v[0];//a

c++ - auto 和 decltype 的关系

是autox=initializer;相当于decltype(initializer)x=initializer;或decltype((initializer))x=initializer;或者两者都没有? 最佳答案 decltype还考虑表达式是rvalue还是lvalue。Wikipediasays,Thetypedenotedbydecltypecanbedifferentfromthetypededucedbyauto.#includeintmain(){conststd::vectorv(1);autoa=v[0];//a

c++ - auto&& 是做什么的?

这是来自ScottMeyers的C++11NotesSample的代码,intx;auto&&a1=x;//xislvalue,sotypeofa1isint&auto&&a2=std::move(x);//std::move(x)isrvalue,sotypeofa2isint&&我无法理解auto&&。我对auto有一些了解,从中我会说auto&a1=x应该将a1的类型设为int&引用的代码中的哪个似乎是错误的。我写了这个小代码,并在gcc下运行。#includeusingnamespacestd;intmain(){intx=4;auto&a1=x;//line8cout输出=4

c++ - auto&& 是做什么的?

这是来自ScottMeyers的C++11NotesSample的代码,intx;auto&&a1=x;//xislvalue,sotypeofa1isint&auto&&a2=std::move(x);//std::move(x)isrvalue,sotypeofa2isint&&我无法理解auto&&。我对auto有一些了解,从中我会说auto&a1=x应该将a1的类型设为int&引用的代码中的哪个似乎是错误的。我写了这个小代码,并在gcc下运行。#includeusingnamespacestd;intmain(){intx=4;auto&a1=x;//line8cout输出=4

c++ - 在 lambda 函数中使用 auto

#include#includevoidfoo(int){}intmain(){std::vectorv({1,2,3});std::for_each(v.begin(),v.end(),[](autoit){foo(it+5);});}编译后,上面的例子开始错误输出是这样的:h4.cpp:Infunction'intmain()':h4.cpp:13:47:error:parameterdeclared'auto'h4.cpp:Inlambdafunction:h4.cpp:13:59:error:'it'wasnotdeclaredinthisscope这是否意味着关键字auto不

c++ - 在 lambda 函数中使用 auto

#include#includevoidfoo(int){}intmain(){std::vectorv({1,2,3});std::for_each(v.begin(),v.end(),[](autoit){foo(it+5);});}编译后,上面的例子开始错误输出是这样的:h4.cpp:Infunction'intmain()':h4.cpp:13:47:error:parameterdeclared'auto'h4.cpp:Inlambdafunction:h4.cpp:13:59:error:'it'wasnotdeclaredinthisscope这是否意味着关键字auto不

c++ - 如何使用 auto 获得 const_iterator?

第一个问题:是否可以“强制”const_iterator使用汽车?例如:std::mapusa;//...initusaautocity_it=usa.find("NewYork");我只想查询,而不是更改city_it所指向的任何内容,所以我想要city_it成为map::const_iterator.但是通过使用自动,city_it与map::find()的返回类型相同,即map::iterator.有什么建议吗? 最佳答案 抱歉,但我认为最好的建议是不完全不使用auto,因为您想要执行(隐式有效的)类型转换。auto用于推断e

c++ - 如何使用 auto 获得 const_iterator?

第一个问题:是否可以“强制”const_iterator使用汽车?例如:std::mapusa;//...initusaautocity_it=usa.find("NewYork");我只想查询,而不是更改city_it所指向的任何内容,所以我想要city_it成为map::const_iterator.但是通过使用自动,city_it与map::find()的返回类型相同,即map::iterator.有什么建议吗? 最佳答案 抱歉,但我认为最好的建议是不完全不使用auto,因为您想要执行(隐式有效的)类型转换。auto用于推断e