Skip to main content

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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
13 views

How to include version information in a C++ project? [closed]

I wrote a C++ static library, and I want to add version information for it in a designated header. I'm working with C++14. I'm contemplating on multiple approaches: Adding it as macros: #pragma once ...
lielb's user avatar
  • 1
-1 votes
0 answers
52 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
68 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
12 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,051
0 votes
0 answers
56 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.6k
0 votes
0 answers
20 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
152 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
18 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
98 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,568
5 votes
1 answer
179 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
187 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
39 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
80 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
0 votes
2 answers
68 views

Seamlessly using maps with different comparators

I was using an alias to refer to one of two maps: map<int, int> & map_alias = use_map_a ? map_a : map_b; but then changed map_b to use std::greater as its comparator (instead of the default ...
Gymkata's user avatar
0 votes
2 answers
109 views

Code won't continue if i use 2 as the input

If i input number 2 for std::cin >> menu;, the code after std::cin >> menu; won't execute. At first, i think the problem is in the function, but the code haven't even go to the switch (i ...
Ayodya Enhanayoan's user avatar
-1 votes
2 answers
63 views

Polymorphic behavior of derived class objects in C++ STL list [duplicate]

I am storing objects of base and derives classes (Account, StudentAccount, EmployeeAccount) in an STL list and process them with STL Iterator. The dynamic polymorphic behavior of objects is not ...
Syed Irfan Ahmad's user avatar
0 votes
1 answer
56 views

adding pointers to keys in map in map

struct ndptr_t { const pnode *ptr; ndptr_t(const pnode* _p = nullptr) : ptr(_p) {} ~ndptr_t() { // if no ndptr_t used outside map nid, clear nid } }; static std::map<...
U J's user avatar
  • 63
0 votes
1 answer
35 views

initialization of boost::flyweights::intermodule_holder fails with interprocess_exception and permission denied

I've no clue why this would fail. The shared_memory_object should be unique as it is only accessed from within the same process. The current directory is writable and so is $TMPDIR and so is /tmp/ ...
Frank Puck's user avatar
0 votes
1 answer
68 views

Reusable ::testing::Values generator in gtest

I have a piece of software (c++) thats tested excessively with googletest. There are a lot of INSTANTIATE_TEST_SUITE_P calls. There is a particular value generator that I'd like to reuse, something ...
gnight's user avatar
  • 452
4 votes
1 answer
178 views

Why is this trivial code requiring exception handling

We are currently working on an embedded system where C++ exceptions cannot be used and thus their support is deactivated in the compiler/linker settings. In this project, we get a IAR-linker error for ...
Paul R.'s user avatar
  • 728
0 votes
1 answer
101 views

Tree with std::unique_ptr. Reference cannot be bound to dereferenced null pointer in well-defined C++ code

I am trying to write a tree data structure with unique_ptr but I ma getting following warning while printing the Tree: struct Node { int data_{0}; std::unique_ptr<Node> left_{nullptr}; ...
Vigyan's user avatar
  • 11
0 votes
0 answers
52 views

CURL do not free memory inside a thread without a active host

I need to call several POST requests every second with an image and I can't wait for any response When my host is active everything works good. But when the host is offline, the memory increase fast ...
Everton Soares's user avatar
0 votes
0 answers
28 views

error: ‘CV_WRAP_FILE_PATH’ has not been declared

when I add #include “opencv2/objdetect.hpp” , there is a wrong “/usr/include/opencv2/objdetect/face.hpp:85:47: error: ‘CV_WRAP_FILE_PATH’ has not been declared 85 | CV_WRAP static Ptr create(...
MingZi Jia's user avatar
-6 votes
3 answers
158 views

Is writing else statement at the last mandatory in if-else ladder in C++?

I have always seen that at the end of an if-else ladder in C++, the bottom else statement is always present. if (condition1) { doA(); } else if (condition2) { doB(); } else if (condition3) { doC(...
Divyanshu Dwivedi's user avatar
1 vote
1 answer
36 views

Finding a sequence in a row of matrix using lower_bound

I needed to write a function which will sort the rows of a matrix (vector<vector<int>>) by a specified criterion. The criterion is that a row is said to come first if its biggest element ...
THE_CRANIUM's user avatar
-2 votes
1 answer
216 views

Can I use MISRA-2023 with C++14?

I would like to follow the MISRA C++:2023 coding guideline. But it targets C++17, while the code and compiler follow C++14. The document reads: The guidelines within this document target C++17, and ...
Borph's user avatar
  • 926
0 votes
1 answer
111 views

Save compressed DICOM image without having to temporally save uncompressed DICOM

I have a DicomInterface class that inherits from DcmDataset class. After setting the DICOM tags, I want to save the DICOM image with JPEG Process 14 transfer syntax. If I first save the DICOM file ...
Phạm Hồng Nhung's user avatar
0 votes
1 answer
97 views

Explanation for extra move constructor call

I will straightaway head to the code and explain what I'm trying to understand here. class MyInt { unique_ptr<int> ptr; public: MyInt(int val) { cout <&...
Onkar N Mahajan's user avatar
3 votes
1 answer
90 views

Can I use std::align to verify the alignment of a given pointer?

The following function template tries to locate an object in an array of bytes. We may assume that the argument buffer "usually" holds an object of the given type, but I need a diagnostic (...
HelpingHand's user avatar
  • 1,429
0 votes
0 answers
51 views

The implementation of tbb::parallel_for gives a sigsev segmentation error

I was compiling a program named autoremesher on Ubuntu 22.04. It's an open source project, and I was requested to remove it's GUI. That I did and removed it's dependency from QT framework, except for ...
Burhanuddin Ali Asghar's user avatar
1 vote
2 answers
108 views

Why can't I use templates members in its specialization?

Here's my code: #include <iostream> template <typename T> struct Foo { public: T DataMember; }; template<> struct Foo<int> { public: void bar() { std::...
Сергій Горбаньов's user avatar
0 votes
1 answer
50 views

Is there a way to implement std::regular_invocable as a type_trait style function in c++11/c++14?

I'm currently working on an Arduino "gameboy" style project where I'm trying to make a library that will work like a game engine. In the Arduino IDE there is no c++ STL when using an AVR ...
Andrey Stroitelev's user avatar
0 votes
0 answers
54 views

The instruction at 0x00007FF697F8AE43 referenced memory at OxFFFFFFFFFFFFFFFF. The memory could not be read

I'm writing a programming lab and I have this error, I don't know how to solve this, please help bug the program crashes when I select item 10 and information from the file is not deleted afterward ...
Олеся Зубрицька's user avatar
2 votes
1 answer
106 views

operator delete after both operator new and placement new?

Suppose I want to put an object on the "heap", but I need to have some additional memory allocated after it. My understanding is that the following would be a standard-compliant way of doing ...
Noam Elul's user avatar
  • 349
0 votes
1 answer
107 views

module "QtNetwork" is not installed

Here is the complete content of my .pro file (I have specified to add the network module): QT += quick virtualkeyboard network # You can make your code fail to compile if it uses deprecated APIs. # ...
SeaYJ's user avatar
  • 1
0 votes
1 answer
68 views

How can std::unique_ptr apply EBO on closure?

#include <memory> #include <cstdio> int main(){ auto x1 = [](int *p){ delete(p); }; auto ptr = std::unique_ptr<int, decltype(x1)>(new int{1},x1); printf("%zu\n&...
Paoer111's user avatar
0 votes
2 answers
77 views

auto in if clause - the way to define parameters inside if [duplicate]

I want to define a parameter inside if . for example if(MyDataPtr && auto* InfoPtr = MyDataPtr ->extractInfo()) And gen compilation error Expected ')' Is it impossible? or what ca be done? ...
YAKOVM's user avatar
  • 10.1k
1 vote
0 answers
122 views

How to undefine and redefine a macro in C++?

I have a macro in the existing part of project that I want to suppress for my includes. The existing macro is defined like this: #define NAME _T(MYCONST("Name")) However In ...
Ace's user avatar
  • 440
0 votes
1 answer
69 views

how to overload unique_ptr in a class . i am getting compilation error [duplicate]

std::unique_ptr<Manager>& checkManager(std::unique_ptr<Manager> &p1) { if(p1 && p1->getName().find("Manager") != std::string::npos ){ std::cout<&...
user265906's user avatar
5 votes
3 answers
129 views

C++ Fundamentals: Template operator- overloading Failed - "template argument deduction/substitution failed"

I have been trying to write my own vector class to better understand C++ templates and iterators, but have been stuck with this error for a while and would really appreciate the help. The code fails ...
Hersh Joshi's user avatar
-2 votes
1 answer
157 views

How to write a google mock matcher to match a void pointer argument?

I have a function that takes a const void* that I'm mocking. I want to have matchers based on the value of pointee that's being passed into the function. For example: #include <vector> #include &...
ventsyv's user avatar
  • 3,447
1 vote
1 answer
105 views

Pre-C++17 replacement for CTAD?

(Or: "How to store the return value of a template-argument-deduced function where auto is not allowed") I'm working on a generic C++ framework made up of several class templates that allow ...
HelpingHand's user avatar
  • 1,429
2 votes
0 answers
64 views

C++ constexpr compiles too fast [duplicate]

When I compile a program including: #include <iostream> using namespace std; constexpr int fib_c(int n) { if (n<=1) return n; return fib_c(n-1)+fib_c(n-2); } int main() { ...
user23499217's user avatar
0 votes
1 answer
132 views

error: implicit instantiation of undefined template 'std::tuple_element<0, std::tuple<std::string, int> &>' [duplicate]

I have checked out the related posts to this error and wasn't able to use those solutions to solve my problem. So i have this code that attempts to dynamically create a tuple by converting stringified ...
rehan's user avatar
  • 41
0 votes
0 answers
56 views

error: no matching function for call to 'get<i>(std::tuple<int, int>&)' [duplicate]

I'm quiet new to C++, so I can't really figure out the issue. I really hope someone can help me. Whenever I run a loop and try to set a tuple's value inside of that loop, I get an error saying: error:...
rehan's user avatar
  • 41
1 vote
1 answer
278 views

error: no matching function for call to 'std::tuple<std::vector<int, std::allocator<int> >&, int>::tuple()'

Hey I normally work with Javascript and dart but I've been required to write some code in C++ for some project so I've been facing a lot of issues while writing it. I have this error that I've been ...
rehan's user avatar
  • 41
0 votes
2 answers
115 views

How to lazily instantiate a functor argument passed in a function when calling it under some condition in C++14?

Assume that I have a function that abstracts some error-handling logic, it has argument which is a functor. Inside it, it calls this functor conditionally. The function looks like this: void ...
Christophe's user avatar
5 votes
2 answers
233 views

Implement Non Copyable Non Moveable wrapper for map/vector etc

I want to write a wrapper over the STL containers like map, vector, unordered map etc. that do not have copy or move constructors. There are a few approaches that I can think of, but none are nice: ...
Aman Deep Gautam's user avatar
0 votes
0 answers
47 views

Implementation propagation_const in prio C++17 version

It is the following example #include <iostream> #include <memory> class B{ public: void foo() const{ std::cout << "foo const" << std::endl; } ...
getsoubl's user avatar
  • 855
0 votes
0 answers
87 views

C++ library added but still unresolved external symbol error

Inside my c++ project I have a folder: "include" with 3 files: Framework.h , FrameworkRelease_x86.dll ,FrameworkRelease_x86.lib . I included them as it was stated in microsoft documentation: ...
Антон Олег's user avatar

1
2 3 4 5
172