Skip to main content
Filter by
Sorted by
Tagged with
Advice
2 votes
4 replies
66 views

Does anyone know if there is, in c++, any way to determine at runtime the cpu characteristics of the machine that compiled the code? For example, in gcc (which I'm using) the preprocessor variable ...
user3195869's user avatar
2 votes
0 answers
41 views

Let's say that we have a simple main.cpp file which contains only a single call of a function bar which is defined in the module a: import a; int main() { bar(1); } Then let's take a look at the ...
siga's user avatar
  • 451
2 votes
2 answers
91 views

This is an attempt to make an alias to an anonymous class: struct { int i = 0; } a; // error C7626 in MSVC using A = decltype(a); This produces an error in Visual Studio: error C7626: unnamed ...
Fedor's user avatar
  • 24.7k
-3 votes
0 answers
92 views

A string literal is of type const char [N], and you can pass this type to a templated function that looks like: template <uint64_t N> void func(const char (&arg)[N]); On cplusplus.com, ...
Zebrafish's user avatar
  • 16.3k
1 vote
2 answers
118 views

Could we add elements in a vector<int> n; with cin >> n[i]; in a loop in C++? Just interested in knowing and it's my first experience using stack overflow.
volodkya's user avatar
0 votes
0 answers
136 views

I'm interesting in possible implementation approaches for a quite special variant of a list, with the following requirements: Efficient inverse lookup ("index of"): "give me an index ...
cubuspl42's user avatar
  • 8,581
5 votes
1 answer
101 views

Both GCC and Clang reject extern "C" static void foo() {} but accept extern "C" { static void foo() {} } Aren't these supposed to be equivalent?
yuri kilochek's user avatar
0 votes
0 answers
45 views

A request from a standalone application to the sharedWithMe [1] endpoint returns only one item. Scopes used for authorization are: files.readwrite.all group.readwrite.all sites.readwrite.all ...
josuegomes's user avatar
0 votes
1 answer
61 views

With my code which is just a regular RAW input example.... WM_INPUT, RIM_TYPEMOUSE... I'm getting on Windows 10 the full 1,000Hz of my mouse and on Windows 11 I'm getting about 128Hz. How to fix this ...
Gr3g's user avatar
  • 21
Best practices
1 vote
7 replies
77 views

I have two numerical maths libraries given by DLLs (I am under Windows) and header files. (I can't modifiy the headers and anyway there are dozens of them. I also don't have have access to a code that ...
Olórin's user avatar
  • 3,881
Best practices
0 votes
7 replies
153 views

My confusion is about the return statement inside readFileContents: The function returns std::optional<std::string>, but the local variable is a std::string. NRVO doesn’t apply here because ...
sam's user avatar
  • 911
0 votes
0 answers
49 views

I currently have been trying to use WebContainers + emscripten for my compilation, and i want to know if it is possible, and if not other ways to do it. hello.js import { WebContainer } from 'https://...
ARGHHHHHH's user avatar
-6 votes
0 answers
72 views

INTRO I am getting unwanted pulsing and slowing down in rendering 2d particles, which should be drawn faintly (low alpha) and leave a fading trail under the influence of gravity. Below is a ...
Alabastine's user avatar
1 vote
0 answers
111 views

Consider the following code: #pragma omp parallel for (int run = 0; run < 10; run++) { std::vector<int> out; #pragma omp for for (int i = 0; i < 1'000'000; i++) { ... } } ...
F.X.'s user avatar
  • 7,475
7 votes
1 answer
210 views

Suppose the following foo function has a function parameter and a template parameter, both with the same default value: template<int Line=std::source_location::current().line()> auto foo (int ...
abcdefg's user avatar
  • 4,442
-1 votes
0 answers
116 views

I have a simple C++ project which uses the CoCreateInstance to access and use some C# code (com-exposed class). The simple code looks like: // ... hr = CoCreateInstance( CLSID_rclsid, NULL, ...
Kaktus's user avatar
  • 9
11 votes
7 answers
1k views

I want to use circular queue with different types and lengths in a project which mainly consists of C code. I'm thinking about implementing the circular queue as a C++ template struct. How to expose ...
Jackoo's user avatar
  • 503
0 votes
4 answers
113 views

I was attempting the binary tree inversion question on Leetcode https://leetcode.com/problems/invert-binary-tree/ I came up with this solution TreeNode* invertTree(TreeNode* root) { if (root ==...
Raghav Wadhwa's user avatar
Advice
2 votes
6 replies
110 views

Why does the following code throw an EOF exception during reading from the stream? The stream state is goodbit before reading. All works as expected if I do not enable exception throwing. https://...
Serge Kork's user avatar
-3 votes
0 answers
131 views

I have a massive C++14, Win32 project that uses legacy MFC. So far, project compiles and works fine at Platform Toolset v142 (vs2019) and latest Windows 10 SDKs. However, when I set the Platform ...
Luiz Henrique's user avatar
3 votes
2 answers
232 views

I see many places in public repositories, where the first and last iterators of std::vector/std::string/std::string_view are converted into pointers using the combination of &* operators. In ...
Fedor's user avatar
  • 24.7k
Advice
0 votes
6 replies
307 views

I'm looking for a way to store type "dynamicly" in a using (or concret implementation) that would be modifable and accessible at compile-time. I would like something like: struct ...
DipStax's user avatar
  • 572
3 votes
1 answer
192 views

In this insertion sort implementation, is the line arr[pre + 1] = curr; optional? Since we are already swapping elements inside the while-loop, won't the current element automatically reach its ...
SHIVRAJ SINGH DEORA's user avatar
3 votes
1 answer
159 views

In the below code, I return a std::vector<A> from the get() function. If I make the std::vector<A> be a const type, the compilation fails, otherwise it passes. Can somebody explain this ...
Harry's user avatar
  • 4,132
0 votes
2 answers
121 views

I am trying to implement a lock-free multiple-producer-single-consumer ring buffer in C++. Here is the full definition and the test code. #include <iostream> #include <memory> #include <...
God_of_Thunder's user avatar