c++11 Questions
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
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
3
Solved
It's very natural to want to compare std::array's at compile time; and its operator==() is obviously constexpr'able. Yet - it isn't marked constexpr. Is this intentional or an oversight? And - what...
Lime asked 20/8, 2017 at 14:45
4
Solved
I read that pthread is C library and is not compatible with C++ object model, especially when talking about exception handling.
So I wish to know on linux system, how gcc/clang implements std::thr...
Condyloma asked 11/8, 2017 at 10:16
1
I know that, generally, we can forward-declare enums in C++11.
So, why does this:
enum kind_t { kind1, kind2 };
template <kind_t Kind> struct foo {};
template <> struct foo<kind1&g...
Dobbs asked 24/8, 2022 at 21:22
2
I have a module written in python. this module is sort of an interface to many different functionalities I implemented in Python:
EmbeddingInterface.py simply imports this module and creates an in...
Denominationalism asked 7/9, 2016 at 18:7
4
Solved
Let's say that I have a main class SomeManager for keeping track of instances of another class SomeClass. When SomeClass is constructed it calls a method of SomeManager passing a pointer to itself....
Snow asked 13/2, 2015 at 4:8
5
Solved
I have some C++0x code. I was able to reproduce it below. The code below works fine without -std=c++0x however i need it for my real code.
How do i include strdup in C++0x? with gcc 4.5.2
note i...
Milagrosmilam asked 6/4, 2011 at 22:34
3
Solved
At work I've been using linux and the GCC compiler for C++11 and C++14. In some of the code at work, I've used a union to store both a reference and a pointer, as so: (Simplified to just the import...
Contrayerva asked 1/8, 2016 at 4:58
5
Solved
I simply wanna erase the specified element in the range-based loop:
vector<int> vec = { 3, 4, 5, 6, 7, 8 };
for (auto & i:vec)
{
if (i>5)
vec.erase(&i);
}
what's wrong?
3
EDIT: total re-edit because the original was becoming an unstructured mess :) Thanks for everyone's input so far; I hope I worked it into the text below.
Question
I'm in search for a lazily-creat...
Nedranedrah asked 17/9, 2015 at 21:29
2
Solved
unsigned int Tick = GetTickCount();
This code is running only on Windows, but I want to use the C++ Standard library so it can run elsewhere.
I searched std::chrono, but I can't find a function ...
Diminution asked 25/7, 2014 at 13:57
3
Solved
I'm trying to return an int64_t if std::is_integral<>::value is true.
Otherwise, I would like to call to_int64t() on the object.
My attempt below is failing because partial specialisation o...
Angeli asked 24/3, 2013 at 13:19
1
Since C++11, the C++ Standard Library (c.f. Section 25.4.1.1 of a draft verion of the standard) requires the std::sort algorithm to have asymptotic worst case execution time O(n log n) instead of a...
Slacks asked 17/3, 2021 at 8:47
2
Solved
How can I serialize a class (with boost::serialization) that contains a boost::optional?
I.e. the following code will give an error when instantiated.
error C2039: 'serialize' : is not a member...
Placia asked 26/9, 2014 at 14:27
4
Solved
Recently I have been using the := operator in python quite a bit, in this way:
if my_object := SomeClass.function_that_returns_object():
# do something with this object if it exists
print(my_obje...
Hog asked 21/8, 2021 at 3:58
2
Solved
As per the documentation(http://www.cplusplus.com/reference/future/future/get/), which says that:
[emphasis mine]
Once the shared state is ready, the function unblocks and returns (or
throws) r...
8
Solved
Why would one write a C++ lambda with a name so it can be called from somewhere? Would that not defeat the very purpose of a lambda? Is it better to write a function instead there? If not, why? Wou...
2
Solved
I have put together a simple c++ timer class that is supposed to call a given function periodically from various examples on SO as follows:
#include <functional>
#include <chrono>
#inc...
4
Solved
How can I obtain the tuple type of the first elements in a given tuple type?
If I only ask for one element, it should give me the inner type instead of a tuple type of one element.
In code, how w...
6
Solved
I have done a bit of research on the matter but have not come to a concrete solution. I would really like to be able to do this:
public delegate void VoidFloatCallback(float elapsedTime);
public...
4
Solved
Is there a way to identify whether or not a base class is a virtual base class?
std::is_base_of will identify a base class, but I'm looking for something like std::is_virtual_base_of to identify a...
2
Consider the following two snippets of code where I am trying to launch 10000 threads:
Snippet 1
std::array<std::future<void>, 10000> furArr_;
try
{
size_t index = 0;
for (auto &...
Sales asked 22/6, 2017 at 2:24
3
Solved
Now we all sometimes have to work with binary data. In C++ we work with sequences of bytes, and since the beginning char was the our building block. Defined to have sizeof of 1, it is the byte. And...
Alter asked 28/4, 2013 at 5:46
3
Solved
I'm writing different sort functions, which take two iterators and sort sequence. I would like to implement them for any kind of vector and make them typesafe, like this:
template <typename T&g...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.