Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [c++14]

C++14 is the version of C++ after C++11. This tag should be used (along with the [C++] tag) for questions about C++ features specific to C++14.

-2 votes
0 answers
49 views

free char array after assigning to string [duplicate]

I have a char array that I create dynamically using new. Then I assign it to a string. now should I free the char array? char * p = new char[19]; memcpy(p, "helloworld",10); std::...
RituV's user avatar
  • 67
-3 votes
0 answers
55 views

Program ends abruptly iterating a 2-D vector using an iterator [closed]

I am updating a distance matrix which computes the distance between two nodes in an unweighted graph if the edge is present in the edges vector. Edges is a 2-D vector with each element of size 2 where ...
Bharath Devaraju's user avatar
0 votes
2 answers
90 views

How to binary search a std::vector BUT that return a RandomAccessIterator?

I'm looking for a log2(N) way of searching a std::vector and receive a RandomAccessIterator. I want it to work exactly as std::lower_bound() but return a RandomAccessIterator instead of a ...
user1804394's user avatar
-1 votes
0 answers
55 views

Error C2059 syntax error: '__declspec(dllexport)' only when return type is a pointer [duplicate]

I need to create a DLL wrapper around a function that returns unsigned char*. For that I declare the wrapping function in wrapper.h as: extern "C" unsigned char* __declspec(dllexport) fn(); ...
Dinky Dice's user avatar
0 votes
1 answer
72 views

Fixing boost::optional undefined type error

I was trying to create a bidirectional tree-like structure, so Ive ended up with the following struct`s: template<typename T> struct Node { T value; std::vector<...
Anton Grant's user avatar
13 votes
3 answers
1k views

Is it legal to initialize an array via a functor which takes the array itself as a parameter by reference?

In the question Idiom for initializing an std::array using a generator function taking the index?,which basically asks how one can initialize an array of an arbitrary type which is not necessarily ...
Weijun Zhou's user avatar
  • 4,071
0 votes
0 answers
57 views

Why doesn't std::array<T,N>::operator[] return an rvalue reference for rvalue object? [duplicate]

std::array<T,N>::operator[] always returns an lvalue reference (const if needed), but what can possibly be the use of a line of code like this, which is valid C++? std::array<int,1>{1}[0] =...
Enlico's user avatar
  • 26.7k
0 votes
0 answers
25 views

gRPC 1.47.4 vs2017 compilation errors

In my company we try to create packages of gRPC and all dependencies in our private conan repository. Currently we stuck with gcc6.4.0 and VS2017. I had currently created packages for these ...
nablit's user avatar
  • 1
2 votes
3 answers
157 views

In C++, compared to final or not virtual function, what is the advantage of CRTP?

I'm new to learning modern C++ programming. I have read many blogs and questions but haven't found the answer of this question. In C++, compared to final or not virtual function, what is the advantage ...
CatFood's user avatar
  • 33
0 votes
0 answers
19 views

Confused about AUTOSAR AP accessing to method result

AUTOSAR AP defines Request&Response approachs for users, its format just like this ara::core::Future<Output> user_defined_method(Input in) As you see, AUTOSAR AP uses Future to wrap output ...
mac.ma's user avatar
  • 703
1 vote
2 answers
102 views

Specialize a method template with type parameter with a non-type one

I'm trying to implement a class template with static member functions that can handle different types. My code looks like this (very simplified example): #include <array> struct Foo { ...
user3612643's user avatar
  • 5,578
5 votes
1 answer
187 views

Compile result different in GCC 13.1 and GCC 13.2 constructing a string

I have the following code that compiles fine on GCC 13.2. Colleagues can't compile it on GCC 13.1. The new version compiles fine even with -Wall -Wextra. I assume that GCC 13.2 is better and more ...
Thomas Weller's user avatar
4 votes
3 answers
190 views

free() on result of placement new?

I'm trying to understand whether it's valid to call free() on the result of placement new in a buffer allocated by malloc(). Consider the following. Does this code exhibit any undefined behavior? (...
Noam Elul's user avatar
  • 349
0 votes
0 answers
42 views

How to use boost log in visual studio 2015 and build platform is v140

I have added all the dependencies but after adding it i am getting some linking error. I am using visual studio 2015 buildtool v140 , platform v8.1 and platform win32. I have added the necessary ...
Lalit Sharma's user avatar
1 vote
1 answer
81 views

How to print the line number of the caller function from a template function?

I am implementing a log function which logs along with line number of the code. The snippet of the code as follows: #include <iostream> using namespace std; char m_buffer[500]; template<...
GShaik's user avatar
  • 311

15 30 50 per page
1
2 3 4 5
572