General C++ Programming - January 2023

indirectly_readable is false for std::optional??
 
Hi, I do not understand the following: The resulting value when applying the operator* is the same reference type for const and non-const objects... and...
[1 reply] : The resulting value when applying the operator* is the same reference... (by mbozzi)
TEXT like behavior of the function?
 
I have a lengthy function that is bloated because there doesn't seem to be a way to assign generic string with string literal on same line. example: #include ...
[5 replies] Last: Awesome solution and no performance penalty, I like it! Macros again s... (by malibor)
trick with type_identity_t
 
Hi, I do not understand the following code: template<typename From, typename To> concept ConvertsWithoutNarrowing = requires (From && x) { std::type_identi...
[2 replies] Last: type_identity_t<To > is used here to satisfy an arbitrary restrictio... (by mbozzi)
std::compare_three_way not compiling
 
Hi, I have this code: template<typename T> struct Value { T val{}; auto operator<=>(const Value& rhs) const noexcept(noexcept(val<=>val)) { ...
[6 replies] Last: cppreference has excellent examples on how to use C++ stdlib functiona... (by deleted account xyzzy)
(c++ stl thread) what happen when constructing threads without join() or detach()?
 
code below: #include<iostream> #include<thread> using namespace std; int main() { thread t1( (){cout<<"t1"<<endl;}); // without calling ...
[3 replies] Last: Please do not post the same question in multiple forums. https://cplus... (by AbstractionAnon)
Conditionally use function with templates
 
Generic sample code: #include <string> #include <type_traits> #include <cuchar> template<typename StringType> requires std::is_same_v<typename StringType::...
[5 replies] Last: template < std::ranges::input_range STR > requires requires { int... (by JLBorges)
Internal compiler error MSVC
 
Creating a new thread since the previous one is solved: https://cplusplus.com/forum/general/285225/ There is a different issue right now, and I would like to a...
[3 replies] Last: It's the latest compiler version and I was compiling with std:c++20 G... (by malibor)
What is the "z" prefix in string literals?
 
Sample string: std::string str = "z\u00df\u6c34\U0001F34C"; // or u8"zß水🍌" I don't understand nor can I fin any information about the "z" prefix in th...
[3 replies] Last: lol, silly me... Now that you said that it actually makes sense. (by malibor)
Can UTF-16 file be BOM-less?
 
UTF-8 encoded file may or may not have BOM in it, does the same apply to UTF-16? Can there be UTF-16 file without BOM? I mean is it a usual scenario like wi...
[2 replies] Last: Thanks, I see, therefore it's possible for UTF-16 file be without BOM.... (by malibor)
regex_search icase
 
Sample code: #include <regex> #include <string> int main() { std::wregex regex; std::wstring line; // This compiles std::regex_search(line,...
[7 replies] Last: The expensive part of constructing a typical regex is probably the pro... (by mbozzi)
convert string to hex
 
Hello all , Please how can convert this string to hex .. string packet = "11101111000001010110000";
[11 replies] Last: thanks so much Ganado , Working good Thanks for the notes jonnin ... (by Hawlong)
Different behavior in Debugger or normal application
 
Hi, I'm trying to develop a socket application in Linux (I don't know if it's a specific socket problem, by the way) and am running into reading problems. W...
[3 replies] Last: It took 15 minutes to install valgrind and receive the following: ==1... (by Bengbers)
how can replace and add to array
 
#include <iostream> using namespace std; // function to convert decimal to binary void decToBinary(int n) { // array to store binary number int binar...
[6 replies] Last: Thanks so much seeplus , solved (by Hawlong)
by Mobo01
KMP algorithm's time complexity
 
I'm attempting to implement strstr using the KMP method. This is the algorithm described on scaler topics; I also watched this video https://www.scaler.com/topi...
[4 replies] Last: [quote=seeplus]As for once I'm feeling in a goof mood.. Typo?? Eithe... (by deleted account xyzzy)
regex_match issue
 
I never used regex in cpp and I'm having issue with the following sample: int main() { // Get line length until ';' character with regex std::wstring line =...
[no replies]
File manager
 
Someone Please help Tools: - C++ - SDL 1.2.15 - CodeBlocks 20.03 Functionality: 1) Checking the catalog structure: – program searches through sub-cat...
[3 replies] Last: @zaneemma - What is your knowledge of C++? Do you know about std::file... (by seeplus)
by PeteDD
Link-time undefined reference to a class object (revisiting...)
 
This issue eludes me … once again. Undefined reference to a class object. It is similar to one we looked at earlier, but the answer does not seem to be simi...
[7 replies] Last: You could make myADC a pointer Or a function-local static variable (... (by mbozzi)
Neural Network does not work the right way
 
Hi all, I have recently been working on a C++ NeuralNetwork class and wanted to feed it with image data to be able to decide if the image data shows a cat or...
[7 replies] Last: Hey, this is a C++ forum, not a BASIC forum! :) (by Ganado)
vcpkg + Boost + ICU + Windows 10
 
Anyone familiar with vcpkg on Windows? I just installed it and then ran the      vcpkg install boost-locale boost-regex boost --triplet x64-windo...
[12 replies] Last: The amusing part of this discussion about vcpkg is I have (for me) a n... (by deleted account xyzzy)
  Archived months: [dec2022] [feb2023]

This is an archived page. To post a new message, go to the current page.