23 questions from the last 1 days
Advice
2
votes
4
replies
66
views
determine cpu after c++ compilation with gcc?
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 ...
2
votes
0
answers
41
views
Can an exported function template invoke a module-local function using ADL?
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 ...
2
votes
2
answers
91
views
Declaring aliases for anonymous classes
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 ...
-3
votes
0
answers
92
views
Does std::string have a constructor overload for string literal or char array?
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, ...
0
votes
2
answers
119
views
Could we add elements in a vector with "cin >> " in C++
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.
0
votes
0
answers
136
views
How to implement a list with an efficient "index of" operation?
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 ...
5
votes
1
answer
101
views
What's the difference between `extern "C" /*...*/` and `extern "C" { /*...*/ }`
Both GCC and Clang reject
extern "C" static void foo() {}
but accept
extern "C" {
static void foo() {}
}
Aren't these supposed to be equivalent?
0
votes
0
answers
45
views
OneDrive sharedWithMe returns only one item
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 ...
0
votes
1
answer
61
views
Windows 11 raw input API bad performance compared to Windows 10
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 ...
Best practices
1
vote
7
replies
77
views
How to use in the same piece of code two different libraries with exact same declarations
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 ...
Best practices
0
votes
7
replies
153
views
Should I use std::move when returning a local std::string as std::optional<std::string>?
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 ...
0
votes
0
answers
49
views
Is it possible to compile C++ that user types to Wasm Client side using web containers
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://...