The Standard Template Library, or STL, is a C++ library of generic containers, iterators, algorithms, and function objects. When C++ was standardised, large parts of the STL were adopted into the Standard Library, and these parts in the Standard Library are also sometimes referred to collectively ...

learn more… | top users | synonyms

8
votes
0answers
116 views

Object storing and retrieving using wildcard identifier

I'm writing an interpreter for a scripting language which allows objects to: Have an alias Be referenced using a wildcard Contain child objects Combination of all three above For example: ...
1
vote
0answers
47 views

Enum list to STL container, part 2

Original question: Enum list to STL container Goal: Write a function enumToSTLContainer() that is to return any STL container whose elements are from a specified ...
2
votes
1answer
53 views

Enum list to STL container

Can someone improve upon this function of mine? EnumToSTLContainer is supposed to make a copy of any STL container whose elements are from a specified ...
5
votes
4answers
250 views

Counting word occurences

This is a simple word count program I wrote to play around and get familiar with using std::map. Is there anything I can improve upon? I didn't use CTRL+Z to stop ...
5
votes
3answers
412 views

“Jolly Jumper” challenge

I'm a C#/Java full-time developer who is trying to pick up C++ purely for educational reasons. I've tried to solve a pretty simple ACM ICPC problem and would love to hear all kinds of criticisms on ...
2
votes
2answers
364 views

STL List Implementation

I've implemented a simple C++ STL like list. It's pretty simple, all the constructors and methods haven't been implemented here, but majors are. ...
7
votes
3answers
1k views

STL Queue Implementation

I've implemented a simple C++ STL like queue. (I've tried to follow @LokiAstari stack implementation code fashion) ...
8
votes
3answers
2k views

STL Vector Implementation

I've implemented a simple vector like STL C++. ...
-2
votes
1answer
126 views
6
votes
2answers
236 views

Using includes() vs. hash function to check if an unordered_set is a subset of another unordered_set

I did two methods to determine if an unordered_set is a subset of another unordered_set, using hashing, and the built-in ...
4
votes
1answer
99 views

Container which iterates a range or a list

I have made some composited container Range which accepts either a min/max range as a std::pair or a set of integers as a ...
0
votes
1answer
86 views

Filter a collection

In my project, there are some methods which filter some items from a collection. I was told to use the C++ STL whenever I can. But when I use std::copy_if, I feel ...
2
votes
1answer
82 views

LRU Cache with a static variable for garbage value

I have tried to implement a Least Recently Used cache with only C++ STL containers. The main thing that I keep asking my self the static variable called ...
6
votes
2answers
198 views

STL-compliant list class

Well, this is my first attempt to create a STL-compliant container. I'd like to know whether it meets STL concepts & requirements, so feel free to critique. .h link - ...
7
votes
1answer
6k views

Implementation of binary heap in C++

Things I can think of include integer overflow, if the input type is int, etc. But other than that, what do you think is wrong with this code, design-wise, style-wise, and also in terms of other ...
6
votes
2answers
321 views

Is this the right way for creating objects and putting them into std::list?

I am writing small roguelike game where I spawn some items and put them into the std::list - is this the right way to do it ? The Item class is as followed (I know it has public "id" property): ...
5
votes
2answers
369 views

Box-stacking problem in C++

I have tried to write code of Box stacking problem (mentioned here) in C++ . Kindly give me some views on what mistakes I might have made and how I can improve. It is running for the two inputs I have ...
2
votes
2answers
474 views

STL and Dijkstra's algorithm optimization

This is the problem and my solution to this is: ...
2
votes
1answer
99 views

Review of approach to inheriting from std::exception [closed]

I would like a review and recommendations for improvement of my approach to resuing std::exception. Just a quick justification for the four constructor arguments: I want to force myself to always ...
4
votes
2answers
209 views

“Edit distance” UVA programming challenge

I'm trying to solve a programming challenge for fun. The programming challenge is here and my solution for the same can be found here. It currently causes an exceeded time limit. ...
0
votes
1answer
2k views

Breadth-first tree traversal using STL list

I am writing code for breadth-first search of a tree with C++'s STL. Please help as I am new to the STL. ...
3
votes
1answer
89 views

Design considerations for copy_if_max() algorithm?

I need a copy_if_max() function, i.e. copy all the elements in an input range that are equal to the max in that range. The most obvious implementation does two ...
2
votes
2answers
90 views

Utilizing std::map and std::array for displaying a modulus grid

I've written a modulus-type program (using std::vector). The user inputs a number, and the program displays a modulus grid pertaining to that number. This is what ...
3
votes
2answers
109 views

First use of std::map in factors and prime factorization program

This is from an older question of mine that I decided to revisit: Simple and efficient code for finding factors and prime factorization? In that question, someone suggested I use an ...
3
votes
1answer
248 views

Am I using C++11 features like STL and move semantics correctly?

I've implemented selection sort, heap sort, insertion sort, and iterative quicksort using C++11. Am I using the correct STL data structures/algorithms? Am I using move semantics correctly in my code? ...
7
votes
1answer
167 views

STL-style deque class

I decided to write an STL-style class as an exercise. I followed a tutorial of sorts that I found online, but I also made some modifications. I'd like to hear any criticisms you folks might have. Be ...
5
votes
2answers
7k views

Designing a state machine in C++ using the STL

I have this working code for C++ state machine using STL (not using boost state chart). The purpose of posting is two-fold: To share a simple and working code C++ state machine using the STL for ...
1
vote
3answers
436 views

scope exit something wrong?

Is there something wrong with this code? ...
1
vote
2answers
158 views

unw_graph class (unweighted graph)

Here is my new STL-like implementation of an unweighted graph. Could you please tell me what member functions I should include in my library? unweighted_graph.hpp ...
2
votes
1answer
687 views

Free implementation of “bounded priority queue” in C++

I was searching for a free implementation of a "bounded" priority queue. The algorithm has been discussed many times on Stack Overflow. I took a shot and wrote a STL-like bounded_priority_queue ...
7
votes
1answer
446 views

Setting output width with ostream_iterator

I'd like to display a vector (implemented in my custom Vector class) and have the output width of the elements be configurable. I've done this by creating a simple wrapper for the element being ...
3
votes
2answers
305 views

C++ and STL - Machine Learning Problem

I would like to get some general comments on style and use of STL in particular. This is some code I wrote to do machine learning classification (logistic regression). Any suggestions would be very ...
3
votes
0answers
225 views

SGI STL pop_heap() method

Throughout the source code, I find that SGI STL pop_heap() has three steps: put the root value into the last percolate down percolate up Popping an element at ...
2
votes
1answer
520 views

Polymorphic STL foreach without passing the container type

I was trying to figure out how to make a foreach macro for STL containers that is break-able and I came up with this method that uses templates to recognize the container type automatically. Any ...
3
votes
2answers
2k views

STL-like graph implementation

I have implemented an STL-like graph class. Could someone review it and tell me things that I could add to it? File graph.hpp ...
3
votes
1answer
2k views

Simple object pool template container in C++

The main advantage of this pattern is when I often create and destroy objects, which in this case are often used. I made this because I needed to track several short timers at the same time, but it ...
2
votes
3answers
974 views

Checking if a string is a number with STL

Recently me and colleague had a discussion about the following piece of code (simple bool function that checks if string is a number, +1000 not allowed, ...
2
votes
2answers
7k views

STL graph implementation

I'm looking for a code review on the following C++/STL graph implementation: ...
5
votes
4answers
433 views

Generating primes with Sieve of Eratosthenes

There are many problems on the Internet that require you to find prime numbers, so I decided to write a set of functions to find them. I used the Sieve of Eratosthenes for generating the primes as it ...
6
votes
2answers
3k views

Thread-safe std::map accessor

After learning that std::map containers are not inherently atomic and therefore not thread-safe (check out this related Stack Overflow question and usage example), ...
2
votes
2answers
340 views

Trying to be more generic: file to map class

This code will be used to map a set of unique keys to a container of objects that are unique to that key. I would like to be able to reuse this code in future projects hence the template, and not hard ...
0
votes
4answers
1k views

STL matrix chain multiplication

Please provide positive and not-so-positive feedback on style, clarity, or any other additional feedback you would like to provide. ...
1
vote
1answer
173 views

Reading a sequence of points and finding the closest one to the first

I was told this is the place to come for input/feedback on your programming. I am always looking to improve either by personal review or outside opinion/help. Would the community here be willing to ...
2
votes
2answers
286 views

C++ iterating over unequal unordered pairs in one collection

Here is the code that does what I want: ...
6
votes
2answers
4k views

C++ string_cast<> template function

In C++, to simplify string conversion between std::string and std::wstring, I created the following utility template functions: ...
5
votes
2answers
221 views

Counting the total number of characters in a std::set<std::string>?

I have a std::set<std::string> and I need to know the total number of characters (sum of all strings length): ...