Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
92 views

I have a dictionary object, very simple: const mydict = { key1: "value1", key2: "value2" } how do I make a type that automatically converts an object like this into entries? ...
L1Q's user avatar
  • 37
0 votes
2 answers
160 views

I’m trying to write a Python function that satisfies three goals simultaneously: Exhaustively checks all possible values of a Literal argument. Avoids linter warnings like Ruff’s "too many ...
Danilo Horta's user avatar
6 votes
1 answer
131 views

I was testing the behaviour of the big three (GCC, clang, MSVC). I'm not sure what is standard-compliant. Consider this code: // p43.cxx #include <type_traits> constinit auto n1 = ...
La Creatura's user avatar
5 votes
1 answer
158 views

#include <iostream> using namespace std; int main() { // Case 1 cout << &5; // This line fails to compile. Ok, I get this because "5" is a rvalue. // Case 2 ...
Avi's user avatar
  • 179
2 votes
3 answers
278 views

Based on C++ documentation the size to hold hex literal grows from int -> unsigned int -> long -> unsigned long -> long long -> unsigned long long. But I wonder how to specify hex ...
caramel1995's user avatar
  • 3,065
4 votes
8 answers
280 views

C23 added support for binary literals (0xb10100110) and for grouping them for human readability using a separator character ('). This is great for input, but how does one change the printf grouping to ...
hackerb9's user avatar
  • 2,091
0 votes
1 answer
38 views

i made a unit test, it works fine. Now i got a task to change the data from variables in the test body to literals, to make it more readable. So i did and got problem: this test passes successfully: ...
matrixsh1t's user avatar
0 votes
1 answer
386 views

is there any way to concat array literals in rust? For example, I want an array like [0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 9] I can define an array [0; 8] and a [6, 9], but is there any way to write this ...
user avatar
0 votes
1 answer
141 views

This seems rather trivial, but I couldn't find the answer myself: How do I use a literal C char constant in a comparison with Cython? This doesn't work: cdef fct(char c): return c == 'x' sh$ ...
Sylvain Leroux's user avatar
-2 votes
1 answer
81 views

I use this sample code from Custom handlers | Fresh docs: import { Handlers } from "$fresh/server.ts"; export const handler: Handlers = { async GET(_req, ctx) { const resp = await ctx....
Ooker's user avatar
  • 3,404
3 votes
2 answers
272 views

I am very new to zig and doing a very simple coding exercise. The question is about scoring words in scrabble and presents a table. As a sort of challenge I wanted to replicate the scoring table as an ...
kaan_atakan's user avatar
  • 4,107
0 votes
0 answers
155 views

My framework contains a protocol that allows conforming types to describe themselves. One of its requirements is a static member containing the name of the type. This can be used as (for example) the ...
Cheezzhead's user avatar
2 votes
2 answers
894 views

I have a question about this construct: from enum import Enum from typing import Literal class Fruit(Enum): Apple = "apple" Bannana = "bananna" Watermelon = "...
Daniel Šebík's user avatar
0 votes
0 answers
38 views

I've used C for scientific programming for more than 15 years and I've never needed suffixes like F and L for numerical literals. I wonder why some very experienced programmers almost always use them....
apadana's user avatar
  • 732
0 votes
2 answers
948 views

Code from this link: https://github.com/openwch/arduino_core_ch32/blob/main/libraries/USBPD_SINK/src/usbpd_def.h I am looking at the previous file. I did some search and found something about unsign ...
Bao Ng's user avatar
  • 3
-1 votes
1 answer
562 views

This is more of a request for comments and critique rather than a proper question. Context: I am using simple classes with class variables as containers for string constants. These might hold ids of ...
florian's user avatar
  • 29
-3 votes
1 answer
3k views

enter image description here See image. What am i doing wrong? I'm a newbie with python, i don't have a clue what i am doing wrong ps: i previously installed the package elevenlabs with 'pip3 install ...
Bert's user avatar
  • 1
0 votes
2 answers
171 views

I have a chicken-and-egg issue: I need to echo a dot in an if statement in a batch script, but the command prompt crashes, saying '. was unexpected at this time.' Note that echoing treats everything ...
Ahmad Addas's user avatar
1 vote
1 answer
138 views

I wonder, is there another solution to modify to string literals and Is the solution really valid and optimal? #include <stdio.h> #include <string.h> #include <stdlib.h> char *...
Paroz's user avatar
  • 107
-1 votes
1 answer
80 views

let's say i have a program where i print the same line to the console multiple times throughout it's execution and the line needs to be passed to printf() multiple times. on the surface the option at ...
xXRunDeathXx's user avatar
0 votes
1 answer
113 views

I made a chrome extension with the v2 manifest that uses a lot of template literals coming from json files. I was rendering them using new Function which made it so easy. But with chrome extension ...
Patrick Matte's user avatar
19 votes
2 answers
3k views

Does C++23 now provide support for Unicode characters in its basic char type, and to what degree? So on cppreference for character literals, a character literal: 'c-char' is defined as either: a ...
mishar's user avatar
  • 455
2 votes
4 answers
347 views

Ben Saks in his lesson "Understanding Value Categories" at the 2019 CppCon in Aurora (CO) (great lesson btw) said: "Character string literals, such as "examplestring", are ...
ofkilmurray's user avatar
3 votes
2 answers
184 views

If I define a variable of the unsigned int type and initialize it with a value outside its bounds, it uses modulo and assigns itself a value in its range, right? For example: unsigned int a = ...
Rajdeep Sindhu's user avatar
2 votes
1 answer
884 views

The line assigning arguably a slice literal let integers: [i32] = [ 1, 2, 3 ][..]; gives a message that integers “doesn't have a size known at compile-time”. Why is it not obvious that storage space ...
Bernhard Bodenstorfer's user avatar

1
2 3 4 5
32