General C++ Programming - May 2023

by frek
Passing pointers to function taking iterators
 
Suppose for some reason this code is meant: void accum(std::vector<double>::iterator bg, std::vector<double>::iterator end) { std::cout << std::accumulate(bg,...
[12 replies] Last: [quote=frek]Why don't you, Peter, as a great coder, go for C++20/23. T... (by Peter87)
by Gyiove
event class and dynamic bind paramaters
 
I have this c++ class here which can register class function into event class and then call them all with 1 function later. Code: template < typename......
[3 replies] Last: You're making this more complicated than necessary, IMHO. You don't n... (by dhayden)
by frek
C++ multithreading deadlock example
 
std::mutex m1, m2; void f_1() { std::unique_lock l1{m1}, l2{m2}; } void f_2() { std::unique_lock l1{m1}, l2{m2}; } Suppose f_1 starts first and l1 lock...
[9 replies] Last: got it, thanks. (by frek)
How should I export the API of a shared library?
 
I use Eclipse CDT on a Fedora machine for developing C++ code. In the first project I programmed in C++, I wrote a client for Basex (Open Source XML database). ...
[7 replies] Last: I've been trying for nearly a week to create submodules for libBasexCp... (by Bengbers)
Shortcut Icon same as application icon
 
I have a compiled Win32 app that uses a .ico resource file, declared in the .cpp file. My icon displays fine in the application when running. How can I automa...
[2 replies] Last: I think you can direct the shortcut to the icon, or the file where it ... (by jonnin)
Exit condition for 'std::unordered_map' iterator loop with a step size > 1
 
Suppose I have an std::unordered_map containing a large number of elements. I need to process each element and I want to speed up the overall process by usi...
[7 replies] Last: C++23: for( auto&& [k,v] : g_input | std::views::as_const | std::view... (by JLBorges)
Implement fast hash function
 
Hi everyone, I have a project where I need to apply a hash function to some variables in a sequential way. That action will be done frequently so I need it...
[4 replies] Last: Thanks for your help! These algorithms seem to be what I need. (by Alejandro Antonio)
freeglut dll and lib
 
Hello all, I have a c++ project in Visual Studio 6. I have a GL folder where I keep the glut32.lib and dll. I recently added freeglut.dll, .h _extx.h _ucal.h bu...
[7 replies] Last: I installed VS 2012 That version is not as ancient as VS6, but it is... (by deleted account xyzzy)
Linkers and Libraries
 
I've been building a framework for about a year now that builds an OOP for SDL (recently updated for SDL3). Now I would like to set it up so my user only has to...
[4 replies] Last: Pkg-config was really easy to set up, it just requires writing a singl... (by newbieg)
how to specify gcm.cache in g++ command line option?
 
g++ needs to have access to the compiled modules that are required by a module. Thus,. if we compile the first module that has no inter-module dependecies like ...
[2 replies] Last: the gcm.cache contains compiled information from the module that is re... (by JUANDENT)
by kitfox
Should I cache to disk the memory used by my undo stack?
 
I've written a program what uses an undo stack to keep track of edits the user makes. At the moment it is using a lot of memory because some of the states it h...
[3 replies] Last: I think you shouldn't care too munch, unless we really talk about mas... (by kigar64551)
compiling modules C++ 20 with g++ 12.2.0
 
I am using the following commands: g++ -std=c++20 -fmodules-ts -c -x c++ cxx_type_traits_polyfill.ixx g++ -std=c++20 -fmodules-ts -c -x c++ type_traits....
[1 reply] : Take a look at this: sqlite_orm::internal ::polyfill Is that the na... (by coder777)
comparing actual to expected values in neural network
 
hello i am implementing a neural network using the Eigen library (for matrix multiplication). in order to calculate the loss, and to start computing the error...
[no replies]
by Geckoo
MIPS
 
Hello. I am working on a tiny interpreter for MIPS language. It works well as expected. I have implemented some classical OPs with a clever parser. I think that...
[no replies]
why C\C++ don't have a standard Graphics, Sound or others libraries?
 
why C\C++ don't have a standard Graphics, sound or others libraries? on Turbo C\C++ we have the Graphics library
[5 replies] Last: thanks for all to all (by Cambalinho)
Fixing wrong radius values on table output?
 
Hello, For a project I am supposed to have my code output a table as temperature and radius change going from the core of a star to its surface. So far t...
[14 replies] Last: Try this one. It's based on the linear (for density) stellar model in... (by lastchance)
by frek
CTAD
 
Hi all, template <typename T> struct Length { T sz; }; void foo(Length len) { std::cout << len.sz; } int main() { foo(Length{5}); } I get the error: ...
[6 replies] Last: Note that a class template is not a class, it's something you use to g... (by Peter87)
Try to write Bubble Sort Program
 
Hi, I am confused about some code I found online(https://www.techgeekbuzz.com/blog/recursive-bubble-sort-in-c/). It works, but there is a function I need to ...
[5 replies] Last: If you actually do look at the link the code the spammer vomited up is... (by deleted account xyzzy)
How to specify a concept that requires a const method?
 
Hi, I have this: class Circle : public GeoObj { public: virtual void draw() const override; }; So I have created a concept like this: ...
[2 replies] Last: yes you are correct about every type being convertible to void! Thank... (by JUANDENT)
How should center alignment of child components work?
 
I'm working on a class called "LayoutManager" which provides interface to layout child windows or controls within parent window. There are several enumerations...
[6 replies] Last: Option 1 and 4 are "left first then right" That is from the center, p... (by malibor)
May 2023 Pages: 12
  Archived months: [apr2023] [jun2023]

This is an archived page. To post a new message, go to the current page.