c%2b%2b11's questions - English 1answer

43.487 c%2b%2b11 questions.

Update: Fixed. Very simple solution. I just have to add in my Add_Executable method. Here: add_executable (POC eb_pms.cpp url_binder.cpp) So this problem looks pretty small, yet, I am unable to find ...

I have been studying addition of rvalue reference in C++11. It wasn't straightforward but I feel like I am finally starting to get a grasp of it. However there is one particular instance where I am ...

I'd like to use constexpr versions of standard <cmath> functions like exp, log, pow in a portable way. I currently have a non-portable solution g++ treats these functions as constexpr - a non-...

I wrote a small C++ program to illustrate something to a friend, and noticed curious behaviour: The program does not exit or react to CTRL+C after the second print when run in cygwin, but works as ...

I am moving towards C++11 from C++98 and became familiar with auto keyword. I was wondering why do we need to explicitly declare auto if compiler is able to automatically deduce the type. I know C++ ...

When you have a derived object with a move constructor, and the base object also has move semantics, what is the proper way to call the base object move constructor from the derived object move ...

Are all standard library header files installed with mingw32-gcc-g++ package? Thanks and regards.

Has anyone ever combined the classic generic factory by Andrei Alexandrescu (page 208 of Chapter 8 in Modern C++ Design) with the 'multifunction' capabilities of Boost.TypeErasure? That is, the ...

I have an application that has backend written in c++ and it's UI is developed using java swing library. I want to integrate these two in .exe application, any ideas how to integrate a java and c++ ...

A::thread was created by main thread. Can I join A::thread into the thread goo ? struct A { std::thread thread; void foo() { thread=std::thread{[]() { sleep(10); }}; } }; void goo(...

I have a class, something like BizClass below. I'd like to define a templated function and a specialization for a particular concrete type. I'm not sure of the appropriate syntax. template <class ...

matrix 1: 0x02 0x03 0x01 0x01 0x01 0x02 0x03 0x01 0x01 0x01 0x02 0x03 0x03 0x01 0x01 0x02 matrix 2: 0x63 0x53 0xe0 0x8c 0x09 0x60 0xe1 0x04 0xcd ...

I am a newbie in Threading in C++. I need your help regarding usage of mutex and lock_guard (this part doesn't matter). I have a main function and a secondary functions. Please tell me why ...

I am working on a http parser, and it looks like boost.beast is a nice one. However, I still have some questions: *** Assume HTTP Request POST data already received via boost.asio socket. Stored ...

C++17 §10.1.5/1 states: The constexpr specifier shall be applied only to the definition of a variable or variable template or the declaration of a function or function template. A function or ...

I want to know how cpu use 'mfence' to protect sequential-consistency, who can tell me ?

I have a function that looks more or less like this: template<class C> auto f(C const& c) -> decltype(begin(c)){ using std::begin; return begin(c); } The body of the function ...

I think that I vaguely recall that one of the newer c++ standards (maybe its c++11, or maybe 14?...17??) allows you to initialise a struct, whereby you can define a struct and then initialise it ...

Is there a way to limit the MSVC to only support c++11 features but not anything from c++14 or 17? I am using MSVC++ 14.1 _MSC_VER == 1910 (Visual Studio 2017 version 15.0) Thanks!

How much of a difference do modern compiler optimization techniques make? Do they actually provide a noticeable speedup? For example: Are there any examples of C++11 code that will run faster with ...

I am trying to parse a stream by using popen with a command that returns a constant stream of output lines. This makes the application to get stuck on the fgets() call. Here's the method: std::...

REGISTER_OP("Forward") .Attr("F: {float, int32}") .Input("img0: F") .SetShapeFn([](::tensorflow::shape_inference::InferenceContext* c) { // c->set_output(0, c->Matrix((3,4,3,3))); c->...

I would like to know if there is any difference the following two types of std::vector initialization in C++11 and later. std::vector<int> v1 {1, 2, 3, 4, 5}; std::vector<int> v2 = {1, 2, ...

Let's say I have this little fixed-dimension matrix class: template<size_t M, size_t N> struct MatMN { std::array<std::array<double, N>, M> rows; double* begin() { return rows....

There is a range-based for loop with the syntax: for(auto& i : array) It works with constant arrays but not with pointer based dynamic ones, like int *array = new int[size]; for(auto& i : ...

I'm creating a simple debug thread name database (because you can't give thread a name in windows, you can only send that name to debugger). I have this header file: threadname.h class ThreadNameMap ...

When compiling my .cpp file with Rcpp in R, this error message comes : undefined reference to `boost::system::generic_category()' But when I remove the // [[Rcpp::plugins(cpp11)]] line, there isn'...

Source Code I calculate the sum of a billion numbers generated by uniform_real_distribution #include <iostream> #include <random> using std::cout; using std::endl; using std::mt19937; ...

I want to define a type that be equal to an array of 16 byte. Something such as this: typedef uint8_t[16] mynewType; but I am getting error. How can I define such type? I am getting several errors ...

1) Is the following declaration of a naturally aligned pointer: alignas(sizeof(void *)) volatile void * p; equivalent to std::atomic<void *> in C++11? 2) Saying more exactly, is it ...

For any given question I have to take 't' test cases each a string. I have used the following code in c++ for the same: { int t; cin>>t; while(t--){ string s; getline(cin, s); ...

Code in question: #include <atomic> #include <thread> std::atomic_bool stop(false); void wait_on_stop() { while (!stop.load(std::memory_order_relaxed)); } int main() { std::thread ...

I have written a class multi_array which is sort of an extension of std::array to multiple dimensions. template <typename T, std::size_t... N> class multi_array { template <std::size_t......

So lets say I have: struct test { bool a; int b; }; int main() { std::unique_ptr<test> ptr; // don't init the ptr try { if (!ptr->a) { ...

I am currently having trouble finding an element of a button that does not have an ID. The only method I know of is: webBrowser1->Document->GetElementById("submit")->InvokeMember("Click"); ...

This question origins from another question that Why isn't a lambda that captures variables by reference convertible to a function pointer? . It seems like that the lambda with a capture list is ...

I am currently trying to use the boost::regex library in my Android native lib on Android Studio. But I get this two linker errors: F:\Tools\dev\Android\ndks\crystax-ndk-10.3.2/sources/boost/1.64.0/...

#include <thread> #include <atomic> #include <cassert> std::atomic<bool> x = {false}; std::atomic<bool> y = {false}; std::atomic<int> z = {0}; void write_x() { ...

I need to build Boost 1.62 and 1.63 on a Fedora 24 machine, but using GCC 4.9.3 or GCC 5.4.0 (depending on the version CUDA, which is the reason why I need an older compiler). But if I set the custom ...

void _function_(std::vector<long long>& results){ results.push_back(10); return ; } int main(){ std::vector<std::thread> threads; std::vector<std::vector<long ...

Avoiding Downcasting

0 answers, 114 views c++ c++11 c++14
How do you go about preventing downcasting when using interfaces? I have read some answers on stackoverflow that if you have to downcast then you most likely have a weak interface. How do you guys go ...

I have a simple makefile which finds the CPP files relative to it and builds the target from there. How could I modify this to also precompile the header files relative to it when building the target? ...

I do (I think) understand what a consume operation is when it deals with atomic operation. However, since there is no data directly linked to a fence, I wonder if there is case where it is useful to ...

I successfully implemented my own thread_pool class where I can submit lambdas that can return any value but can only take zero arguments. I would like to improve it, such that it can work like std::...

I'm attempting to create a matrix class where the output of the overloaded plus operator is a new matrix that contains the sum of the two matrices passed in. However, I would like to preallocate the ...

Related tags

Hot questions

Language

Popular Tags