c++ Questions

3

Solved

In [conv.lval] p3.4, the result of lvalue-to-rvalue conversion is described as follows: Otherwise, the object indicated by the glvalue is read ([defns.access]), and the value contained in the obje...

1

Solved

Consider this code (godbolt): #include <iostream> template<typename F> void call_by_val(F funct) { std::cout << "call_by_val(): "; funct(); } template<typename ...

2

Solved

I'm trying to learn C++ ranges. As far as I can see, the simplest (and the only, short of implementing a custom range view class) way to create a range view object that generates a custom sequence ...
Angers asked 30/9 at 16:44

6

Solved

The implementation of these methods seems straightforward to me and they would make usage of std::string and std::string_view more interchangeable. After all, std::string_view has constructors whic...
Carloscarlota asked 24/1, 2019 at 11:53

1

I have a source file with a large byte array representing an image. Below an example (in reality it can be any random data): const uint8_t image_test_image[] ={ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,...
Spelt asked 26/9 at 14:55

1

Solved

Consider the toy example code below. It has a too-large-to-copy data structure MyDataStructure and a little iterator class MyDataIterator that the caller can instantiate to iterate over the data in...
Birdsong asked 30/9 at 23:48

5

I downloaded Visual Studio 2017 and pulled my solution repo. However, I'm having some issues because it appears that a lot of the files I had on my previous computer were not downloaded in the inst...
Berkow asked 14/9, 2018 at 5:2

0

I have a hierarchy of polymorphic classes. At some level in the hierarchy, I want to make the implementation of a virtual method final. Additionally, I just want to use the base class implementatio...
Buckra asked 30/9 at 8:17

2

Solved

GCC G++ 9 This code: class foo { int bar[] = {111, 123}; }; produces an error about initializer for flexible array. But this one: class foo { int bar[2] = {111, 123}; }; compiles as n...
Pedology asked 8/1, 2020 at 21:45

3

Solved

I'm new to the "hidden/dark places" of C++ and I was wondering how to load a .dll file from a different directory or a sub-directory inside the one where my current executable is running Ex: ./My...
Devland asked 2/7, 2013 at 8:3

3

Solved

It's very natural to want to compare std::array's at compile time; and its operator==() is obviously constexpr'able. Yet - it isn't marked constexpr. Is this intentional or an oversight? And - what...
Lime asked 20/8, 2017 at 14:45

4

Solved

I am working to implement a code which was written in MATLAB into C++. In MATLAB you can slice an Array with another array, like A(B), which results in a new array of the elements of A at the index...
Gessner asked 6/5, 2021 at 22:4

1

Solved

A requires-expression similarly to a function can introduce local parameters using a parameter list. And lambda expressions defined at block scope may have captures without initializers. Is it allo...
Interlace asked 25/9 at 19:40

2

I'm trying to use opencv native library in an android studio project. I get an error for undefined reference for the function knnMatch. I have added openCVLibrary to my project and had success to ...
Yann asked 19/2, 2018 at 9:21

2

Solved

GCC accepts this code, Clang and MSVC reject it due to failed static assertion in assert. What does the standard say? https://godbolt.org/z/PKMKzYGsc template<typename T> constexpr int assert...
Effectuate asked 24/9 at 2:53

2

I need to reduce the memory used by my native Windows C++ application, without compromising its performances. My main data structure is composed by several thousands of instances, dynamically allo...
Pameliapamelina asked 21/10, 2016 at 7:12

1

I have updated XCode(v. 16.0) and made sure the xcode command line tools (xcode-select version 2409) are updated. I have installed the C/C++ VS Code extension v.1.21.6 My compiler path is set to /u...
Mouser asked 18/9 at 18:23

2

Solved

I've got an algorithm I've used for years to emulate a real-time clock in a non-real-time environment. It's always worked exceptionally well until used on Ubuntu 24.04 in WSL2 in Windows 11. The lo...

1

This code compiles on gcc and msvc but not with clang from C++20 on: #include <type_traits> class IBase { protected: IBase() noexcept = default; public: virtual ~IBase() noexcept = defa...
Redfin asked 21/9 at 16:27

1

Solved

In GDB, I can do the following and get address of a string literal: (gdb) p &"aaa" $3 = (char (*)[4]) 0x614c20 As I understand, a string literal is a rvalue with no symbol to which i...
Mapping asked 23/9 at 1:26

4

I would like to convert wstring to wchar_t*. I have tried everything what i know, please help. I would like to convert wstring to wchar_t*.
Singularity asked 8/7, 2017 at 11:2

2

Solved

I would like to add some type of validation to my QInputDialog. I use the input of the dialog to create a file system path. So I would like to exclude characters such as @$#%^&*() but keep - an...
Glantz asked 8/11, 2013 at 17:56

1

Solved

This code is an attempt to reinterpret memory contents as a different type without violating strict aliasing rules. It was suggested as an answer to "Using std::memmove to work around strict a...
Discharge asked 20/9 at 13:37

4

I have a simple project where the file structure looks like this: - CMakeLists.txt - main.cpp The CMakeLists.txtlooks like this: # Project initialization cmake_minimum_required (VERSION 2.6) pr...
Nobukonoby asked 16/1, 2019 at 2:12

1

Solved

I'm reading the documentation on std::expected::operator==, and apparently it's not SFINAE-friendly. Instead of "doesn't participate in overload resolution if [types are not eq-comparable]&quo...
Eward asked 20/9 at 11:16

© 2022 - 2024 — McMap. All rights reserved.