logo
down
shadow

CPP QUESTIONS

Multicolored dashed line with a dashed pattern using QPen
Multicolored dashed line with a dashed pattern using QPen
will be helpful for those in need Developing the idea of @goug, you can do something like:
TAG : cpp
Date : December 02 2020, 10:46 PM , By : Vincent Jansen
How to deal with an Rcpp::XPtr that may have one of several types
How to deal with an Rcpp::XPtr that may have one of several types
This might help you The best non-macro approach I could come up with so far (using boost::mp11) is the following:Key parts:
TAG : cpp
Date : December 02 2020, 10:46 PM , By : user3045509
How to check if mpz_t number is initialized using GMP?
How to check if mpz_t number is initialized using GMP?
fixed the issue. Will look into that further This is bad practice in C - end of story. You DON'T check that _amount has been initialized! The GMP library is highly optimized, and ensuring an mpz_t object is correctly initialized is the only correct a
TAG : cpp
Date : December 02 2020, 10:46 PM , By : user3045508
What Is a Proper and Elegant Way to Overload Constructors in C++
What Is a Proper and Elegant Way to Overload Constructors in C++
help you fix your problem If I have understood your question correctly then if the initializers of the strings are the same in the both constructors then you can use a delegate constructor
TAG : cpp
Date : December 02 2020, 10:46 PM , By : user3045448
Problem when attempting to change the value of a two-dimensional vector
Problem when attempting to change the value of a two-dimensional vector
With these it helps QVector at() returns a const T, try using operator [] instead, which returns non-const
TAG : cpp
Date : December 02 2020, 10:46 PM , By : CrazyAce
Is it sufficient to only catch exceptions to detect all binary file read/write errors in C++?
Is it sufficient to only catch exceptions to detect all binary file read/write errors in C++?
To fix the issue you can do The fact that read() throws an exception at all guarantees that gcount() cannot be equal to the requested buffer size. You can look at gcount() after a successful read() to check how many bytes it actually read, which you
TAG : cpp
Date : December 02 2020, 10:46 PM , By : user3045378
Qt Connections: Using Lambda Expression Resets Passed int Variable (Weird)
Qt Connections: Using Lambda Expression Resets Passed int Variable (Weird)
like below fixes the issue counter in the [] means you are capturing counter by-reference in the lambda.If the variable int counter has gone out of scope (as local variables are wont to do), then this means you have a dangling reference; using it is
TAG : cpp
Date : December 01 2020, 04:52 PM , By : doehr
Is it possible to return a reference via an argument passed by reference?
Is it possible to return a reference via an argument passed by reference?
this one helps. No, you can't do that.Other than in its initialiser, a reference behaves like the thing it refers to. By passing it as a function argument, you "hide" the initialiser from the part that wants to do the assignment. So, the function has
TAG : cpp
Date : December 01 2020, 04:52 PM , By : user3045317
Program returns a value of -1073741571 instead of going forever
Program returns a value of -1073741571 instead of going forever
I wish this helpful for you Ok so since this is gcc on Windows 10 take a look on this goodboltWithout any optimization enabled both functions are explicitly called.
TAG : cpp
Date : December 01 2020, 04:52 PM , By : user3045245
C++ UBSAN produces false positives with derived objects
C++ UBSAN produces false positives with derived objects
I hope this helps you . Trying to answer this myself after the comments and creating another MWE.TLDR: Make sure all classes containing virtual functions are exported when compiling with -fvisibility=hidden
TAG : cpp
Date : December 01 2020, 04:52 PM , By : user3045228
Can a constexpr linked list of arbitrary types be created?
Can a constexpr linked list of arbitrary types be created?
Hope that helps Compile time metaprogramming is for the most part pure. This means each expression's result is determined by its arguments.There are exceptions that can get around it by using argument dependent lookup and friend functions and SFINAE
TAG : cpp
Date : December 01 2020, 04:52 PM , By : jorgefernandezsalas
Access violation only in release x64
Access violation only in release x64
fixed the issue. Will look into that further This is a bug with the optimizer where it applies a pattern meant for signed integers to unsigned integers.I reported the bug and David Hartglass at Microsoft responded here. The bug is currently being wor
TAG : cpp
Date : December 01 2020, 04:52 PM , By : Jappie
Please explain the following C++ syntax
Please explain the following C++ syntax
like below fixes the issue The code I'm about to present here is originally here: , With reference to your question numbers.
TAG : cpp
Date : December 01 2020, 04:50 PM , By : Renners
How does the C++ function `modf` work internally?
How does the C++ function `modf` work internally?
Any of those help Looking around, I found an implementation source,
TAG : cpp
Date : December 01 2020, 04:50 PM , By : Rizwan
Bug on both clang and gcc on unqualified call
Bug on both clang and gcc on unqualified call
fixed the issue. Will look into that further The rule that you quote is different in C++17. The change proposal: p0846r0. If you are compiling for C++20, then the example should compile, and if it doesn't, then the compiler has incomplete C++20 suppo
TAG : cpp
Date : December 01 2020, 04:50 PM , By : user3044915
Constructing an iterator_range with variadic templates and runtime indices
Constructing an iterator_range with variadic templates and runtime indices
To fix this issue I have a collection of equally-sized vectors and want to provide an interface for the user to obtain an iterator range over a subset of these vectors. , std::index_sequence helps:
TAG : cpp
Date : December 01 2020, 04:50 PM , By : user3044698
Gcc check whether the given class has operator+
Gcc check whether the given class has operator+
help you fix your problem Your original version doesn't work because std::declval returns an r-value and a regular reference can't bind to it. A fix is to bind to a forwarding reference:
TAG : cpp
Date : December 01 2020, 04:47 PM , By : cjan
What are the exact base64 url decoding rules and implementation using openssl and C++ to validate JWT
What are the exact base64 url decoding rules and implementation using openssl and C++ to validate JWT
this will help This is the base64_url_decode that I used. I didn't write it but I can't find where I got it from.With the below code, do you still have a problem?
TAG : cpp
Date : December 01 2020, 04:47 PM , By : user3044656
How zsh/sh/bash check signal SIGTTIN for command "cat &" launched from a c++ program
How zsh/sh/bash check signal SIGTTIN for command "cat &" launched from a c++ program
will help you So. After two days trying and crying now I solve this problem. If you want give your child process SIGTTIN you should call setpgid() in parent process.
TAG : cpp
Date : December 01 2020, 04:47 PM , By : user3044650
C++ will be struct as key for std::map copied to std::map?
C++ will be struct as key for std::map copied to std::map?
I hope this helps you . std::map stores a copy of the key, regardless of the type of the key. While the local variable point is destroyed at the end of addMap, maps is not destroyed, nor are its elements, which consist of the key and the value.
TAG : cpp
Date : December 01 2020, 04:47 PM , By : user3044631
Combination of 2 templated constructors for class build with variadic templates. How?
Combination of 2 templated constructors for class build with variadic templates. How?
I hope this helps . I created some small factory class. See the code below. The factory uses a simple map with a key and a class creator function. The challenge was that I wanted to use different signatures for the createInstance functions. With that
TAG : cpp
Date : December 01 2020, 04:47 PM , By : user3044629
SSE2 packed 8-bit integer signed multiply (high-half): Decomposing a m128i (16x8 bit) into two m128i (8x16 each) and rep
SSE2 packed 8-bit integer signed multiply (high-half): Decomposing a m128i (16x8 bit) into two m128i (8x16 each) and rep
around this issue As you want to do signed multiplication, you need to sign-extend each byte to 16bit words, or move them into the upper half of each 16bit word. Since you pack the results back together afterwards, you can split the input into odd an
TAG : cpp
Date : December 01 2020, 04:47 PM , By : user3044614
Yocto OpenCV w/ GStreamer installation issues
Yocto OpenCV w/ GStreamer installation issues
hop of those help? To complete the answer of @Subrata: You need to install the package corresponding to the elements requiered by gstreamer.I don't know which Yocto version you are using but you can see which gstreamer elements are installed by defau
TAG : cpp
Date : December 01 2020, 04:47 PM , By : user3044541
QFile + QTextStream read only part of the file
QFile + QTextStream read only part of the file
Hope that helps Apparently textStream.atEnd() is not always a reliable indicator that you're actually at the end of a stream. I would try textStream.ReadAll() and see if you get the entire file that way. Alternatively, you can just call textStream.re
TAG : cpp
Date : December 01 2020, 04:47 PM , By : user3044504
std::future.wait_for blocking forever
std::future.wait_for blocking forever
may help you . The problem with your code is that when the future goes out of scope, its destructor might block as reported in the documentation for std::future::~future: It says explicitly:
TAG : cpp
Date : December 01 2020, 04:47 PM , By : user3044399
'Attempt to index a string value' error while loading a c++ module in lua
'Attempt to index a string value' error while loading a c++ module in lua
hop of those help? The second argument to luaL_register is the library name. You can leave it as NULL, but if you do, luaL_register will try to insert the registered functions into the table it expects to find on the top of the stack (and in your cod
TAG : cpp
Date : December 01 2020, 04:45 PM , By : user3044302
cmake3: set path to mpi headers
cmake3: set path to mpi headers
it fixes the issue You are running into the CMP0004 policy error. In earlier versions of CMake, linked libraries automatically had any leading or trailing whitespace removed. This can lead to subtle, undesired errors in some cases, so CMake now enfor
TAG : cpp
Date : December 01 2020, 04:45 PM , By : user3044243
Using a neural network trained in R to predict new data in C++
Using a neural network trained in R to predict new data in C++
I hope this helps . I have trained a basic back-propagation neural network in R using a training data set and validated using a test set. The neural net is giving me satisfactory results. , When training an ANN:-1) Present input pattern
TAG : cpp
Date : December 01 2020, 04:45 PM , By : user3044225
Call common function in destructor before destroying derived members
Call common function in destructor before destroying derived members
should help you out Quite simply you don't. The best thing to do in this situation is to redesign how everything works to prevent this from being a problem. But lets face it, in all likelihood you don't have the time and/or resources to achieve that.
TAG : cpp
Date : December 01 2020, 04:42 PM , By : user3044030
Losing background colour when focus is lost on a QTableView
Losing background colour when focus is lost on a QTableView
To fix the issue you can do Using frozenTableWidget for testing is perhaps a bit confusing as it's a combination of 2 QTableWidgets.
TAG : cpp
Date : December 01 2020, 04:42 PM , By : Dan Sponseller
Why internal linkage error when template defined in anonymous namespace?
Why internal linkage error when template defined in anonymous namespace?
it helps some times You have two overloaded template functions f with the second one having two template parameters. f(x); will invoke void f(const T data); which is indeed not defined anywhere.I'll now sketch out a brief solution.
TAG : cpp
Date : December 01 2020, 04:42 PM , By : SwichPT
Efficient way to remove struct based on one member, but chose which one to keep by other member
Efficient way to remove struct based on one member, but chose which one to keep by other member
around this issue I have a vecor list of found WiFi networks. Problem is, it detects all transmitters, even if they have the same name (repeaters). I want to delete the duplicates, but keep the one with highest quality (RSSI). , With custom functor,
TAG : cpp
Date : December 01 2020, 04:42 PM , By : user3043907
Is it possible to call a non-specialized template function although a specialized function exists?
Is it possible to call a non-specialized template function although a specialized function exists?
fixed the issue. Will look into that further No, the specialisation is bitCount. If you have a define for your testing, you could instead overload bitCount during the tests
TAG : cpp
Date : December 01 2020, 04:42 PM , By : user3043778
Private members of class changes during instantiation of my class even though they shouldn't
Private members of class changes during instantiation of my class even though they shouldn't
may help you . My question is: Why do the my functions GetNumberOfRows() and GetNumberOfColumns() not return the values I specified in my constructor? , The problem is because of these three lines in the constructor:
TAG : cpp
Date : December 01 2020, 04:40 PM , By : user3043875
Getting multiple string input after integer?
Getting multiple string input after integer?
I wish did fix the issue. The issue here is that std::cin >> t; doesn't consume the \n that appears in the input. This is why the first call to std::getline reads everything until the next \n, which appears immediately (such that s is the empty strin
TAG : cpp
Date : December 01 2020, 04:40 PM , By : user3043632
Why my Protobuf class can parse a string serialized by an other Protobuf class
Why my Protobuf class can parse a string serialized by an other Protobuf class
To fix the issue you can do My recommended solution to the problem of multiple different payloads:
TAG : cpp
Date : December 01 2020, 04:40 PM , By : user3043574
Upsampling: insert extra values between each consecutive elements of a vector
Upsampling: insert extra values between each consecutive elements of a vector
To fix the issue you can do So I did some math myself, because I was curious how to get the weight ratios (as if upsampling linearly up to common multiple and then extracting only target values from large array - but without creating the large array,
TAG : cpp
Date : December 01 2020, 04:40 PM , By : shadow000fire
gMock for Dummies - How to Getting Started? (Visual-Studio-2019)
gMock for Dummies - How to Getting Started? (Visual-Studio-2019)
I wish this help you I was able to compile my solution now: I created a new blank project in VS Studio 2019 I cloned the google repo googletest
TAG : cpp
Date : December 01 2020, 04:40 PM , By : user3043510
Pointer to deallocated variable changes address
Pointer to deallocated variable changes address
it should still fix some issue Accessing the return value of fun has implementation-defined behavior, as it returns an invalid pointer value (see the quote below, why). In particular platforms, it may even generate a runtime fault. So, p's value is i
TAG : cpp
Date : December 01 2020, 04:40 PM , By : subhadeep
In the C++, does template instantiated when I specialized it?
In the C++, does template instantiated when I specialized it?
it should still fix some issue You can check such questions with https://godbolt.org/:
TAG : cpp
Date : December 01 2020, 04:40 PM , By : user3043421
C++ variadic function syntax
C++ variadic function syntax
it helps some times for my understanding, it just mean that when you use ,... with a correct syntax, then it can be replaced by ... for instance :
TAG : cpp
Date : December 01 2020, 04:36 PM , By : user3043314
C++ "undefine" module keyword in include
C++ "undefine" module keyword in include
wish of those help module isn't a keyword (you can find the list of keywords in [lex.key] and verify that it isn't there).Instead, it's an "identifier with special meaning" ([lex.name]/2), more commonly referred to as a context-sensitive keyword.
TAG : cpp
Date : December 01 2020, 04:36 PM , By : user3043301
shellcode calls different syscall while runing alone as individiual code and while running with C++ code
shellcode calls different syscall while runing alone as individiual code and while running with C++ code
around this issue In your C++ shellcode caller, strace shows your execve system call was
TAG : cpp
Date : December 01 2020, 04:36 PM , By : user3043171
How to get datas send by Protobuf with a QTcpSocket
How to get datas send by Protobuf with a QTcpSocket
wish helps you out
TAG : cpp
Date : December 01 2020, 04:36 PM , By : user3043164
How to update vertex buffer data frequently in DirectX 11?
How to update vertex buffer data frequently in DirectX 11?
wish helps you As this has been already answered the key issue that you are using Discard (which means you won't be able to retrieve the contents from the GPU), I thought I would add a little in terms of options.The question I have is whether you req
TAG : cpp
Date : December 01 2020, 04:36 PM , By : Lunalila
Dynamic allocation not working for global integer pointer
Dynamic allocation not working for global integer pointer
I hope this helps you . Because p is a pointer sizeof(p) will return 8 (or 4 on 32 bit systems). Because that is the size used by p. The memory size used by the structure p points to is another story
TAG : cpp
Date : December 01 2020, 04:36 PM , By : user3043057
Why does the vc++ 2019 not accept the code?
Why does the vc++ 2019 not accept the code?
this will help template parameter object is a normative term, that refers only to template parameters that have a class type.
TAG : cpp
Date : December 01 2020, 04:36 PM , By : user3043052
stacking vectors into a Eigen Matrix
stacking vectors into a Eigen Matrix
will help you I tried to make a Eigen matrix by stacking two vectors. To do that i created size 8 two vectors. Also i created a matrix. which is size of (2, 8). In order to do it i used following code. No compilation errors but also no output as well
TAG : cpp
Date : November 29 2020, 12:01 PM , By : cafo80
Why is a variable not an lvalue in C++?
Why is a variable not an lvalue in C++?
this one helps. decltype has special rules for id-expressions, deducing their type without regard to value category. If you want it to deduce a type based on the value category an id-expression normally has, you can surround the id-expression in pare
TAG : cpp
Date : November 29 2020, 12:01 PM , By : user3042996
How to interpret the report of perf
How to interpret the report of perf
should help you out With the help of @Peter Cordes, I pose this answer. If you have something more useful, please feel free to pose your answers.
TAG : cpp
Date : November 29 2020, 12:01 PM , By : user3042898
GMock macros not recognized? YCM gives me error, but Bazel builds fine
GMock macros not recognized? YCM gives me error, but Bazel builds fine
this one helps. My problem was that in the /usr/include there was a gmock and a gtest folder that was an old version that did not have MOCK_METHOD but MOCK_METHOD0, ... 1, etc. That was the version Clang would give errors against, but my Bazel WORKSP
TAG : cpp
Date : November 29 2020, 12:01 PM , By : user3042810
Why can't allocate stack memory dynamically in visual c++? but gcc can do it
Why can't allocate stack memory dynamically in visual c++? but gcc can do it
Any of those help GCC does not compile Standard C++ by default (for some crazy reason). It allows various non-standard extensions (like your variable length array). You have to set switches for standard version and pedantic mode to enforce it:
TAG : cpp
Date : November 29 2020, 12:01 PM , By : Mortal
Can I have a local C++ compiler different from the one in linux environment?
Can I have a local C++ compiler different from the one in linux environment?
will help you Yes.This is done all the time for ARM cross-compilation for SBCs like Raspberry Pi and Android devices. A specific GCC based toolchain like Lenaro is unpacked in a different folder such as /opt to cross compile ARM software on X86 machi
TAG : cpp
Date : November 29 2020, 12:01 PM , By : user3042761
Segmentation fault while returning integer between classes
Segmentation fault while returning integer between classes
this one helps. From the code you've shown, it looks like the only thing that's happening when your code is crashing is that the destructor for cluster is running. So it's most likely either a bug in that destructor itself or some memory corruption h
TAG : cpp
Date : November 29 2020, 12:01 PM , By : user3042745
Indexing of integer array through characters of a string
Indexing of integer array through characters of a string
hope this fix your issue Let me explain this to you.But first, some recommendation. If you do write real code and not for competitive programming, please do never use
TAG : cpp
Date : November 29 2020, 12:01 PM , By : Asher
Multiplying by a decimal wont give me a decimal answer to feed back into my variable
Multiplying by a decimal wont give me a decimal answer to feed back into my variable
I hope this helps you . Your mistake is at the inner else clause.An else-clause has no condition, so the (clubCard == 'n' || clubCard == 'N'); is useless, but still correct c++. It evaluates to a bool that is then discarded. The problem is, that the
TAG : cpp
Date : November 29 2020, 12:01 PM , By : user3042720
DIfference between '{' and '(' when defining a vector<string> with integer arguments?
DIfference between '{' and '(' when defining a vector<string> with integer arguments?
hop of those help? In this case, they are the same.Using the braced initialisation syntax (vector v2{10}) will call the vector::vector(initializer_list) constructor if it is valid, but in this case it is not, since an int isn't a std::string, so it i
TAG : cpp
Date : November 29 2020, 12:01 PM , By : user3042707
C++ unordered_map operator[ ] vs unordered_map.find() performance
C++ unordered_map operator[ ] vs unordered_map.find() performance
around this issue There are two reasons why the []-operator will be slower than find: The []-operator calls a non-const function on the map properly preventing all kinds of optimizations, like loop unrolling. The more import reason: The []-operator c
TAG : cpp
Date : November 28 2020, 12:01 PM , By : user3042666
Unexpected end of regex when ascii character
Unexpected end of regex when ascii character
will be helpful for those in need \u is the beginning of the escape sequence for a Unicode code point, you need to escape it. Also, [...] is a character set match, it needs to be escaped if you want to match it literally.
TAG : cpp
Date : November 28 2020, 12:01 PM , By : Devesh Chaubey
I predict Char array type value could cast pointer type only
I predict Char array type value could cast pointer type only
will be helpful for those in need In C you could cast a char pointer to a struct.In C++ you can do it as well, but you should not do it. Although it may work. But C++ gives you no guarantee about how the data of the struct is represented internally.
TAG : cpp
Date : November 28 2020, 12:01 PM , By : Sruthy Mathew

shadow
Privacy Policy - Terms - Contact Us © festivalmusicasacra.org