Skip to main content
Best practices
8 votes
28 replies
2k views

I'm moving from C to C++ and I'm trying to avoid using C practices in C++. It is said that raw pointers are a C feature, and that in C++ I should use smart pointers instead, yet every example I have ...
noname noname's user avatar
11 votes
5 answers
1k views

Consider the set {A,B,C} and an operator op defined by the following table A op A = A A op B = A A op C = A B op A = A B op B = B B op C = C C op A = A C op B = C C op C = B I would like to encode A,...
abcdefg's user avatar
  • 4,915
Advice
2 votes
11 replies
389 views

I watched a few tutorials on YouTube. They said to assume a 32-bit architecture and then said "a single CPU cycle can only access a word (equals the CPU's native size i.e 4 bytes) at a time from ...
Random Guy's user avatar
Advice
1 vote
17 replies
195 views

The following code compiles on std >= C++20 but fails to compile on std < C++20. This holds for msvc, gcc and clang. #include <cstdio> int main() { struct byte { unsigned ...
Puzomor Croatia's user avatar
Best practices
2 votes
5 replies
151 views

Suppose I have a C-style matrix of elements typedef struct _RAW_DATA{ int a; int b; }RAW_DATA; inside a templated class, that defines the size of the matrix: template<size_t TDim> ...
user2281752's user avatar
2 votes
2 answers
154 views

Is there a way to prevent implicit conversions happening in concepts? For example, this example compiles with GCC and clang when I actually want it to give an error that the char constructor is ...
Hello Worlder's user avatar
1 vote
2 answers
367 views

As C++26 standard's timeline is getting near, I want to know: What is(are) the reason for no built in support of networking by the C++ standard. That is, what exactly are the problems that lead to ...
Richard's user avatar
  • 47.7k
Advice
3 votes
8 replies
132 views

I want to use multiple threads to decode PNG files to speed up loading in my C++ game engine. The easiest solution is to use IMG_Load from SDL_Image, as I already use SDL, e.g.: surface = IMG_Load(...
Nikolaj's user avatar
  • 1,175
0 votes
2 answers
119 views

I think it's common knowledge that you can't have statements in the global module fragment, and that the global module fragment is restricted to "preprocessor" directives only. With: module; ...
Zebrafish's user avatar
  • 16.6k
2 votes
1 answer
133 views

I am reading the WPD_OBJECT_DATE_MODIFIED time value of a file/folder on a Portable Device (WPD) and need to display it similar to how Explorer does. I have a folder whose Date Modified is displayed ...
gene b.'s user avatar
  • 12.7k
2 votes
3 answers
113 views

I want to pass a C-style array to a function taking a std::span, but overload resolution chooses to convert the array to bool instead. Is this behavior required by the standard, or is it a compiler ...
prl's user avatar
  • 12.5k
1 vote
2 answers
108 views

I'm currently working on a project that requires a multi-threaded approach. This project is currently platform specific, i.e. Windows. This is how my read code looks like: #pragma once #include <...
neo's user avatar
  • 67
2 votes
1 answer
95 views

If I use a C++ object's property from QML like this: class Cpp { ... Q_PROPERTY(... aProperty READ getAProperty ... ... getAProperty() { // which engine called me?.. } }; // ...
Ivan's user avatar
  • 509
4 votes
1 answer
121 views

I decided to try a dual screen to display the square as a wireframe vs a colored in square: #include <GLAD/glad.h> #include <GLFW/glfw3.h> #include <iostream> void ...
Kelvin Ohaya's user avatar
4 votes
1 answer
143 views

This is my first time working with CUDA programs. So I just wrote a simple hello world program. #include <stdio.h> __global__ void hello(){ printf("Hello block: %u and thread: %u\n"...
Alvin Alex's user avatar

15 30 50 per page