1,263
questions
1
vote
1
answer
116
views
How to define a generalisation to_string and to_wstring to avoid code duplication
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 ...
1
vote
0
answers
88
views
GORM - Syntax Error near "`", but no backtick in the query using string literal
I got this code to recurse into Categories structure:
I used this query:
err = DB.Exec(`
WITH RECURSIVE CategoryCTE AS (
SELECT ID, Title, Parent_id, Description, ...
2
votes
2
answers
132
views
c++17 User-defined literals strange behavior for sequence of strings
I spent some time while diagnosting the bug where I lost the comma between two strings created with std::string_literals.
EDIT
As soon a lot of commenters address to really clear case of compiler like ...
4
votes
3
answers
187
views
How to remove leading white-space in multi-line raw string-literals
When using multi-line raw string literals, how do we tell the compiler not to include the leading spaces?
I have the following bit of code:
#include <string>
#include <print>
int main()
{
...
1
vote
1
answer
42
views
TypeScript: Automatic Type Inference for Object Property Values Based on String Key
I have a task where I want a function in TypeScript to accept a string key of an object and infer the type of the value that the key points to. I'm almost there, but I'm running into an issue where ...
0
votes
0
answers
51
views
Is there a way to #include contents of Raw string without the delimiters? [duplicate]
I'm writing a thing for Arduino. The piece for the webpage currently has:
const char index_html[] =
#include "index.html.h"
;
where index.html.h contains:
R"MaRkEr(<!DOCTYPE ...
0
votes
0
answers
76
views
Syntax Highlighting C# Raw Strings for SQL
The raw string literal feature of c# seems very useful but I thought I would also get syntax highlighting especially for json objects and sql statements.
But with the visual studio 22 version 17.10.5 ...
1
vote
1
answer
36
views
Powershell, write creation of environment variables to file [duplicate]
I have a simple question I am struggling to find answer to.
I want to write next:
"$env:CI_JOB_STAGE = preprocessing" to a file.
I tried with this:
Add-Content -Path test.bat -Value "$...
1
vote
2
answers
129
views
Difference between a mutable and immutable string [duplicate]
I just started studying C++, but there is a thing that I don't fully understand: when you initialize a std::string variable with a string literal, like this:
std::string str = "some string";
...
0
votes
0
answers
18
views
Some syntax confusion in Python related to string literals [duplicate]
I am learning to manipulate data using Python. While I was learning with some course online, I found this piece of code having string literals.
w = 200
b = 100
x_i = 1.2
...
-3
votes
1
answer
63
views
printing " and ' in python [duplicate]
How can I print this ('''""") in Python?
I tried this but I got error:
print("'''"""")
and I tried this but I got error:
print("""""&...
1
vote
1
answer
153
views
how to allow long Raw string literals to be compiled without separate resource files
I'm working on a C++ codebase which has been provided with some library's source files which I'm prevented from breaking some guidelines or changing the library logic and paradigms, for instance I'm ...
3
votes
2
answers
203
views
How to avoid duplication of string literal text in functions that accept different width characters / strings?
I frequently need to create string manipulation functions in C++. My APIs tend to be written to accept std::basic_string<T> (effectively), but I also want to accept std::basic_string_view<T&...
0
votes
0
answers
87
views
Convert C code to C++ code - for initialising an array of structures [duplicate]
The following code, written years ago in C, will not compile in the Community version of Microsoft Visual Studio for C++:
typedef struct {
char* szString;
int iID;
} LocalStringElement;
...
3
votes
2
answers
124
views
Initializing an array of char - Is the string used to initialize the array stored separately in memory in addition to where the array is stored
In the book entitled Understanding and Using C Pointers by Richard Reese, on page 110 the author states
"An array of char can be initialized using the initialization operator. In the following ...