• Forum
  • General C++ Programming

General C++ Programming

by admin
Welcome to this board!
 
Welcome to the general programming forum in C++.com! In this forum, users can to talk about any topic related to programming in the C++ language that does not ...
[no replies]
Unlock mutex when returning
 
The back-end of my application executes a command with _popen and passes the output to the front-end. void Loader::LoadBuffer(const std::string& arg) { ...
[2 replies] Last: Whoops you're right, thanks I'll make bufferLoaded atomic. As for out... (by LsDefect)
how to read a single character as with getchar but in C++?
 
Hi, in C one could read a single character from the keyboard with functions like getc() or getchar(). What is the equivalent in C++? streams use buffered inp...
[8 replies] Last: in C one could read a single character from the keyboard with functio... (by seeplus)
Strange arithmetic conversions
 
Stroustrup states in C++ Programming Language 4th edition page 271 that the result of converting an unsigned integer to a signed one of possibly larger size imp...
[5 replies] Last: This is one of the reasons why .ssize()/std::ssize was introduced to g... (by seeplus)
How to clear the buffer for istreams?
 
Hi, what if I want to read only one character of input from the keyboard and want to use streams? so this: char c; cin >> x; will read a charact...
[1 reply] : https://en.cppreference.com/w/cpp/io/basic_istream/ignore (by salem c)
c++ array negative numbers
 
I am trying to solve this problem, but got wrong output. Given an array of integers, write a function to move all the negative numbers to the left end of the ar...
[4 replies] Last: to move all the negative numbers to the left end of the array without... (by seeplus)
c++ indice 2 numbers
 
I solved the below problem. Can anyone tell me the best way here? Given a list of integers and a target sum, write a function to find the indices of the tw...
[4 replies] Last: Another way is to use combinations. Consider this which will find the ... (by seeplus)
What is the difference between declaring a variable auto and declaring it auto&&?
 
Hi, I have two variables for a general function f(): auto value = f(); auto&& other = f(); what is the difference between them?
[9 replies] Last: Why auto&& and not auto& ? I had to look this one up. && is speci... (by jonnin)
by stav
which one of these bytecode instruction designs is better?
 
I've been going down a bit of a rabbit hole trying to figure out the most optimal way to design a bytecode instruction class. To be clear an instruction is som...
[7 replies] Last: I don't think either of these approaches of good. To see why, consider... (by dhayden)
by Cplusc
Inconsistent Results with Different Methods
 
I’m facing an issue in a C++ project where two different methods for computing the same values are giving inconsistent results, despite both using the same in...
[16 replies] Last: Hi Cplusc, I hope all is well at your end :+) Sorry for an even late... (by TheIdeasMan)
Threading
 
Hello everybody, long time no post. My posts have been sporadic at best lately, but hopefully, this one will gain some traction and be helpful to many who find ...
[18 replies] Last: Not that it really matters your link lists different authors for the ... (by seeplus)
Why are there multiple multithreading frameworks?
 
In my learning, I've come across several multi-threading frameworks. I know the language didn't officially provide thread support until C++11 and that some thre...
[8 replies] Last: PS. There's also: Intel Threading Building Blocks https://www.intel.co... (by seeplus)
by helios
About full-duplex sockets
 
Sockets are supposed to be full-duplex, right? So the endpoints should be able to send and receive literally at the same time. But how do you handle that at the...
[1 reply] : I'm not even sure what API you are using here 🤔 But, if we are tal... (by kigar64551)
Mismatch overload problem
 
Why does s have the value false? template<typename T> char test_have_range(decltype(&T::begin), decltype(&T::end)); template<typename T> short test_hav...
[1 reply] : #ifndef DUTHOMHAS_IS_ITERABLE_HPP #define DUTHOMHAS_IS_ITERABLE_HPP ... (by Duthomhas)
How to test if a type T has a begin<T> defined
 
I have a SFINAE context where I have the following: struct have_sort { char c; }; struct have_range { char c ; }; struct have_none { char c ; }; ...
[no replies]
why testing for member pointer determines the template type is a class?
 
why does this code determine if the type is a class: template<typename T> class is_class { template<typename C> static char test(int C::*); template<typena...
[4 replies] Last: Thanks!! (by JUANDENT)
Trouble with seeing where variable is initialized?
 
Hello, This question is in regards to the initialization of the variable value_type value; I can see that the struct foo is typed as the wrapper<int> b...
[4 replies] Last: [quote=lostwithcpp]this is only for structs, not classes? Technically... (by Peter87)
by Cplusc
C1090 error (1,2)
 
I am getting the following annoying and frustrating error which appeared suddenly out of nowhere. the code was working just fine and I don't know what happened....
[23 replies] Last: hardware that old wouldn't be able to slot enough ram to run it either... (by jonnin)
by PacR
Read nested structures from file.
 
Hi guyz im having trouble reading structures from text file containing: // this is example.txt structname1{ hp 50 mp 10 structname2{ ...
[19 replies] Last: As another take on this, consider: #include <iostream> #include <fs... (by seeplus)
How to find the Type of a struct that is passed as an argument and the template arguments for a lambda function?
 
The question I have pertains to the type of the structs that are passed as a function argument into this function template<class Arg> Result operator()(A...
[5 replies] Last: thanks for all the help (by lostwithcpp)
  Archived months: [may2024]