Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Posts tagged c++

3 child tags

Use this tag for questions concerning the use of the C++ programming language and for questions containing code in the C++ language. Avoid using it together with the C tag unless your question is explicitly about code compatibility or differences between C++ and C.

Unless the question explicitly mentions which version of the C++ standard that is uses, the current active version of ISO 14882 is assumed (C++17).

When applicable, always include information about which compiler and target system you are using.

This tag doesn't have a detailed wiki yet.

66%
+2 −0
Q&A When to use custom iterators versus pointers

I am working on a toy project where I have a container for which I would like to write an iterator that iterates over the values in the container. Because the values are stored in a (c-style) arra...

0 answers  ·  posted 9d ago by mr Tsjolder‭

Question c++ iterator
60%
+1 −0
Q&A Ghidra decompiler: c_str() used in phantom string?

I loaded a binary into Ghidra for analysis. The decompiler says undefined8 main(void) { basic_ostream *pbVar1; char *pcVar2; [--snip--] pbVar1 = std::operator<<(pbVar1,"PXZ ");...

1 answer  ·  posted 6mo ago by nteodosio‭  ·  edited 5mo ago by Alexei‭

Question c++ ghidra
71%
+8 −2
Q&A Write to same file from multiple threads

I want to write a text file from multiple threads. The file structure is line-oriented. This means writing of lines should be atomic. I am using Qt 5.15.2. Is it enough to protect a shared QTextSt...

2 answers  ·  posted 3y ago by Silicomancer‭  ·  edited 8mo ago by Shree‭

77%
+5 −0
Q&A How should one match a specialized version of a variant?

Let's say I have a variant that can hold a bunch of different types of values (say I got them from parsing a JSON or similar). using Value = std::variant<std::monostate, int, double, std::strin...

1 answer  ·  posted 2y ago by Moshi‭  ·  last activity 11mo ago by Baum mit Augen‭

Question c++ variant
83%
+8 −0
Q&A How to define an object with different subclasses in an if-statement?

Note: I asked this question on TopAnswers a couple weeks ago, but didn't get any response, so I figured I'd ask it here. I am currently learning C++. I have a parent class (Vehicle) and two subc...

1 answer  ·  posted 1y ago by Trevor‭  ·  edited 1y ago by Alexei‭

77%
+5 −0
Q&A Any testimonials for any C++ units of measure library?

The question is about libraries that extend the data type system to ensure physically realistic computations. Think std::chrono but for distance and mass and other things as well as for time. Inste...

1 answer  ·  posted 1y ago by Fred Wamsley‭  ·  last activity 1y ago by Ben‭

57%
+2 −1
Q&A What should I read if I knew C++ twenty years ago? [closed]

For someone who was familiar with C++ in the past and is coming back to it after a long break, what are some useful books that won't waste time with basics but will cover the new features of the mo...

0 answers  ·  posted 1y ago by Fred Wamsley‭  ·  edited 1y ago by Alexei‭

Question c++
81%
+7 −0
Q&A Is there any benefit to using new?

I've heard that in modern C++, smart pointers are preferred to raw pointers for ownership (the so-called RAII principle, as I understand it). This makes sense, and since then I've always used them...

1 answer  ·  posted 1y ago by Moshi‭  ·  last activity 1y ago by deleted user

71%
+3 −0
Q&A Do you need to use std::move to store a parameter passed by value?

If you have a class which needs to store a construction parameter internally, and you want to take advantage of move semantics, I understand that the parameter should be passed by value: class Foo...

1 answer  ·  posted 2y ago by deleted user  ·  last activity 2y ago by Dirk Herrmann‭

Question c++ reference
77%
+5 −0
Q&A Why can't a derived class add a const qualifier to a method?

Say we have an abstract class Foo declared as so: class Foo { public: virtual void test() = 0; }; Let's say that we make a derived concrete class FooDerived, and decide to mark it's ve...

2 answers  ·  posted 2y ago by Moshi‭  ·  last activity 2y ago by Dirk Herrmann‭

28%
+0 −3
Q&A C++ exit code -1073740940 [closed]

What means the exit code -1073740940 in C++?

2 answers  ·  posted 2y ago by always_improve‭  ·  closed 2y ago by Alexei‭

Question c++ exit-code
75%
+4 −0
Q&A What advantages does Agner Fog's VCL have over OpenMP?

Agner Fog has this C++ Vector Class Library, which is ... useful for improving code performance where speed is critical and where the compiler is unable to vectorize the code automatically in an...

1 answer  ·  posted 2y ago by anatolyg‭  ·  edited 2y ago by Alexei‭

77%
+5 −0
Q&A How to manage CPU capabilities of Jenkins nodes?

We use Jenkins Pipeline to build and test some C++ software. The pipeline script runs the tests on 10 different nodes in a parallel way in order to save time. All of these nodes are real (not virtu...

1 answer  ·  posted 2y ago by anatolyg‭  ·  last activity 2y ago by bta‭

80%
+6 −0
Q&A How kill a child process without read() hanging in the parent process?

There is an external program I'm calling from within my C/C++ program, by using fork() and execl(), and redirecting the stdio with dup2() to be able to read the output from the external program. I...

1 answer  ·  posted 2y ago by sktpin‭  ·  edited 2y ago by Lundin‭

28%
+0 −3
Q&A How to plot in C++?

I was trying to plot using following lines in C++. #include "koolplot.h" int main() { plotdata x(-6.0, 6.0); plotdata y = sin(x) + x/5; plot(x, y); return 0; } When I was...

0 answers  ·  posted 2y ago by Anonymous‭

Question c++ plot
70%
+5 −1
Q&A How allocated memory is calculated?

int arr[] = {10,123,14,14,15,16}; cout<<sizeof(arr)/sizeof(arr[0]); I was reading the article. When sizeof() is used with the data types such as int, float, char… etc it simply ret...

1 answer  ·  posted 2y ago by Anonymous‭  ·  last activity 2y ago by Canina‭

Question c++ memory
42%
+1 −2
Q&A What might happen if I ignore warning?

#include <iostream> using namespace std; int linearSearch(int array[], int n, int key){ for(int i=0;i<=n;i++){ if(array[i]==key){ return i; } } } int main() { int ...

2 answers  ·  posted 2y ago by Anonymous‭  ·  last activity 2y ago by Lundin‭

50%
+2 −2
Q&A Print value from constructor

#include<iostream> using namespace std; class Book{ public: string title; string author; int pages; Book(string aTitle, string aAuthor, int aPages){ aTitle = title; ...

1 answer  ·  posted 3y ago by deleted user  ·  edited 3y ago by Alexei‭

77%
+5 −0
Q&A Tools for debugging coredumps

For debugging running programs I often use whatever is integrated with the IDE I am using. QtDeveloper right now, but also used Eclipse, Netbeans and others. Most of them just use gdb under the hoo...

0 answers  ·  posted 3y ago by Estela‭  ·  edited 3y ago by Estela‭

81%
+7 −0
Q&A Multiple catches with almost the same code.

I find myself often writing code like this. try { // code } catch( FailedReadException const & ex) { file.close(); std::cerr << "Read failure " << ex.readFailure() <&...

2 answers  ·  posted 3y ago by Estela‭  ·  edited 3y ago by Ayxan Haqverdili‭

83%
+8 −0
Q&A Is `uint8_t` always an alias for a character type if it exists?

Is uint8_t guaranteed to be a character type if it exists? Will using a uint8_t* to examine bytes of an object cause violation of the strict aliasing rule? Is the following legal code: #include &l...

1 answer  ·  posted 3y ago by Ayxan Haqverdili‭  ·  edited 3y ago by Lundin‭

83%
+8 −0
Q&A Is it correct to run code inside a method whose object has been destroyed?

Consider an object for which a method is invoked. Beyond certain point the method no longer accesses this at all. No read/writes of non-static members. No invocation of non-static methods. Is it ...

1 answer  ·  posted 3y ago by Estela‭  ·  last activity 3y ago by Hyperlynx‭

Question c++ multithreading
85%
+10 −0
Q&A Destroy std::mutex referenced but not owned by std::unique_lock?

Is it correct to destroy a mutex which is referenced but not owned by an unique_lock as in this code? { std::unique_ptr<std::mutex> mutex = std::make_unique<std::mutex>(); std::u...

1 answer  ·  posted 3y ago by Estela‭  ·  last activity 3y ago by Angew‭

Question c++
85%
+10 −0
Q&A Scheme for cross-platform warning control?

tl;dr I'd like to learn a compact, cross-compiler way of selectively suppressing compiler warnings. Consider the case where you really mean to make an exact floating-point comparison using ==, o...

1 answer  ·  posted 3y ago by dmckee‭  ·  last activity 3y ago by Someone‭

66%
+2 −0
Q&A Confusion about using std::async with class member function

So,I'm having a doubt when I call std:async() on a member function of a class. The book I'm reading says (emphasis mine) You can also pass a pointer to a member function to async(). In that case...

1 answer  ·  posted 3y ago by hamsasimon‭  ·  last activity 3y ago by Chris Jester-Young‭

Question c++ multithreading
81%
+7 −0
Q&A Pros and cons of various type_traits idioms

My work tasks have recently started requiring me to use the type_traits header to restrict the classes that may be used in template functions, methods, and classes. And while I used it for a long t...

1 answer  ·  posted 3y ago by dmckee‭  ·  edited 3y ago by Marc.2377‭

77%
+5 −0
Q&A When should I use wait() instead of get() when using C++ threads

I'm trying to understand the purpose of the wait() function in Class future<> for C++. At the moment I don't see any purpose for calling wait() instead of get(). What I have tried in code: i...

1 answer  ·  posted 3y ago by hamsasimon‭  ·  last activity 3y ago by Derek Elkins‭

Question c++ multithreading
75%
+4 −0
Q&A Static and thread_local initialization order

Is there any guarantee regarding initialization of static and thread_local objects? In example, is there any guarantee about the value printed by the following program? #include<iostream> s...

1 answer  ·  posted 3y ago by Estela‭  ·  edited 3y ago by Alexei‭

50%
+2 −2
Q&A Having trouble adding include directories

I'm trying to set up a simple test project, to unit test a change I'm working on. The change is to a file inside some existing project. I've tried to set up the includes as the original has it, but...

1 answer  ·  posted 3y ago by Hyperlynx‭  ·  last activity 3y ago by Hyperlynx‭

Question c++ cmake
71%
+3 −0
Q&A connect with SLOT/SIGNAL: QPushButton clicked signal not received by main window

I added a QPushButton to my ui file named pushButton, and manually connected it using connect. There are no errors or warnings emitted at any point in the compilation stage The button does show up...

1 answer  ·  posted 3y ago by jrh‭  ·  last activity 3y ago by jrh‭

Question c++ qt
75%
+4 −0
Q&A Generate SIGSEGV without undefined behaviour.

In order to test that coredumps are generated and that they contain useful information which can be retreived with gdb I need to generate a SIGSEGV. Or anything else which causes a coredump. The co...

1 answer  ·  posted 3y ago by Estela‭  ·  last activity 3y ago by Lundin‭

Question c++ linux gcc