• 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]
Making a shared_ptr out of a stack object corrupts the heap!!
 
Hi, The following code is incorrect: Customer customer = { 0, "John Doe", "johndoe@example.com" }; auto cc = std::make_shared<Customer>(customer);...
[2 replies] Last: Note: std::make_shared<T>() creates a new heap-allocated instance of... (by kigar64551)
Testing restart functionality in C/C++
 
Hello! I am trying to implement "restart" functionality in my code, where if for some reason the code stops (i.e. iterations drop) I can pick up from where I s...
[1 reply] : you will get more help if you put it in a repo where we can see the co... (by jonnin)
Need a data structure where I can map a string to a type
 
Hi, Need a certain compile time map m like this: using Type = typename m["Customer"]::type; // Type would be Customer How can i do this? Regar...
[10 replies] Last: It's not necessary to use an enum. It was just a suggestion. (by Peter87)
Save to file with vector (dynamically)
 
I have created a programme that does calculations and generates results from those calculations. The imformation generated is stored in variables for later d...
[11 replies] Last: i outside the loop is not a c++ error. It is a questionable programmi... (by jonnin)
what does T = 0 mean in a template parameter?
 
What does T = 0 mean in the following code: template<typename T, T = 0> T moduloOf(T a, T b) { return a % b; }
[4 replies] Last: Indeed: "initialized with value 0" limit what type the T can be? (by JUANDENT)
When does early binding happen?
 
Thing 1: Static binding takes place during compilation - function calls are replaced with an instruction saying "go here for the appropriate function definit...
[1 reply] : I guess this is what's called "devirtualization" which GCC has optimiz... (by Peter87)
Would like some testers please
 
Sorry is this is the wrong forum. If possible I would like someone to try out my program. It works for me but I want to know if it works for other people. ...
[10 replies] Last: There's a special GitHub repo set up to make it easy to learn how to f... (by deleted account xyzzy)
_Safe_add checks for overflow but does not do anything to report the problem!
 
Looking at VC++ source files I find in ratio the following: what is the purpose of _Safe_add_integer_arithmetic_overflow_error? inline void _Safe...
[5 replies] Last: Neat example, thanks. (by Ganado)
templates class friends strong types
 
Hello all, first a bit of background. Land Surveying involves many types of: Angles, Bearings; Distances; Co-ordinates; and there are many types adjustments ...
[8 replies] Last: I read Jonathon Boccara's blog That article is from 2016, C++20's co... (by deleted account xyzzy)
unresolved external symbol "int const value"
 
One file states: extern const int value; extern const int this_cpp; const int mine = value; const int yours = 40; and another cpp states co...
[1 reply] : Your other.cpp file also needs to say extern, otherwise it's taken to ... (by salem c)
How to improve my C/C++ posts to CplusPlus forum
 
I would like to know how to increase the enjoyment and benefit of my posts to the readers of the CplusPLus forum. May I have your input on the following impro...
[3 replies] Last: This isn't like a certain well known site where they delete your ques... (by deleted account xyzzy)
by stav
A class that supports taking ownership and not
 
I'm writing a Parser class. It takes 1 argument in its constructor which is a Lexer object. The question is i dont know whether i should take it as a reference...
[2 replies] Last: doing it both ways will make the code that uses the tool a bit harder ... (by jonnin)
How can a export an existing concept from a c++20 module
 
Hey guys. I have been using concepts for some time and they work very well. Now I'd like to add module support. The important part here: I need to be backward...
[1 reply] : If'n I understand what you are trying to do it would require a very de... (by deleted account xyzzy)
Redefinition Errors on Build (1,2)
 
Win10, MSVS 17.11.3, C++ latest, console app. I'm a novice, hobbyist coder. I have a not-too-esoteric console app that contains a file for the main() function...
[25 replies] Last: [quote=George PlusPlus] Reference about using tags here at CplusPlus ... (by SimpleCoder)
How come a concept receives 2 template parameters but only one is used?
 
How come a concept receives 2 template parameters but only one is used? Here is use of concept Arithmetic in requires clause (2 template parameters) ...
[1 reply] : There are two syntaxes involved, both of which ultimately supply the s... (by DizzyDon)
Parameters and move semantics
 
Here's some error logging code in my program (basically): void SetError(std::string&& arg){ error = arg; } try { // something } catch (st...
[10 replies] Last: I think I've actually got a handle on this now - thank you very much! (by LsDefect)
why pass by universal reference?
 
I understand by universal reference the argument passing following this pattern: template<typename T> void f(T&& t) as in template< class Exe...
[1 reply] : Universal references are useful when you want to move the argument if ... (by Peter87)
Cannot convert from T to T&
 
Cannot convert from T to T& as in the following: auto f(const map<string, int>& mp) { auto p = find_if(mp.begin(),mp.end(), Greater_than{ 42 }); return p; ...
[4 replies] Last: Is there any harm in using auto&&? No, I don't think so. does f re... (by Peter87)
How to write a concept that requires one to create an object to specify that that constructor must exist
 
I need to write the following concept: template<typename T> concept Element = requires (T a, T b) { a = b; T c{ a }; }; I know I can do ...
[no replies]
  Archived months: [sep2024]