logo
down
shadow

CPP QUESTIONS

C++ passing a nested unordered_map by reference and manipulating it
C++ passing a nested unordered_map by reference and manipulating it
around this issue You are not passing by reference, you're passing a pointer. This is a version using reference:
TAG : cpp
Date : November 22 2020, 02:42 PM , By : Avraz Shawkat
Prefer unordered_set over vector
Prefer unordered_set over vector
hope this fix your issue Is it safe to say that if I don't want duplicates in my container, and I don't care about element position as I only want to iterate through the container, then I should use an unordered_set instead of vector?
TAG : cpp
Date : November 22 2020, 09:00 AM , By : BMG Vlogs
CUDA, Qt creator and Mac
CUDA, Qt creator and Mac
Any of those help I managed to get your example running with a few minor corrections to your .pro file. If you or anyone else is still interested in a larger C++/CUDA/Qt example for Mac and Linux check this answer from a few months ago. Your particul
TAG : cpp
Date : November 22 2020, 09:00 AM , By : Jose Betanzos
Heroku / Rails: can't set path to vendorized dependencies
Heroku / Rails: can't set path to vendorized dependencies
With these it helps I've got a set of libs/headers/binaries that are used to build some gems in my app (specifically Boost and SWIG). I've pre-built everything on a cedar-14 docker image and put it all in my vendor directory, so I have "vendor/swig"
TAG : cpp
Date : November 22 2020, 09:00 AM , By : Zippy
Using self made libraries in Visual Studio
Using self made libraries in Visual Studio
it should still fix some issue On a C++ Win32 Console App project there is an option on the new project wizard to create a library.Create your libraries in a single solution and add a post build step to copy them to a "central folder". In you code th
TAG : cpp
Date : November 22 2020, 09:00 AM , By : annika
Bypass trigger of OnFocus/GetFocus event if the application window loses activation c++
Bypass trigger of OnFocus/GetFocus event if the application window loses activation c++
will be helpful for those in need I have a text box which take string value. On Focus lost it does a specific function (say function 1). But even if I lost focus on the window, this OnFocus event is getting triggered. , I tried checking if the On foc
TAG : cpp
Date : November 22 2020, 09:00 AM , By : Payal
CURLpp, segmentation fault
CURLpp, segmentation fault
Does that help There was extra library curl-7.45, which i had to delete and update other libraries.Commands:
TAG : cpp
Date : November 22 2020, 09:00 AM , By : Raul Meira
Exclusive checkbox in QListView
Exclusive checkbox in QListView
I hope this helps . You can always make it in the way described below. Firstly connect the clicked signal of ListView to the slot which will handle your items click. Secondly inside of the slot you can get the item from QModelIndex and check the stat
TAG : cpp
Date : November 22 2020, 09:00 AM , By : Michael Hansen
Firemonkey: TLabel text truncated despite autosize property true
Firemonkey: TLabel text truncated despite autosize property true
may help you . After tinkering around with a bunch of settings both in XE8 and on Windows I finally found the solution. The machine running Windows Server 2008 R2 had all of its visual enhancement settings turned off which caused the application to r
TAG : cpp
Date : November 22 2020, 09:00 AM , By : Bas Ariaansz
How to prevent constructor from casting argument types in c++?
How to prevent constructor from casting argument types in c++?
like below fixes the issue I have a class to store big unsigned numbers and I'd like to allow user to create object using types such as long long, int, unsigned int and so on and also from string . I created a constructor BigNumber(const unsigned lon
TAG : cpp
Date : November 22 2020, 09:00 AM , By : analogchops
Why can't I construct a gsl::span with a brace-enclosed initializer list
Why can't I construct a gsl::span with a brace-enclosed initializer list
This might help you When you call the vector version, the initializer list is used to create a temporary std::vector, which is then passed to the function by const reference. This is possible, because std::vector has a constructor, that takes an std:
TAG : cpp
Date : November 22 2020, 09:00 AM , By : Brian Locke
unexpected tokens following preprocessor directive - expected a newline
unexpected tokens following preprocessor directive - expected a newline
may help you . Remove all non-ASCII characters from your files or set your editor and compiler to accept UTF-8.
TAG : cpp
Date : November 22 2020, 09:00 AM , By : providedbike
C++-What is the need of both buffer and stream?
C++-What is the need of both buffer and stream?
With these it helps Ok lets lets start from the scratch suppose you want to work with files. For this purpose you would have to manage how the data is entered into your file and if the sending of data into the file was successful or not, and all othe
TAG : cpp
Date : November 22 2020, 09:00 AM , By : Valentina Quiroga Fo
get the rank of an element of a boost::multi_index container
get the rank of an element of a boost::multi_index container
will be helpful for those in need @sehe's answer is perfectly valid but runs in linear time. If you want better performance, consider defining your index 0 as random_access and 1 as ranked_non_unique (index 2 is redundant):
TAG : cpp
Date : November 22 2020, 09:00 AM , By : Xiao.Zhou
How Can I Find the MIN, MAX, SUM and AVG of A Sorted List
How Can I Find the MIN, MAX, SUM and AVG of A Sorted List
around this issue The program is intended to read elements from a file then sort those elements using shell sort, save the sorted elements into an array and then find the minimum, maximum, sum and average. , Well if the list is sorted then:min is fir
TAG : cpp
Date : November 22 2020, 09:00 AM , By : balgood
Critical error -> c0000374
Critical error -> c0000374
fixed the issue. Will look into that further In your mallocs you're using sizeof(int) instead of sizeof(double).Also your destructor only deletes the first row of globalMatrixH. It should be a loop going through every index, just as in the constructi
TAG : cpp
Date : November 22 2020, 09:00 AM , By : Dominique Hernandez
Constrained delaunay triangulation with Projection_traits_xy_3
Constrained delaunay triangulation with Projection_traits_xy_3
should help you out The traits class parameters of all triangulation classes must be Gt. The insert-by-range constructor of the Constrained triangulation expects a range of constraints. You can use the insert function instead.
TAG : cpp
Date : November 22 2020, 09:00 AM , By : Mgiu5
Concurency : sharing same memory space
Concurency : sharing same memory space
Hope that helps Problem solved : some of my buffers didn't even get the chance to get created because I was aborting the prepareForRendering function in some cases before the buffer creation part. Cases being : attempting to create texture ressources
TAG : cpp
Date : November 21 2020, 09:01 AM , By : Roxanne
QProcess::startDetached() but hide console window
QProcess::startDetached() but hide console window
I wish did fix the issue. I had exactly the same problem, and could not solve it in a clean way. I have found 2 options: Hacky way: Subclass QProcess and call setProcessState(QProcess::NotRunning); after starting the process. This will prevent the de
TAG : cpp
Date : November 21 2020, 09:01 AM , By : Jessica Williams
iOS static library build with Scons linker search on wrong paltform
iOS static library build with Scons linker search on wrong paltform
like below fixes the issue The problem was Xcode command line tolls that I had to update manually. The reason for the update is the new Xcode (7) update that I made. After the update compilation worked perfectly.
TAG : cpp
Date : November 21 2020, 09:01 AM , By : jacob saltzman
C++ Pointer Lists and passage by reference
C++ Pointer Lists and passage by reference
fixed the issue. Will look into that further On the code below, do I need to create an instance of my list when I use the constructor in ClassWithList? , You have to do some simple corrections (explanations in comments):
TAG : cpp
Date : November 21 2020, 09:01 AM , By : Rob S
C++ container to store(insert/get/remove) structure with multi key of integer value is pointer
C++ container to store(insert/get/remove) structure with multi key of integer value is pointer
I wish did fix the issue. How to store following structure Key=[k1,k2,...,kn]; Value=void* n is unknown at compile time. It's constant for object but varies for class. It must be like tree but C++ STL. It must be as fast as it can be for inserting, r
TAG : cpp
Date : November 21 2020, 09:01 AM , By : Akshaya Nayak
How can I use a constexpr value in a lambda?
How can I use a constexpr value in a lambda?
help you fix your problem I would want to use a constexpr value in a lambda. Reading the answer to Using lambda captured constexpr value as an array dimension, I assumed the following should work: , Should this be considered a bug in clang 3.8?
TAG : cpp
Date : November 21 2020, 09:01 AM , By : Don Klayman
IO from a mapped file vs IO using filestreams
IO from a mapped file vs IO using filestreams
this one helps. (Disclaimer: I am the author of proposed Boost.AFIO)
TAG : cpp
Date : November 21 2020, 09:01 AM , By : Renée Fortier
Valgrind: "invalid read size 1" when throwing custom exception
Valgrind: "invalid read size 1" when throwing custom exception
Hope that helps From what I understand, it returns an invalid pointer. But it compiles fine outside of valgrind and prints the right message.
TAG : cpp
Date : November 21 2020, 09:01 AM , By : Dustin Greiner
Iterator end check fails after incrementing inside a `for` loop
Iterator end check fails after incrementing inside a `for` loop
wish of those help You are checking for it != vec.end() but with it++ happening twice you are skipping twice on each check. In other words you are running past the end of the vector without spotting it.If you add one more element to your vector then
TAG : cpp
Date : November 21 2020, 09:01 AM , By : Klaus
Is it possible to switch between BLAS libraries without recompiling program?
Is it possible to switch between BLAS libraries without recompiling program?
Hope that helps Sure, you have to have them installed, and on Ubuntu/Debian issue command
TAG : cpp
Date : November 21 2020, 09:01 AM , By : Harun Bulut
Will any compiler actually ever elide these copies?
Will any compiler actually ever elide these copies?
This might help you The compiler can - and normally does - elide the copies from the temporary to the argument. The compiler cannot elide the copy from the argument to members. While it may technically possible to elide these copies in some cases, th
TAG : cpp
Date : November 21 2020, 07:38 AM , By : Jeremy Ware
DirectX DXUT alternate API
DirectX DXUT alternate API
wish help you to fix your issue For Windows Store and universal Windows apps on Windows 10, you can use XAML+DirectX interop to get right GUI on top of a Direct3D surface. See DirectX - Using XAML with DirectX and C++ in Windows Store Apps.In general
TAG : cpp
Date : November 21 2020, 07:38 AM , By : blobfish
What happen when you open/close a handle?
What happen when you open/close a handle?
hop of those help? hProcess is just a value associated a process. The handle itsself is managed and associated with the process by the Operating System.
TAG : cpp
Date : November 21 2020, 07:38 AM , By : Dominik Kamiński
Call function use pointer
Call function use pointer
fixed the issue. Will look into that further First of all: Your functions void my_int_func(int x) and void my_int_func2(int y) do not return anything (return type void). They just prompt the input parameters to stdout.What you probably want is someth
TAG : cpp
Date : November 21 2020, 07:38 AM , By : Ahmed739
New to threads : problems using std::ref() in thread parameters
New to threads : problems using std::ref() in thread parameters
This might help you I am new to C++ threads and trying make several objects packed in a std::vector call their prepareForRendering(...) method asynchronously. It seems I am using std::ref wrongly. This works : , Just pass pointer to bind:
TAG : cpp
Date : November 21 2020, 07:38 AM , By : Syd Luce
Building GMP 6.1.0 on 64 bit Windows 7 (msys2/mingw64): configure fails due to mp_limb_t is not 64 bits
Building GMP 6.1.0 on 64 bit Windows 7 (msys2/mingw64): configure fails due to mp_limb_t is not 64 bits
wish helps you This is solved by adding --host=x86_64-w64-mingw32 to the configure command. This is generally recommended to build software that uses Autotools or some form of configure script for Windows 64-bit.You can read this page on the MinGW-w6
TAG : cpp
Date : November 21 2020, 07:38 AM , By : phaser33
Invalid explicitly-specified argument in clang but successful compilation in gcc — who's wrong?
Invalid explicitly-specified argument in clang but successful compilation in gcc — who's wrong?
fixed the issue. Will look into that further As there is no answer for a week, I will post my vision. I am far from being an expert at language-laywering, actually I would consider myself a complete novice, but still. The following is based on my rea
TAG : cpp
Date : November 21 2020, 07:38 AM , By : enns
Copy elision for pass-by-value arguments
Copy elision for pass-by-value arguments
To fix the issue you can do There are actually two copies being performed on each Range object passed to the constructor. The first happens when copying the temporary Range object into the function parameter. This can be elided as per the reference g
TAG : cpp
Date : November 21 2020, 07:38 AM , By : anthonygallina1
Filter Gtest based on two filters
Filter Gtest based on two filters
To fix the issue you can do I have multiple GTests. I would like to run only some of them based on two filters. For example, I want to run all UI properties tests. Something like: --gtest_filter=Properties and --gtest_filter=UI. I would like to use b
TAG : cpp
Date : November 20 2020, 09:01 AM , By : Hugo Arturo Figueroa
CGAL's documentation for Delaunay Triangulations
CGAL's documentation for Delaunay Triangulations
This might help you From here: Locate is implemented by a line walk. The walk begins at a vertex of the face which is given as an optional argument or at an arbitrary vertex of the triangulation if no optional argument is given.This is particularly u
TAG : cpp
Date : November 20 2020, 09:01 AM , By : ark
Combination of mmap() and memalign() in Linux/GCC?
Combination of mmap() and memalign() in Linux/GCC?
this will help Just mmap a block that is (first rounded to the next power of) twice as big as what you need and then munmap what is not needed.
TAG : cpp
Date : November 20 2020, 09:01 AM , By : Petr K
Adding constraints to a CPLEX model in C++
Adding constraints to a CPLEX model in C++
To fix the issue you can do for your help, finally I could figure out what was wrong. Basically, the initialization of the variables was not correct, because I was not adding them to the model. For instance, the definition of the U variable should be
TAG : cpp
Date : November 20 2020, 09:01 AM , By : Alexis Migueres
Words overlapping in a Word Search game
Words overlapping in a Word Search game
Hope this helps Your logic to place a word should be: pick a word pick random coordinates and an orientation until the word can be placed at these coordinates and with that orientation. place the word
TAG : cpp
Date : November 20 2020, 09:01 AM , By : Abdullah Hanefi Önal
AIX CMakeTest does not add correct -lpthread
AIX CMakeTest does not add correct -lpthread
Hope this helps You have to use target_link_libraries and apply it on your executable. Simple example on a project using boost::threads :
TAG : cpp
Date : November 20 2020, 09:01 AM , By : Lukas Macko
How to play ogg Vorbis files using IGraphBuilder
How to play ogg Vorbis files using IGraphBuilder
should help you out Pay attention to HRESULT error codes; they mean something. MSDN is often helpful with function-specific error codes like the one you got. (With enough COM programming you'll be able to recognize common ones like E_INVALIDARG by si
TAG : cpp
Date : November 20 2020, 09:01 AM , By : user4576364
Compiling a Qt project with CMake using resources and ROS (catkin_make)
Compiling a Qt project with CMake using resources and ROS (catkin_make)
hop of those help? So apparently it was an issue with catking. I removed the build directory created by catkin, ran again catkin_make, and now it compiles.Note: I just did a minor editing to the cmake file. I had copied the wrong one on SO.
TAG : cpp
Date : November 20 2020, 09:01 AM , By : Hans GD
boost::interprocess::managed_shared_memory() open_only fails on XP
boost::interprocess::managed_shared_memory() open_only fails on XP
I hope this helps . BoostOpen.exe was failing within the CreateFileA api call, returning -1 as handle value.I noticed that on Windows7 the boost shared memory name was:
TAG : cpp
Date : November 19 2020, 03:54 PM , By : Avinash
writing more than one Mat variable to an XML file using filestorage in opencv
writing more than one Mat variable to an XML file using filestorage in opencv
wish helps you Problem is solved finally, In the project configuration properties> Linker > input > additional dependencies I had set opencv_world300.lib while it should have been opencv_world300d.lib. Changing that the problem is solved now
TAG : cpp
Date : November 19 2020, 03:54 PM , By : Mario Lecca
Get pointer to object from pointer to some member
Get pointer to object from pointer to some member
I hope this helps . If you are sure that the pointer is really pointing to the member b in the structure, like if someone did
TAG : cpp
Date : November 19 2020, 03:54 PM , By : Sago78
Can't figure out pointers in C++! Need info about basic strings and pointers
Can't figure out pointers in C++! Need info about basic strings and pointers
help you fix your problem I'm guessing this is the first time you've come across pointers. If you don't quite understand them, I'd highly recommend going and learning about them as they are pretty critical to C/C++ (among other languages).For the ben
TAG : cpp
Date : November 19 2020, 03:54 PM , By : Cupoto
Errors with std::enable_if<>
Errors with std::enable_if<>
To fix this issue When you use std::enable_if::type literally there is nothing to be substituted. Thus, the code is always wrong and the compilers reports the error as such. SFINAE only applies if there is "S" (substitution) which ended up to "F" (fa
TAG : cpp
Date : November 19 2020, 03:54 PM , By : Michael Wahl
How to find out if we are running in main thread?
How to find out if we are running in main thread?
will help you There is no such thing as main thread. There is a thread which was launched first, but all threads are first-class citizens. By tinkering with linker flags, I can easily create a program where the thread executing main() would not be th
TAG : cpp
Date : November 19 2020, 03:54 PM , By : Katherine
Could it be the case that sizeof(T*) != sizeof(const T*)?
Could it be the case that sizeof(T*) != sizeof(const T*)?
I hope this helps . No, they can't be different. For sufficiently different T1 and T2, sizeof(T1 *) can be different from sizeof(T2 *), but if T2 is just const T1, then:
TAG : cpp
Date : November 19 2020, 03:54 PM , By : olastor
Last word repeated in a text file C++
Last word repeated in a text file C++
Hope this helps This is my code for writing and reading a text file but the problem here is that this code generating the last word again as in it is repeating the last work of the text file which it shouldn't. Can anyone tell what mistake im making?
TAG : cpp
Date : November 19 2020, 03:54 PM , By : ahrefmef
manage enum var in c (porting code from c++)
manage enum var in c (porting code from c++)
I hope this helps you . I´m trying to make a porting of a c++ code to an msp430 c code. Since I never faced enumerated type, I´m getting few problem to undestand how to manage it. This code was written from Taylor Andrews : enum list are defined as:
TAG : cpp
Date : November 19 2020, 03:54 PM , By : Ethan Lu
Not able to create mock class/object to replace the functionality of a private member object in my class for unit testin
Not able to create mock class/object to replace the functionality of a private member object in my class for unit testin
wish helps you You can do it by creating an interface IB and making class B implement that interface. Then, in class A, use pointers to this interface. That way you can change the implementation in tests and use the mock class.One more thing. Since y
TAG : cpp
Date : November 19 2020, 03:54 PM , By : Luke
Determine DBL_MIN in a loop
Determine DBL_MIN in a loop
will help you DBL_MIN is minimum normalized positive value of double. This means that this is the minimum value that has its mantissa not less than 1.0. You can still go for smaller numbers if you choose smaller mantissa.So what you get is Denormal n
TAG : cpp
Date : November 19 2020, 03:54 PM , By : Katarzyna Kaminska
Can adding extra const qualifications break functionality (assuming compilation went fine)?
Can adding extra const qualifications break functionality (assuming compilation went fine)?
I hope this helps you . As I try to apply const-correctness for my own code, I often have to add const qualifications to function definitions in other modules (written by other programmers) in order to use those functions in my own code. (see here on
TAG : cpp
Date : November 19 2020, 09:01 AM , By : Omer Saeed
C++ template specialisation, but no match found
C++ template specialisation, but no match found
Any of those help The compiler needs to see the generic declaration before you can declare a specialization, so simply change the order of the declarations.
TAG : cpp
Date : November 19 2020, 09:01 AM , By : kkcocoqq
Visual c++ 2010 Express won't debug a new project
Visual c++ 2010 Express won't debug a new project
I hope this helps you . The user "rcgldr" gave the answer in comment, the problem comes from the Avast anti-virus software. Turning it off solves the issue.
TAG : cpp
Date : November 19 2020, 09:01 AM , By : Oliver Ebersold
Deque Iterator Error
Deque Iterator Error
I wish this helpful for you Since deque< BinNode* >::const_iterator is a dependent name, you need to explicitly identify it as a type with the typename keyword:
TAG : cpp
Date : November 19 2020, 09:01 AM , By : Leonid Poliakov
Regex to strip leading zeros
Regex to strip leading zeros
I hope this helps you . The std::regex also has a regex_replace method. It can modify strings based on a given pattern and a replacement pattern.In your case, you can use backreferences to captured substrings (those substrings matched and captured wi
TAG : cpp
Date : November 19 2020, 09:01 AM , By : Gnarl Marx
Why do I get ESC successfully only by _getch()?
Why do I get ESC successfully only by _getch()?
should help you out Because std::cin.get() reads characters from the console window, however it is not possible to actually 'write' the escape character; therefor it never catches it.from cplusplus.com
TAG : cpp
Date : November 19 2020, 09:01 AM , By : Rohan Sewaney

shadow
Privacy Policy - Terms - Contact Us © animezone.co