All Questions
10 questions
0
votes
1
answer
129
views
Class holding collection of other class
I have a class Item. Then another class ItemCollection holds std::map<int,Item> item_collection_. The reason to create the class ItemCollection is if I want to do something with collection of ...
0
votes
0
answers
199
views
Base class with bool flag to imitate virtual constructor
I am using bool flag to call base class function when needed to imitate virtual constructor. I am using this way for inheritance purpose. I have a Base class constructor with int and bool. The bool ...
0
votes
1
answer
192
views
Avoid numerous dynamic_cast_ptr in the API design of polymorphic types
I am trying to design a geometric intersection API. Below is the code to represent geometric elements.
#include <iostream>
#include <memory>
// Since I did not write the Shape class I ...
3
votes
1
answer
171
views
What should I use for technically always read-only objects?
I have a function get() which gets a human object from somewhere. That is literally the only use of human, to provide a collection of properties of a human.
struct human {
std::string first_name;
...
10
votes
2
answers
4k
views
Is this a good approach for a "pImpl"-based class hierarchy in C++?
I have a class hierarchy for which I would like to separate the interface from the implementation. My solution is to have two hierarchies: a handle class hierarchy for the interface and a non-public ...
8
votes
1
answer
1k
views
Design considerations for configuration menu on embedded system
I am working on an embedded system that interfaces with the user with several buttons and a small graphic display.
As a side note: Since I am on an embedded system, I would like to prevent dynamic ...
6
votes
3
answers
5k
views
How to properly deal with starvation
I'm trying to find a way to avoid starvation in my program, a producer/consumer (two threads, one for each role) problem with four priority levels (four deques).
Basically, the consumer thread always ...
2
votes
2
answers
2k
views
Does it make sense to have a user specified thread limit?
I'm developing a C++14 application and would like to take advantage of the new multithreading features, in particular std::async. I have seen a number of applications which allow the user to specify ...
9
votes
1
answer
2k
views
C++ serialization design review
I am writing a C++ application. Most applications read and write data citation needed and this one is no exception. I created a high level design for the data model and serialization logic. This ...
16
votes
3
answers
10k
views
How to handle design changes for auto_ptr deprecation in C++11?
We are testing a library under C++11 (i.e., -std=c++11). The library uses auto_ptr and this pattern:
Foo* GetFoo()
{
autoptr<Foo> ptr(new Foo);
// Initialize Foo
ptr->Initialize(...