Click here to Skip to main content
15,879,535 members
Everything / STL

STL

STL

Great Reads

by Thorsten Ottosen
Are you tired of filling data manually into STL containers? With the Initialization Library it gets a lot easier.
by Shmuel Zang
This article shows how we can implement a thread-safe events (similar to .NET events) mechanism using the standard C++ library.
by JadBenAutho
Efficient and standalone library for NTP server/client utilizing pure C++
by Michael Dunn
Create custom tasks in your app's jump list on Windows 7

Latest Articles

by JadBenAutho
Efficient and standalone library for NTP server/client utilizing pure C++
by Vadim Stadnik
Simple and useful alternative to traditional memory pool
by Steffen Ploetz
Is LINQ the right technology for processing large amounts of data in runtime-relevant environments?
by honey the codewitch
std::chrono doesn't work on the Teensy? Oh no! Here's how to fix it.

All Articles

Sort by Score

STL 

25 Nov 2004 by Thorsten Ottosen
Are you tired of filling data manually into STL containers? With the Initialization Library it gets a lot easier.
13 Aug 2018 by Shmuel Zang
This article shows how we can implement a thread-safe events (similar to .NET events) mechanism using the standard C++ library.
25 Sep 2008 by Rajesh R Subramanian
Of all your questions I've attempted, this is the toughest one, Christian.First off, .NET and C++ (I will say only C++ in this message. But, When I say C++, include the frameworks and libraries built on and around it - MFC, ATL, WTL, etc.,) are...
2 Mar 2024 by JadBenAutho
Efficient and standalone library for NTP server/client utilizing pure C++
29 Jun 2009 by Michael Dunn
Create custom tasks in your app's jump list on Windows 7
25 Oct 2000 by Jim Crafton
An Article describing working with the Visual Component Framework
28 Sep 2002 by Matthijs Hollemans
A shell extension to allow you to select files based on a wildcard search
14 Dec 2008 by Roy, Philippe
An article on improving STL containers to cache to disk in order to lift memory limitation issues.
26 Nov 2009 by Stuart Dootson
From what I can tell, the C++ stream system presumes that files are sequences of bytes, not characters - even when you use wide streams - the 'wide' part of wide stream (AFAICT) indicates how the stream object interacts with C++, not the underlying file or whatever. Thus, your codecvt facet has to t
26 May 2020 by stefan stammberger
A novel allocator implementation for managing huge sets of data in STL's std:: containers for Windows operating systems
26 Nov 2009 by John R. Shaw
The problem is that utf16_codecvt methods never get called and, therefore, the result is wrong. I have search the net, but all I can find is examples of what is supposed to work. Unfortunately none of them has worked. I have also seen other posters, on the net, with the same problem, but no one gave
13 Aug 2009 by Stuart Dootson
The way I'd approach it is like this:1. Define functions that return random voewls and random consonants - here's a random vowel function:char RandomVowel(){ const char vowels[] = {'a', 'e', 'i', 'o', 'u'}; // Use rand() to get a number...
1 Sep 2009 by PARK Youngho
A tool that enumerates all fonts installed on Windows, and shows you the preview so as to help you code conveniently.
12 Oct 2009 by Jörgen Sigvardsson
In addition to what Stuart said, if you really don't want to change the function signature from floatto double, you can always use literals that are typed as float. If you add the suffix f to the floating point numbers, they will be typed float.Your examples would then be function(1.2f, 2f) and func
2 Jun 2014 by Bartlomiej Filipek
How memory access patterns can influence performance of your code
25 Nov 2018 by Bartlomiej Filipek
What performance can we get from C++17 parallel algorithms?
6 Feb 2023 by Vadim Stadnik
Simple and useful alternative to traditional memory pool
19 Mar 2002 by Alex Mikunov
.NET Extensions that provide an infrastructure for enforcing database-like data integrity constraints
22 Aug 2008 by Perspx
I don't know about removing power but you can lock volumes with DeviceIoControl() with the FSCTL_LOCK_VOLUME which means that your process has exclusive access to that volume. Take a look at the documentation here. You could do this with the CD...
17 Oct 2009 by Rajesh R Subramanian
hanlei0000000009 wrote:I need my program sleep 1 microsecond, but Sleep() can not do this.Neither can any other API do this (under Windows). Windows was never designed to provide this kind of functionality (it is not a real-time OS). If you use something like Sleep(2), your program may sleep for 2 m
15 May 2011 by Doc Lobster
String conversion using the C++ Standard Library only
18 Oct 2020 by Espen Harlinn
An introduction to C++ 20 concepts
27 Jun 2001 by Rashid Thadha
An outlook control and framework that can be used in your WTL Application
26 Jun 2001 by Mike Melnikov
A template class that enable you to make tensors with any dimensionality. Process convolution of any tensors and so on.
11 Jul 2002 by Pavel Kobyakov
A DevStudio add-in described provides two interesting IDE integration features: adding a new tab to VC WorkspaceView window and running an arbitrary process under IDE with output sent to "Build" tab of VC Output window.
22 Aug 2008 by Jijo.Raj
ameyakoshti wrote:1st of all i want to know whether it is possible to disable usb portsTo disable USB ports, check this[^]. You have to programatically access the registry and set the key.ameyakoshti wrote:and CD rom "POWER" through VC++.I hope...
30 Jan 2009 by CPallini
"text && text" If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.This is going on my arrogant assumptions....
24 Aug 2022 by honey the codewitch
std::chrono doesn't work on the Teensy? Oh no! Here's how to fix it.
30 Sep 2002 by Ernest Laurentin
Shows how to use Microsoft Script Hosting inside existing ATL/WTL Application
22 Aug 2008 by vikas amin
its simple by modifying the registery , check this linkhttp://forums.msdn.microsoft.com/en-US/vcgeneral/thread/15469774-bd67-4bed-b797-32a899eb79d3[^] Vikas AminMy First Article on CP" Virtual Serial Port "[^]modified on Thursday, July 24, 2008...
2 Aug 2009 by «_Superman_»
In an executable, there must be one entry point that can be called by the loader, runtime etc.There cannot be any ambiguity here.That is why we can have only one main function in a console program and only one WinMain function in a windows...
8 Aug 2009 by David Crow
See here. "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." -...
13 Feb 2009 by «_Superman_»
SetEndOfFile can be used to extend or truncate a file. «_Superman_»
21 Nov 2017 by IAmJoshChang
How to create a VR first person shooter IV - Game over panels
1 Jan 2002 by Alexander Berthold
A library allowing you to conveniently build a custom tokenizer and analyzer supporting precedence priorized rules
12 Nov 2002 by Alex Vinokur
The C++-program simulates a Turing Machine (TM). TM is defined by input files: metafile, states file, alphabet file, transition file, input word(s) file(s).
22 Apr 2009 by Stuart Dootson
Use std::inserter[^] or std::back_inserter[^] for the output iterator. That causes the items to be inserted into the container without having to know what size it should be before you've constructed it.If you're using a vector or list as the...
3 Aug 2008 by hoxsiew
int count; // Loop counter variableint correct;char correct_answers[count] = {B, D, A, A, C, A, B, A, C, D, B, C, D, A, D, C, C, B, D, A}This can only cause problems. correct_answers[count] should probably be correct_answers[NUM_QUESTIONS] since...
1 Aug 2009 by Bacon Ultimate Cheeseburger
Simply make a call to GetObjectType().
13 Aug 2009 by Stuart Dootson
Using Spy++ on a sample application I just built, it would seem that instead of edt1, you now want to use cmb13 (0x47c). I guess they decided that as that field is (now) actually a combo-box, that would be a better ID to use. Java, Basic, who...
13 Oct 2009 by Cedric Moonen
No, you can't select the type of the class this way. However, by using pointers (or references), you can manipulate all buildings the same way by manipulating pointers to the base class (this is called polymorphism, google for it if you want more information).What you want are virtual constructors,
24 Nov 2011 by Scanix
SystemFramework defines interfaces, classes, and types to support a native runtime system with its own garbage collector, delegates, etc. The design of SystemFramework classes is similar to those of the .NET Framework.
5 Feb 2012 by Lakamraju Raghuram
A glance around vector of bool-type
27 Jan 2013 by Andreas Gieriet
There is not such thing like "the one and only code convention".Your team/company may/may not decide on some code convention.If no explicit convention is given, anyone does whatever he thinks is the right way (or does not care at all...).Naming conventions, layouting, etc. is very much...
24 Apr 2013 by Leo Chapiro
STL is very slow while debugging in Visual Studio due to the iterator debugging support. You can speed this up dramatically by setting #define _HAS_ITERATOR_DEBUGGING 0Quelle: http://msdn.microsoft.com/en-us/library/aa985939(v=vs.80).aspx[^]
17 Aug 2020 by Espen Harlinn
Ranges is coming to C++, and the Range-v3 library was the basis for the proposal to add range support to the C++ standard library
16 Apr 2001 by Igor Sukhov
The ATL and MFC versions of the class that implements a dialog for selecting users(computers) within the Windows Network.
15 Jul 2002 by Adrian Bacaianu
That article present a way to retrieve the GET-POST data from a form into an ISAPI extension.
22 Apr 2002 by Craig Henderson
Identifying the minimum difference between two data sets.
19 Dec 2008 by Stuart Dootson
I think you need to add the WTL include directory to the include directory path for the resource compiler. Right-click on the project, select 'Properties', select Resources->General in the properties window and add the WTL include directory to...
21 Apr 2009 by liquid_
How to compute difference and intersection of two sets?There are functions set_difference and set_intersection which requires two pairs of iterators of source sets and output iterator of resulting set. Here, set can be any sorted container with...
22 Sep 2008 by Christian Flutcher
I am progressing with my C++ learning. I am stuck with the following code. void ChangeData(int** ptr){ int ab = 1000; // scope in this method *ptr = &ab;}int _tmain(int argc, _TCHAR* argv[]){ int a = 10; int* aPtr = &a; ChangeData(&aPtr); cout...
22 Sep 2008 by Russell'
The variable is destroyed, but not the contents.You know the abbress s you can continue to check it's value...but, as you sad, it is wrong, so do not do it. The system can use the same locatio of that variable in any moment after that the...
22 Sep 2008 by Cedric Moonen
Christian Flutcher wrote:I am confused how this is happening?Because you were lucky (or in your case, not ). In your ChangeData function, your local variable has a certain address which you store in your ptr variable. When the function exits,...
10 Oct 2008 by led mike
Gut Mikh Tappe wrote:Please let me know what to do Ok I will try. What you need to do is read the documentation.[^]Also reading this might help as well.[^]In my experience not all authors match every reader. So if you find reading those sources...
10 Dec 2008 by Kiran Pinjala
Hi,I have creted a MFC SDI project in VC 2008 and compiled in Vista OS. Now when i copied the project into XP OS system and opened. I can open all views(class view, solution explorer...) but the resource view...it is showing a MessageBox statingA...
29 May 2009 by «_Superman_»
Call GetLogicalDrives to get all the available drive letters.Call GetSystemDirectory to get the drive which contains the OS.Open the volume using CreateFile("\\.\C:", ...Here replace C: with the drive letter returned in GetSystemDirectory.Call...
1 Jul 2009 by David Crow
Caslen wrote:If it is my problem is there anyway to detect programatically whether a file is already open somewhere else?Open it exclusively. All other attempts will fail. "Old age is like a bank account. You withdraw later in life what you...
1 Aug 2009 by «_Superman_»
OnCreate is called just when the application requests that the Create function be called. So it is not guarenteed that the window is fully created. OnInitDialog is called after the window (in this case the dialog) is completely created.When you...
16 Oct 2009 by Stuart Dootson
Yeah, that's not happening...Why 1 microsecond, FFS? What are you trying to do? Because there may well be a better way.
3 Apr 2009 by David Crow
The union looks something like this:-----------------------| 512 |-----------------------| 00000010 | 00000000 |-----------------------| 2 | 0 |----------------------- "Old age is like a bank account. You withdraw...
9 Jan 2010 by phoenicyan
High-performance expression evaluator that allows filtering large number of messages
10 Mar 2010 by «_Superman_»
fstream is a C++ object. It will work in any OS.Win32 APIs will work only in Windows.fstream implementation in Windows will eventually call the Win32 APIs.So the first approach will give you portability.The second approach will execute slightly faster.
20 Aug 2010 by Tsuda Kageyu
Safe! It's guaranteed that the elements of a vector are stored contiguously.http://www.cplusplus.com/reference/stl/vector/Sorry. I forgot to tell one important thing.&*v.begin() isn't safe because sometimes the iterator of a vector is not a pointer. Use &*v[0].
16 Oct 2010 by Aescleal
If you're using C++ there's no reason to use printf or the whole god awful family of C relics. Use a stream. Then you get type safety and you won't try reading return addresses off the stack to interpret as strings. Consider rewriting along the lines of:int main(){ int d = 20; ...
13 Dec 2010 by Alain Rist
Hi Ted,Not really understanding why you want to expose that, anyhow this should compile: typename std::deque::iterator begin(){ return B.begin();}cheers,AR
15 Jan 2012 by «_Superman_»
CString uses either the ASCII character set or the UNICODE character set depending on whether the UNICODE pre-processor macro is defined.Visual Studio defines UNICODE by default.std::string on the other hand always uses the ASCII character set.You can explicitly use CStringA to use the...
20 Mar 2013 by cocaf
How to show progress in a Boost test application.
24 Feb 2014 by Vidyasagar Machupalli
After a successful game release to Windows store ,I wanted to try with mobile platforms.I thought why can’t i port the same game (Bongo Soccer-200 downloads on win 8/8.1 as on today) to android? The issues i may face I have used an unity Terrain and a 3dMax goalpost in my game,which are h
25 May 2014 by Sergey Alexandrovich Kryukov
You should properly use the return from the function remove function. It returns an iterator to the element that follows the last element not removed:http://www.cplusplus.com/reference/algorithm/remove[^].Then you need to use the iterator obtained and the str.end() iterator of the original...
26 May 2014 by Stefan_Lang
You can override the default comparator by specializing std::less like this:struct mytype { int x;};template struct std::less : public binary_function{ // functor for operator
13 Jan 2015 by Vidyasagar Machupalli
Gaming: The best free tools to start your Game Development
18 Sep 2015 by Shvetsov Evgeniy
Type tricks (above described and other)
15 Mar 2016 by Keyhole Software
How to automate your front-end development environment with npm
16 May 2016 by Keyhole Software
AngularJS is a popular framework used for building single-page applications. One great benefit of using Angular is that it is easy to incorporate automated testing. I have been using Angular on various projects for a few years now, so naturally I was curious to learn what’s new in Angular 2.
25 Nov 2016 by Jochen Arndt
There is a really good answer about string comparison at this SO thread:c++ - How to compare a "basic_string" using an arbitary locale - Stack Overflow[^].Regarding your SQL examples, both should return false for the example strings when using AS (Accent Sensitive). But I'm not quite sure...
22 Oct 2017 by IAmJoshChang
How to stop the time score system when the game is over
19 Mar 2020 by Nikola M. Živković
In this article I tried to sum up what has been my greatest challenges and things that I had to accept and change about myself after becoming Team Lead.
23 Nov 2019 by Zhaohui Xing (Joey)
Swift classes for algorithm, including single linked list class, stack class, queue class
21 Mar 2019 by Martin Vorbrodt
Parsing Command Line Options
4 Jun 2020 by Maciej Los
I'd suggest to start by reading tutorials: C++ Classes and Objects - GeeksforGeeks[^] Arrays in C/C++ - GeeksforGeeks[^] Inheritance in C++ - GeeksforGeeks[^] Polymorphism in C++ - GeeksforGeeks[^] Tip: under the third link, you'll find sample...
18 May 2023 by CPallini
See, for instance: https://stackoverflow.com/questions/12050777/how-to-return-memory-from-process-to-the-os[^]
7 Nov 2002 by Leor Zolman
A set of tools to shorten the length of VC++ STL-related error messages so that the most vital information from a message fits within the status bar in VS.
19 Dec 2008 by josip cagalj
Hi to all. I'm trying to open some project wroted using WTL. When I try to rebuild it (using VS2008 on Win XP) I get the compile error as above. Now, "atlres.h" file is in directory which I added to my project settings properly and I don't know...
26 May 2009 by followait
I tried as below, but ostream cannot be instantiate?ifstream ifs1("file1");ifstream ifs2("file2");ostream oss;oss
26 May 2009 by Stuart Dootson
ostream is an abstract base class - that's why you can't instantiate it. Also, you can't use the insertion operator on streams to get what you're wanting.So...what do you mean by "memory binary stream"? If you were using strings, then this should...
15 Oct 2010 by fantasy1215
Please run the code below.int main(int argc, char* argv[]){ int ii = 20; char tmp[32] = "loveing"; printf("[%d]hello[%s]\n", tmp); //no integer fill the %d format char szData[52] = {0}; sprintf(szData, "[%d]saying [%s]\n",ii);//no string fill the %s format printf("%s", szData); return 0;}The...
9 Sep 2008 by SandeepNK
Sample code is as follows:class TestClass{CCriticalSection m_csTest;void Fun1() { m_csTest.Lock(); Fun2(); MessageBox("In Fun1 critical section."); m_csTest.Unlock();}void Fun2(){ m_csTest.Lock(); MessageBox("In Fun2 critical...
25 Sep 2008 by Christian Flutcher
I know .NET framework and C# well. Recently I started working with C++/CLI which I felt more interesting than C#. Since .NET framework is becoming popular, do you think MFC got obsolete? Are you guys doing any projects in MFC other than...
10 Oct 2008 by Mark Salsbery
In addition to super_ttd's reply...If you must use fopen(), then you should probably use a CStringA.CString has a generic internal character type, depending on whetherUNICODE or _UNICODE is defined.If you want to use the generic text CString,...
7 Jan 2009 by CPallini
I suppose it depends on color depth... See BITMAP struct definition [^], the bmBitsPixel member looks promising. If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. ...
8 Jan 2009 by Code-o-mat
Take a look at this[^], might be usefull. > The problem with computers is that they do what you tell them to do and not what you want them to do.
8 Jan 2009 by Hamid_RT
OR see CRichEditControl50W - A VC++ Rich Text Edit 4.1 MFC Control[^]. Of one Essence is the human racethus has Creation put the baseOne Limb impacted is sufficientFor all Others to feel the Mace(Saadi )
27 Jan 2009 by Garth J Lancaster
1) this sounds like homework - we dont do homework - at best we will give you hints, but if you're expecting us to jump in and solve all your issues, go to RentACoder or such 2) DONT GET IMPATIENT AND POST MORE THAN ONCE - most of us here have...
22 Jun 2009 by Stuart Dootson
Member 4399131 wrote:I assumed that the problem isn't in my coding technique, it must be generally in the algorithm I use!!!Yep.Member 4399131 wrote:Does somebody know a better algorithm to implement FindOneOf???Looking at their code (strpbrk -...
2 Aug 2009 by CPallini
Because there is only one application in your application... If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of...
6 May 2010 by sashoalm
Here's my try:#include using namespace std;int main(int argc, char* argv[]){ string name; static const int namelen = 15; static const char* letters[2] = { "bcdfghjklmnpqrstvwxyz", "aeiouy" }; static const letterlen[2] = { strlen(letters[0]), strlen(letters[1])...
13 Aug 2009 by softwaremonkey
Hi,In an older (MSVC++6.0) project I used HideControl(edt1) to hide the filename edit control in a CFileDialog derrived class, which worked fine at the time.When I compile this project with MSDEV2008, the code complies OK but control is no longer...
13 Aug 2009 by Stuart Dootson
Could you do all of the automation, including creation of the Word object, on the worker thread?Basically you're running foul of COM single-threaded apartments and things, I think. This article[^] explains them well. Java, Basic, who cares - it's...
31 Aug 2009 by Moreno Airoldi
Consider this as a rough idea:#include void PrintArrayClockwise(int *array, int rows, int columns){ int r = 0; int rh = rows / 2; int i; while (r