Solved

standard vector header C++

Posted on 2016-08-29
11
36 Views
Last Modified: 2016-11-28
Hi

Where is the best place to grab an uptodate standard vector header?
0
Comment
Question by:LuckyLucks
  • 3
  • 3
  • 3
  • +2
11 Comments
 
LVL 28

Expert Comment

by:pepr
ID: 41775426
This is a part of implementation of the Standard Library that comes with the compiler, so...

#include <vector>

Open in new window


For Visual C++, get the Visual Studio 2015 Community Edition plus the updates.
0
 

Author Comment

by:LuckyLucks
ID: 41775565
I have some projects have their own vector.h . So why do they do that? Are compiler specific headers a bad/non-portable thing?
0
 
LVL 8

Expert Comment

by:Subrat (C++ windows/Linux)
ID: 41775725
vector belongs to std namespace which is the latest one So as suggested by other expert use vector not vector. h which was older one and not in std namespace. Hopefully  you will get deprecated warning if using vector. h
0
 
LVL 32

Expert Comment

by:phoffric
ID: 41775748
In the debuggers that I have worked with, when you construct the vector or do other vector operations, you can step into the constructor. Then you will see and be able to copy the vector header file. Some debuggers may give you the folder location so that you can find the vector file, as well as other standard lib headers.
0
 
LVL 28

Expert Comment

by:pepr
ID: 41775813
It was the time when the Standard library was not that much standard, or when there were better implementations by third parties.

Notice also, that even already quite old C++ does not use .h extension for the standard library headers. If you have Visual Studio, you can find the vector header in "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\vector" (here for Visual Studio 2015).

In cases when there is also a C header available--like assert.h--the C++ code should use #include <cassert> wrapper instead. You should not see any .h extension for the standard headers.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:LuckyLucks
ID: 41777355
@phoffric:

That is a good idea - to step into and find the src vector file.

But there is no "best policy"/ standard as to where to grab it from ? For example, if i wanted the glew headers, i would go to http://glew.sourceforge.net/ . Nothing like that for vector ?
0
 
LVL 32

Accepted Solution

by:
phoffric earned 250 total points
ID: 41777524
>> But there is no "best policy"/ standard as to where to grab it from ? For example, if i wanted the glew headers, i would go to http://glew.sourceforge.net/ . Nothing like that for vector ?

If all header files from all vendors were the same, I could see having a central repository. While they define the standard library required api's, there are implementation details that may differ significantly.

When I had to search for the valarray header, I went to the Intel compiler root directory, and did a general find operation. I can tell you that the Intel valarray implementation has to be very different than the g++ version.

If all you wanted was the api, then there are references that provide you with what is necessary for using the api in an ordinary way. For example:
http://www.cplusplus.com/reference/vector/vector/?kw=vector
1
 
LVL 28

Assisted Solution

by:pepr
pepr earned 250 total points
ID: 41777568
To add an illustration to the above phoffric's comment. The later C++ standard introduced rvalue references and the move semantics (C++11; for example here). This way a programmer can tell better the intention to the compiler and the resulting code is faster. When the compiler implements the feature, it can use it also for implementation of the standard libraries that come with the compiler. Say, the vector implementation becomes more efficient. If the third party vector does not use that feature, you can use it but it will be less efficient. On the other hand, you cannot use that newer implementation of the vector with older compilers that do not implement the feature.

The above description considers only the standard features. However, a compiler can use implementation details that are not prescribed by the C++ Standard. Then it may be possible to implement the std::vector even more efficiently. But then it it cannot be used for another compiler.

The Standard Library should be as efficient as it could be. This is the reason why you should prefer the one that comes with the compiler.
0
 

Author Comment

by:LuckyLucks
ID: 41824066
accepting pepr+phoffric solutions.
0
 
LVL 32

Expert Comment

by:phoffric
ID: 41831978
Glad we could clarify this.
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 41903859
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- phoffric (https:#a41777524)
-- pepr (https:#a41777568)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now