Skip to main content
2 votes
1 answer
155 views

I need to set the result from std::put_time from ctime into a std::string, how do I do this ? Here is my code: BBToolkit::LogManager::LogManager() { auto t = std::time(nullptr); auto tm = *std:...
joris studios's user avatar
5 votes
0 answers
176 views

I observe rather strange behavior of Visual Studio's compiler with short strings during constant evaluation, as can be demonstrated by this example: #include <string> constexpr char f( const ...
Fedor's user avatar
  • 25.1k
2 votes
1 answer
164 views

I want to create the following string: "name_1,name_2,...,name_100". This can be accomplished using the following code: #include <format> #include <string> // ... const auto ...
PlsHelp's user avatar
  • 347
3 votes
0 answers
150 views

I seem to run into issue with the use of std::ssize in C++. I am able to compile in string.cpp but not string_quiz.cpp. I ran this code with g++ -o string_quiz -std=c++23 string_quiz.cpp string_quiz....
dansyw91's user avatar
3 votes
1 answer
132 views

For this simple classes below. For MyClass, the constructor initializes str with s during construction using the intializer list. Does this mean that str doesn't get constructed at all yet until mc ...
Engineer999's user avatar
  • 4,159
0 votes
2 answers
302 views

If I have an empty string and I do .resize() I expected the size and the capacity to be that size. That is not the case in GCC or Clang or MSVC. Requesting a size of 17 gives you a capacity of 30 or ...
Zebrafish's user avatar
  • 16.7k
1 vote
0 answers
57 views

I'm trying to convert an std::array of integers to a string for output, so I tried using this string constructor: template< class InputIt > basic_string( InputIt first, InputIt last, const ...
venyanwarrior's user avatar
9 votes
0 answers
284 views

I want a templated function that calls a method of its template class depending on which class it is. I understand that a better way to achieve this would be using std::is_same, but irrelevant for the ...
Ivan Gorin's user avatar
2 votes
2 answers
121 views

I'm a bit lost why Option 1 doesn't work. In my understanding I should be able to write to a presized std::string whatever I want as long as I don't overshoot the string size, but it doesn't work on ...
glades's user avatar
  • 5,448
1 vote
1 answer
144 views

I wish to optimise the use of const string literals in a bulky c++ 20 project to enhance compilation and runtime performance In lots of source files string literals are declared with const std::string ...
MikyMax's user avatar
  • 11
22 votes
2 answers
2k views

The cppreference mentions that if initialization contains a dynamic initialization part, the program is ill-formed when using constinit in C++20. I just wonder why the following code compiles then: ...
Ijaz Ahmad's user avatar
1 vote
1 answer
149 views

I have a number of user-defined classes for which I would like to define a to_string function. However, instead of defining this for just std::string, I would like to define this for all the possible ...
Involute's user avatar
  • 245
2 votes
1 answer
106 views

I'm working on a project that requires shuffling a string then unshuffling said string later. Currently I shuffle the string on a Linux machine and attempt to unshuffle on a Windows machine, ...
WhiteKSI's user avatar
0 votes
1 answer
116 views

I came accros an error while using cxxparse/cxxparse4101 to parser a simple c++ source file. Can anyone give me a help? c++ file: //map.cpp #include<iostream> #include<map> #include<...
brandon xiong's user avatar
1 vote
1 answer
155 views

When declaring std::string cpp{}; does this call new/malloc? Assume we already have a const char* c. Is it possible to move the contents from c to cpp without extra allocations?
SpeakX's user avatar
  • 427

15 30 50 per page
1
2 3 4 5
81