Developer FAQs

Developer Questions And Answers

×
MENU
  • Languages
  • Web
  • Database
HomestdvectorPosts
Deleting raw pointers from std::vector Languages

Deleting raw pointers from std::vector

I have following pattern:Pseudo code:I'm unable to come up with some nice clean code for this.This link provides different approaches, but they all look more or less cumbersome to me.
02月10日 发表评论
Read More
What is the memory layout of vector of arrays? Languages

What is the memory layout of vector of arrays?

can anybody explaine the memory layout ofdoes it provide contiguous memory block of a 2D array with 2 rows of 5 elements?
01月14日 发表评论
Read More
Copy std::map into std::vector of pairs Languages

Copy std::map into std::vector of pairs

I'm trying to copy a map into a vector of pair, so I can then sort the vector by the second data member of the pairs. I have resolved this doing like this:
12月19日 发表评论
Read More
c++ float* array as reference to std::vector<float> Languages

c++ float* array as reference to std::vector<float>

I want to create a std::vector<float> vpd which will be a reference to float*.How should I modify the code, if I want get 23 from cout?
11月21日 发表评论
Read More
How to write a function that can take in an array or a vector? Languages

How to write a function that can take in an array or a vector?

I would like to write a C++ function with one argument such that one can pass in either any of the following types:
11月11日 发表评论
Read More
Why is this function producing incorrect values? Languages

Why is this function producing incorrect values?

I have a simple function template to calculate the average value of a container:I added in the static_cast<>s above to try to force the calculation to the desired type <T>.
11月07日 发表评论
Read More
Will a std::vector's capacity ever be reduced? Languages

Will a std::vector's capacity ever be reduced?

C++14 final working draft makes the following comment about std::vector:Storage management is handled automatically, though hints can be given to improve efficiency.
10月15日 发表评论
Read More
Can STL algorithms and back_inserter preallocate space? Languages

Can STL algorithms and back_inserter preallocate space?

If I have something like:Would STL be able to preallocate space in newVector before processing and adding the new elements? I know it is not a requirement of the algorithm, but would a "good" implementation be able to optimize that? Or, for this kind of case, should I prefer adding...
09月25日 发表评论
Read More
Avoid Conversion from single element vector to primitive type Languages

Avoid Conversion from single element vector to primitive type

I have a problem with constant single element std::vector when pass through a function. C++ compiler automatically call wrong function when the std::vector variable contain a single element. This is though the policy of C++ design. However is there any explicit method to specify in such a case. Here are...
07月17日 发表评论
Read More
Why does emplace_back(“Hello”) call strlen? Languages

Why does emplace_back(“Hello”) call strlen?

Justin's answer on another question made an observation that I find very interesting but can't quite explain. Consider the following code:
07月07日 发表评论
Read More

Posts navigation

第 1 页 第 2 页
Copyright ©  Developerfaqs  All Rights Reserved.

登录 找回密码

输入用户名或电子邮箱地址,您会收到一封新密码链接的电子邮件。

  • 文章目录
  • icon