1,272 questions
3
votes
2
answers
111
views
How to hide the raw string literal indentation line in VS2022?
I would like to hide this line, looked in every indent and structure option but cannot manage to find which one makes this appear. I do not have extensions installed (monokai theme). I have disabled ...
13
votes
5
answers
3k
views
Definition of a C string with two terminating 0's
Can one write
static char str[] = "Foobar\0";
And be sure that the compiler generates two terminating 0's?
One explicitly, the \0.
The other one implicitly, the default string terminating 0....
0
votes
1
answer
103
views
Types from array of strings, need a string literal to pass into a function
In the following Rust code, I have an array of strings and I try to iterate over the names so that I can add them to my egui UI. I get two errors:
error: expected a literal and error: argument must be ...
4
votes
2
answers
164
views
Is assigning string literal to mutable char* legal on newer language revisions or just warned against by compilers?
Related to Is it bad to declare a C-style string without const? If so, why? , but that question is about best practise, while mine is more language lawyer. Similar questions have been asked, but for C+...
5
votes
1
answer
195
views
How to check a string literal in static_assert?
I want to check, that a string literal doesn't have some specific value.
#include <assert.h>
static_assert("aaa"[0] != 'a');
However, this results in this error:
error: expression in ...
3
votes
2
answers
599
views
python psycopg cursor : str is not assignable to LiteralString
I want to switch from synchronous db calls to asynchronous db calls.
I don't want to change my query builder. My query builder outputs a sql query as a string (actually in reality it outputs a query ...
0
votes
1
answer
65
views
Is there a way to forbid line breaks inside single and double-quoted strings?
I discovered today, to my horror, that Postgres accepts newline characters inside single- and double-quoted string literals:
postgres=# select 'a
postgres'# b';
┌──────────┐
│ ?column? │
├──────────┤
│...
19
votes
1
answer
2k
views
Escape braces in C# interpolated raw string literal
I need braces in a raw string literal that uses interpolation:
var bar = "Bar";
var s = $"""
Foo
{bar}
Baz
{{Qux}}
""";
Console.WriteLine(s);
I expect ...
1
vote
1
answer
69
views
TS type that requires string literal in the array/tuple
I am trying to build a generic type, that will guarantee presence of the string literal (no matter at what position)
What I desire for:
// 'a' is in the first position
const x1: ArrayContainingLiteral&...
0
votes
1
answer
104
views
String literals, List Literals and let statements not working as expected with Mojo 24.4.0
I am new to Mojo and just started learning the language. I am practicing some code on my Jupyter notebook in my Mac mini. My Mojo version is 24.4.0
CASE1:
The below simple code for ListLiterals gives ...
1
vote
1
answer
148
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
138
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
197
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 ...
7
votes
3
answers
275
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
128
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 ...