Questions tagged [c++14]

2 votes
2 replies
Find the unique elements of a vector C++
Is there a fast way to find all the single elements (only appeared once) in a vector of elements? All the elements in the vector is either single...
asked 4 months ago
2 votes
2 replies
Call std::function with list of variant types
I am working with a third party library that passes values using a custom vector and variant types. These vectors however map 1:1 to my functions...
asked 4 months ago
1 votes
1 replies
Is it possible to avoid errors in parts of a c++ template function that are not going to run in the end?
I have a template with two integers as input. One may have a larger type than the other. My code does a shift accordingly so the results fits the...
-6 votes
1 replies
How to fix “teminated due to timeout” error in the problem Array Manipulation | Hackerrank?
I'm trying to solve the array manipulation problem on hackerrank, but it shows "terminated due to timeout" in some of the test cases. How can it...
asked 4 months ago
-3 votes
0 replies
Find, whether given gift count array is valid or not. If it is valid print any of possible way of gifting that lead given array
Its farewell day, there are total N students, every student has bought a gift to give. He/She will give this gift to some other student. After gi...
asked 4 months ago
0 votes
0 replies
Template Argument Deduction which function which is no where used/declared/defined [duplicate]
At http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx, the VC++ team officially declare that they have not yet implemented the C++11...
asked 4 months ago
3 votes
2 replies
Sequencing between the destruction of local automatic function variables vs the construction of the return value
There exists code that relies on the fact that local automatic function variables are destroyed after the return value has been created, for exam...
asked 4 months ago
1 votes
1 replies
Idiomatic way of choosing between types based on a compile-time condition
Given an unknown type T, I need something which picks another type R based on the size of T. If T is 8 bytes the type should be pcg64 and if T is...
asked 4 months ago
1 votes
1 replies
C++ - inherit from base class with member function as template argument
I have this very simple class using CRTP: template <typename DerivedType, void (DerivedType::*updateMethod)() = &DerivedType::update>...
asked 4 months ago
0 votes
1 replies
Does NDK support C++14?
Currently working on something where I need to develop some feature using C++14, but still wondering on whether it can be supported by Bionic &am...
asked 4 months ago
0 votes
0 replies
How to include my class function into my main using the command line arguments?
So I trying to create a board for my ConnectN Game but I am not sure how I would call it in my main function using command line arguments. In my...
asked 4 months ago
0 votes
0 replies
std::experimental::optional with ndk/clang
I am trying to build my project which uses std::experimental::optional. For Linux it compiled just fine, but for android/ndk the compiler throws:...
0 votes
2 replies
How can I make this simple program return without closing?
I started trying to learn C++ tonight and I'm just messing around in an IDE right now. How can I make this simple program not close the program u...
asked 4 months ago
3 votes
1 replies
The sized operator delete[] is never called
I am trying to keep track of how much memory has been allocated in my developments. It is easy to keep track of allocation because the overload o...
asked 4 months ago
3 votes
1 replies
std::promise set_exception twice cause Segmentation fault
Let's say I have a method that calls an unstable third-party service, so I add a timeout for this call say 10 seconds. Here is what I tried: int...
asked 4 months ago
-2 votes
0 replies
Write a Program to PASS and RETURN Object from FRIEND Function [closed]
I don't know If the approach to solving this question is right or not but .. the main objective of the question is that the friend function shoul...
asked 4 months ago
0 votes
0 replies
Issue with X3 and MS VS2017
I am having a weird problem with boost spirit X3 (v1.69) in combination with MS VS2017. I am getting compiling errors in well formed structures....
asked 4 months ago
0 votes
2 replies
Why non deductible template parameters is problematic?
Trying to compile this piece of code results in an error. template <typename T> struct MyClass; template <typename T, std::size_t sz&g...
asked 4 months ago
-1 votes
0 replies
How to convert 32bit integer co SDL_Colour
I want to convert uint32_t to SDL_Color, so I can write simple hexadecimal number as color (kind of like in css), or send just single integer thr...
asked 4 months ago
6 votes
2 replies
c++: constexpr function doesn't evaluate at compile time when using with std::cout [duplicate]
This question already has an answer here: Why GCC does not evaluate constexpr at compile time?...
asked 4 months ago
2 votes
3 replies
What is the difference between the 2 versions of std::enable_if
I don't understand why the first (good) version of the code compiles, but the second doesn't I have read this, this , this, and of course this b...
asked 4 months ago
-2 votes
0 replies
std::vector push_back unique_ptr vs shared_ptr performance
Shouldn't push_back be faster on a simple std::vector < unique_ptr > vs std::vector< shared_ptr > ? class B { public: B(int i):...
asked 4 months ago
34 votes
2 replies
std::unique_ptr of base class holding reference of derived class does not show warning in gcc compiler while naked pointer shows it. Why?
I have a hierarchy of base class and derived class. Base class has one virtual function which is overridden by derived class. class Base {...
asked 4 months ago
0 votes
2 replies
How can I shuffle a std::stack in C++?
I have an STL stack that contains pointers to objects. How can I shuffle the order of the items inside the stack? Can I use the algorithm library...
asked 4 months ago
0 votes
1 replies
How to define some function which can be accessed from within the scope of operator overloading for (+) operator?
I created a code by using operator overloading concept in c++ for addition of two rational numbers by overloading the +(plus) and the <<(In...