c++11 Questions
2
Solved
I'm working on code that runs on a raspberry pi 3. And got the following error on my logging classes.
==1297== Invalid read of size 8
==1297== at 0x4865D1C: ??? (in /usr/lib/arm-linux-gnueabihf/li...
4
Solved
I am writing library which wraps a lot of functions and methods from other library. To avoid coping of return values I am applying std::forward like so:
template<class T>
T&& wrapper...
Portwin asked 18/10, 2012 at 6:4
2
Solved
All,
Referring to the question in std::lock still caused deadlock
I still couldn't figure what is the problem in the below code. Can somebody please explain the problem and how to fix this? Why do...
Sniffle asked 21/11, 2019 at 10:12
10
Solved
Consider the following: (Wandbox)
#include <array>
#include <algorithm>
#include <iostream>
template<typename T, int N, int M>
auto concat(const std::array<T, N>&...
4
Solved
Can somebody please provide some insights on this? Is the lambda capturing external variables, or is the outside world capturing values produced by the lambdas? What does it mean for a certain vari...
7
Given a
template<typename First, typename... Tail>
struct something
{
std::tuple<First, Tail...> t;
};
How can I get a std::tuple<Tail...> that contains all elements from...
1
Solved
Consider the following code, with adjacent mutex sections containing shared memory accesses:
std::mutex mutex;
int x;
void func() {
{
std::lock_guard lock{mutex};
x++;
}
{
std::lock_guard lo...
Captor asked 22/6 at 13:0
3
Solved
What is the difference in getting a value through aMap[key] and aMap.at(key) in C++?
6
Solved
How to convert std::chrono::time_point to string?
For example: "201601161125".
Hardandfast asked 18/1, 2016 at 14:28
4
Solved
I have this warning pop up when I'm trying to compile the following union:
10:5: note: offset of packed bit-field 'main()::pack_it_in::<anonymous struct>::two' has changed in GCC 4.4
#pragma...
Loose asked 21/12, 2016 at 1:22
6
Solved
Reading various questions here on Stack Overflow about C++ iterators and performance**, I started wondering if for(auto& elem : container) gets "expanded" by the compiler into the best pos...
Stumpy asked 30/5, 2012 at 18:2
3
Solved
I'm trying to understand memory fences in c++11, I know there are better ways to do this, atomic variables and so on, but wondered if this usage was correct. I realize that this program doesn't do ...
2
Should *(int*) be just int in C++11?
I run compile below code with g++ -std=c++11, it outputs "0", which is out of my expectation.
int num = 0;
int *num_ptr = &num;
cout<&l...
9
Given the following code:
struct Window{
void show();
//stuff
}w1, w2, w3;
struct Widget{
void show();
//stuff
}w4, w5, w6;
struct Toolbar{
void show();
//stuff
}t1, t2, t3;
I want to sh...
4
Solved
The code below prints 0, but I expect to see a 1. My conclusion is that lambda expressions are not invoked by actually passing captured parameters to the functions, which is more intuitive. Am I ri...
9
Solved
Is there a way to access the iterator (I suppose there's no loop index?) in a C++11 range-based for loop?
Often we need to do something special with the first element of a container and iterate ove...
Ashlynashman asked 19/1, 2014 at 11:9
1
Consider:
struct A {};
struct B {
operator A&() volatile;
operator A&() const;
operator A&&();
};
B b;
const A& a = b;
(godbolt link: https://godbolt.org/z/jcYch9jdW)
GCC,...
Crowbar asked 4/6 at 10:56
2
Solved
I'd like to use std::is_invocable, but it is available only since C++17, and we are using C++11 Standard.
Is there any way to emulate the functionality using C++11?
Convex asked 5/7, 2018 at 9:36
4
Solved
I have an uncopiable class. Copying this would be problematic. I want to guarantee that it won't be ever copied, so I made its copy constructor deleted:
class A {
public:
A();
A(const A&) =...
Interleaf asked 6/7, 2016 at 13:8
3
Solved
I read a thoughtful series of blog posts about the new <system_error> header in C++11. It says that the header defines an error_code class that represents a specific error value returned by a...
3
Trying to use AX_CXX_COMPILE_STDCXX_11 in my configure.ac file like this:
...
AX_CXX_COMPILE_STDCXX_11(, optional)
...
However, results in error:
./configure: line 16126: syntax error near unex...
2
I have a main.cpp including a.h (that has its own a.cpp)
a.h includes the header only library "stbi_image.h" as such:
#ifndef STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#include "st...
Yang asked 11/4, 2017 at 14:26
8
Solved
I have recently started using Visual Studio 2019 for my C++11 project. VS2019 converted the project and it compiles into an executable. But I can't open my resource (.rc) file in the Resource Viewe...
Fennell asked 4/6, 2019 at 9:56
2
Solved
I haven't found any wording in the C++11 standard that says unscoped enums are deprecated, but from a pragmatic perspective I'm wondering if they are still useful. A lot of people on my team have g...
7
Solved
How can I make a class template that returns whether any of its variadic types are equal to the first type. I want to be able to do this:
is_same<T, A, B, C>::value; // true if T is one of A...
Ruyter asked 10/6, 2013 at 20:32
© 2022 - 2024 — McMap. All rights reserved.