c++ Questions
3
Let's say I am writing a class that passes a std::variant<A,B> to another class.
While I design the class, I decide I'd like to keep a copy of the last thing that was passed to that other cla...
Audwen asked 5/11 at 14:31
1
Solved
I have a project where I'm putting objects in an unordered_map that can logically chain together with other objects in the map. To represent this chain, I store a reference to the next object in th...
Beera asked 31/10 at 12:1
3
Solved
I'm trying to find the equivalent of a critical section for C++11 , is the new C++11 mutex concept process-bound (e.g. enforces mutex only on the user-space) ? Perhaps it's implementation specific ...
Floaty asked 7/5, 2014 at 13:47
1
Solved
I have the following function that takes a symbol table and adds a composited function to the symbol table:
void add_function(exprtk::symbol_table<double>& symtab) {
using compositor_t ...
2
This is a follow up to this question, Restricted access for allocated arrays belonging to separate object, after discovering that returning by value across compilation units doesn't help to hint th...
Fauch asked 21/10 at 18:23
2
Solved
Assuming alignment is a uintptr_t power of 2, looking for the next properly aligned address can be done using this expression:
(address + alignment - 1u) & ~(alignment - 1u)
This is used in cu...
Earthwork asked 23/10 at 23:36
2
Consider this example:
#include <iostream>
#include <atomic>
#include <thread>
#include <chrono>
#include <cassert>
int main(){
std::atomic<int> v = 0;
std::at...
Eijkman asked 23/10 at 13:20
0
C++17 allows scoped enums to be initialized with integers as long as it's not narrowing, e.g.
#include <cstdint>
enum class e16 : uint16_t { x16, y16 };
enum class e32 : uint32_t { x32, y32 }...
Andria asked 23/10 at 23:35
1
Solved
I was thinking about the utility of non-standard __restrict keyword in C and C++ and how its effect can be emulated by carefully declare (disjoint) value objects .
Restrict is usually explained thr...
Midget asked 20/10 at 20:45
5
I'm hoping this isn't a duplicate question, but I've searched in some detail and haven't found my exact case before.
I have a simple struct that I also want to be able to access as a simple byte a...
2
Solved
I want to find the index of the first integer in an array of integers which is <= key. I can do it with binary search in log2(N)+1 compares. Shouldn't it be possible with only log2(N) compares?
...
Dg asked 13/8, 2015 at 18:48
1
Solved
Consider this example:
#include <iostream>
#include <atomic>
#include <thread>
struct SpinLock{
std::atomic<bool> state;
void lock(){
bool expected = false;
while(!stat...
Tricksy asked 17/10 at 13:41
4
Solved
I have an android application in QT.
I would like to call android settings from a button.
I used this code in Java :
public void usb(View v){
Intent intent = new Intent();
intent.setClassNam...
Gangrel asked 29/7, 2014 at 20:42
3
Solved
I developped an application in C++ using Qt for the graphic interface and now I would like to release it for linux and for Windows.
I've been looking through documentation, forums and tutorials but...
1
Solved
Should the following program be rejected? Clang seems to accept it.
template<typename T>
concept c = requires { T::n; };
struct z;
constexpr bool b(auto...) { return c<z>; }
struct z { ...
Refutation asked 12/10 at 22:32
7
Solved
I'm trying to make a list of template classes of variable types. So the idea is to loop of a list of objects that all have a common function, e.g. getValue, but a different type. The type could be ...
3
I am trying to implement two classes A and B which contain data stored in std::unique_ptr container, and A could transform to B with some calculation. The class A and class B are shown as below. Th...
Origan asked 25/2, 2020 at 2:6
2
Solved
I was reviewing a code I proposed to initialize a std::array at compile-time for non-default-constructible objects: https://mcmap.net/q/905632/-idiom-for-initializing-an-std-array-using-a-generator...
Spoke asked 8/10 at 9:48
1
Solved
Under normal circumstances, creating a shared handle in DX using CreateSharedHandle, then using glImportMemoryWin32HandleEXT in OpenGL should allow sharing. I tried rendering a triangle in DX and d...
2
2
Solved
There is a part in the C++ standard about multi-threading memory model that I don't understand.
A visible side effect A on a scalar object or bit-field M with respect to a value computation B of M...
Swinge asked 18/4, 2020 at 0:23
1
Is there an equivalent of the GNU "strip" tool for Windows?
I'd like to strip out the names of any internal symbols from a static library, so that running dumpbin /symbols mylib.lib will no longer...
Soundless asked 16/10, 2016 at 22:20
5
Solved
In Python I can do this:
>>> import itertools
>>> for i, j, in itertools.product(range(3), repeat=2): print i, j
...
0 0
0 1
0 2
1 0
1 1
1 2
2 0
2 1
2 2
Is it possible to have ...
2
Solved
In this example code, why isn't
using IParameterBase<TYPE>::operator=;
working, and the base class assignment operator working?
I recently changed to this templated version, previously I had ...
Lucifer asked 3/10 at 11:39
1
Solved
I understand that std::is_constant_evaluated() was useful to determine compile time evaluation in C++20.
But since C++23 we have if consteval.
However there is no mention of deprecation for std::is...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.