Skip to main content
2 votes
4 answers
237 views

If two pointers are referencing the same memory location. Will it be possible to make one pointer null, if we deallocate that memory location? For example: #include <iostream> using namespace ...
GhostVaibhav's user avatar
1 vote
4 answers
119 views

We are trying to create a class for setting options that can be either float or int (in reality, there are several more types). We want to store options of any kind in a single list, so we have made a ...
kalj's user avatar
  • 1,502
3 votes
5 answers
294 views

tl;dr I have a program that "works", but does so in part via unsequenced behavior. I recognize that code with unsequenced behavior can technically do anything - however, it has to do ...
Nick Reed's user avatar
  • 5,109
-3 votes
2 answers
183 views

I have std::map of std::vector of raw pointers. According to Google AI, in order to clean it I should do: int main() { std::map<int, std::vector<MyObject*>> myMap; // Populate the ...
Igor's user avatar
  • 6,473
0 votes
0 answers
46 views

In my Qt application, I'm dynamically creating QStandardItem objects and adding them to a QStandardItemModel using appendRow(): auto* item = new QStandardItem("text"); model->appendRow(...
DaNilsoN's user avatar
0 votes
0 answers
58 views

I have a problem with an attempt at factorizing two utility functions, each calling a given "hardcoded" function, into one utility with a functor call instead. Meaning I have a factoring ...
v.oddou's user avatar
  • 6,867
2 votes
4 answers
198 views

I'm using C++ 14. I find C++'s vector operations erase and remove verbose and confusing and want to write a simple generic wrapper to remove an element from a vector of structs if that element's value ...
gene b.'s user avatar
  • 12.6k
0 votes
4 answers
268 views

I am relatively new to C++ and would like to know if it is possible to do the following and if so, is there a better way to achieve the same or similar result more efficiently? Declare a struct/class ...
BalmyWinner's user avatar
0 votes
1 answer
118 views

I need to refactor the following code (simplified for clarity) : #include <iostream> // those structs cannot be changed struct Foo1 {int f;}; struct Foo2 {int g;}; struct Foo3 {int h;}; ...
vazlsky's user avatar
  • 2,360
0 votes
4 answers
202 views

I'm using a single structure to store multiple parameters. I want to access these parameters via their element names, just like a normal structure. I also want to name the structure elements and ...
Marcus Hampel's user avatar
4 votes
2 answers
130 views

I have two types, CustomNotCompatibleWithRun, CustomCompatibleWithRun, and a run() function: #include <iostream> #include <type_traits> template <typename T_> struct ...
zhanginou's user avatar
  • 327
-1 votes
3 answers
183 views

Just experimenting with shared_ptr to explore its functionalities. I'm constructing a new shared_ptr object using a raw pointer from other shared_ptr object. The following code is compiling and runs ...
Artur Brodsky's user avatar
5 votes
1 answer
63 views

From https://boost-ext.github.io/sml/examples.html#deferprocess Modified to try and copy the fsm. #include <boost/sml.hpp> #include <cassert> #include <deque> #include <queue> ...
DrDreadful's user avatar
3 votes
1 answer
121 views

I am trying to create constructors for building a class, that can take iterators of anytype, as long as they are an iterator for a specific value_type. With a different handler for all iterators of ...
Questor's user avatar
  • 314
5 votes
1 answer
233 views

I have a constant declared in one case of my switch statement: void foo( int& v ) { switch( v ) { case 0: static constexpr int c{ 0 }; break; case 1: v = c; ...
Fedor's user avatar
  • 24.7k

15 30 50 per page
1
2 3 4 5
572