Skip to main content
Filter by
Sorted by
Tagged with
4 votes
1 answer
208 views

This simple code: #include <print> int main() { volatile int i = 5; std::println("{}", i); } Doesn't compile with any major implementation of the std library. Any particular ...
ixSci's user avatar
  • 13.9k
4 votes
1 answer
113 views

This question has to do with syntactic conventions for string encoding identifiers in locale names passed to setlocale in C, focusing on the particular example of UTF-8. My preliminary observation is ...
NikS's user avatar
  • 194
4 votes
3 answers
274 views

this seems just like a little quirk that I can fix just by including <cmath> where std::floor is used, but still this is weird and I'm wondering if anyone knows what's happening. I have a ...
Zebrafish's user avatar
  • 16.3k
1 vote
0 answers
126 views

The following program #include <charconv> #include <string> #include <iostream> int main() { std::string s = "0X1.BC70A3D70A3D7P+6"; std::cout << "...
eyelash's user avatar
  • 4,126
1 vote
2 answers
213 views

I learned ages ago that Standard Library containers won't accept references. E.g. this simple program won't compile because of attempting to create a vector of int&: #include <vector> int ...
StoneThrow's user avatar
  • 6,435
4 votes
2 answers
396 views

If I wanted to only use std::string, for example, wouldn't importing a (theoretical) std::string module be more performant than importing the entire standard library? Is it for ease of use, since you ...
user avatar
1 vote
1 answer
102 views

I need to use the logarithmic integral function which is defined in the cmath header. Unfortunately, I get an error: no member named 'expint' in namespace 'std' when I try to compile it. To reproduce ...
João Viana's user avatar
0 votes
0 answers
101 views

I'm solving some competitive programming problems related to vectors, but I can only use modules from the standard library, I'm not sure if there is any module that defines vectors and vector ...
Peco's user avatar
  • 13
6 votes
1 answer
1k views

I'm looking at the standard library documentation, and I see that from typing import Sequence is just calling collections.abc under the hood. Now originally, there was a deprecation warning/error and ...
Dave Liu's user avatar
  • 1,164
5 votes
1 answer
537 views

I know that at least most Ranges view types don't require any heap-allocation. For example, you can take a C array on the stack and pipe it through std::views::take(42) without causing any heap-...
Quuxplusone's user avatar
  • 28.7k
-2 votes
1 answer
586 views

What's the difference between types.Implements and types.Satisfies in golang? I'm working on a code that inspects Go AST.
Seiya's user avatar
  • 143
7 votes
3 answers
1k views

Python's standard library is vast, and my intuition tells that there must be a way in it to accomplish this, but I just can't figure it out. This is purely for curiosity and learning purposes: I have ...
ruohola's user avatar
  • 24.8k
1 vote
2 answers
135 views

The javadoc for Arrays.sort(T[] a, Comparator<? super T> c) from the package java.util in the standard library for Java 20 API docs reads as follows: public static void sort(T[] a, Comparator&...
GreyBit's user avatar
  • 107
1 vote
0 answers
66 views

Maybe this is a stupid question, but I'm new to this and trying to understand things. Let's say I want to write a simple "Hello World" program: // hello.c int main() { printf("%s\n&...
moped's user avatar
  • 21
1 vote
2 answers
269 views

I'm currently trying to get a better understanding of Apple's open-source Swift compiler on GitHub. After using Swift for several years, I've gotten used to the philosophy of defining important types ...
Frævik's user avatar
  • 19
1 vote
1 answer
192 views

Basically I want to this: template<typename TYPE> struct not_rvalue_reference{ typedef std::conditional_t<std::is_rvalue_reference_v<TYPE>, std::remove_reference_t<TYPE>, TYPE&...
AKL's user avatar
  • 1,399
3 votes
1 answer
264 views

I'm having trouble understanding which functions from the standard library can throw exceptions, and if so which and when. Some functions are noexcept, in which case ok they don't, but if I look for ...
Eternal's user avatar
  • 3,114
0 votes
2 answers
319 views

In this case I want to read integers from standard input such that they are separated by spaces and newline. My first attempt was similar to the following code: fn splitter(x: String) -> impl ...
true equals false's user avatar
1 vote
1 answer
62 views

It's easy to overload your own functions like so: void testVal(loc l) { println("LOC <l>"); } void testVal(value v) { println("VAL <v>"); } such that testVal(|...
Teun M.'s user avatar
  • 194
0 votes
1 answer
179 views

What is the difference between Ordering.by() and Ordering.on() in Scala? (Well, one is defined in the trait and the other in the companion object, and the implementation code is also different, but ...
18446744073709551615's user avatar
2 votes
1 answer
259 views

Is a namespace contained in a library or a library is contained in a namespace? How many namespaces are there in the C++ standard library ?
Sonu Gupta's user avatar
4 votes
3 answers
1k views

Using the <stdarg.h> header, one can make a function that has a variable number of arguments, but: To start using a va_list, you need to use a va_start macro that needs to know how many ...
KianFakheriAghdam's user avatar
2 votes
1 answer
485 views

I am using the python trace module in order to figure out why my program is exiting early. However, there seems to be a bug with the trace module itself. When i run py -m trace -t src/main.py > ...
Michael Sohnen's user avatar
0 votes
1 answer
282 views

There are a number of under-the-hood implementations of the Context interface in the Go standard library. For instance, the Background and TODO contexts are backed by the unexposed emptyCtx type which ...
Ivan Velichko's user avatar
0 votes
3 answers
340 views

I'm interested in how List.init and other library functions are implemented in OCaml. Where can I see the implementations? I checked this official link: https://v2.ocaml.org/api/List.html and only ...
stht55 's user avatar
  • 410
5 votes
1 answer
1k views

As it was in Java, any object that is Iterable can be used in an enhanced for loop. I thought the same held true for Kotlin as well, until I discovered that kotlin.collections.Map is not Iterable at ...
SMMH's user avatar
  • 391
0 votes
1 answer
55 views

I am trying to use logging when try fails. I have a for loop for converting a string of date into datetime format. For example, converting "03/05/2021" to 2021-05-03. However, there are ...
Jaino's user avatar
  • 1
0 votes
2 answers
377 views

The docs for InputStream.read(bytes) say "This method blocks until input data is available, end of file is detected, or an exception is thrown." However, java.io.FileInputStream extends java....
Max Heiber's user avatar
  • 15.7k
7 votes
1 answer
2k views

I've noticed a deprecation note on the Rust std page next to u8, i8, u16 and so on: What is going on, and what will the replacement be?
Oleksandr Novik's user avatar
7 votes
1 answer
3k views

I have found articles on how to implement a Disjoint Set (Union Find Algorithm implementation) for C++, Java, Kotlin, Python, etc.. The implementation of it is not especially difficult, although there ...
AaronC's user avatar
  • 753
4 votes
1 answer
160 views

I am working with the Map module in OCaml. Consider the following code to create a map with ints as keys: module Int = struct type t = int let compare a b = a - b end module IntMap = Map....
ajax2112's user avatar
  • 238
2 votes
1 answer
8k views

I am trying to use zlib.crc32 to compute CRC in Python. I would like to be able to set the generator polynomial of the CRC, but I cannot find any documentation. So the question is: can this be done? I ...
TJ1's user avatar
  • 8,690
3 votes
0 answers
109 views

As a part of academic project I was about to microbenchmark some Java and Kotlin collections behaviours, and compare them to each other. Recently I found out, that under the hood Kotlin, when run on ...
Adalbert's user avatar
3 votes
3 answers
415 views

This question was discussed a few times but all those discussions almost a decade old and there was no good solution. The question is the same. We have smart pointers, like unique_ptr, that is great. ...
Alex's user avatar
  • 819
0 votes
1 answer
299 views

As seen in the image below, I finished working on my project folder "click" under the main folder "my project." I didn't establish a virtual environment when I first started ...
B A C H A S H's user avatar
-2 votes
1 answer
112 views

The header files of C library functions can be found under /usr/include. The actual source files, however, don't seem to be simply located anywhere in the file system. So what exactly happens under ...
cssdev's user avatar
  • 79
0 votes
1 answer
564 views

Following Swift Standard Library documentation, &+ discards any bits that overflow the fixed width of the integer type. I just did not get why adding two maximum values, 8-bit signed integer can ...
David Taylor's user avatar
1 vote
1 answer
1k views

Are there any functions like the built-in functions getattr and hasattr in the standard library but which skip instance attributes during attribute lookup, like the implicit lookup of special methods? ...
Géry Ogam's user avatar
  • 8,434
25 votes
1 answer
36k views

In Python, I want to get the current Unix timestamp and then store the value for the long term and be handled by non-Python systems. (I am not merely trying to compute the difference between two ...
Nayuki's user avatar
  • 18.8k
3 votes
2 answers
1k views

I need set-like data structure with these properties: hashable no duplicate elements maintains order immutable iterable part of standard library? want to keep it simple What is happening: frozenset([...
Octavio del Ser's user avatar
4 votes
2 answers
10k views

I want to get the cpu usage during testing for my ML model (during a call to predict). Here is currently what I am doing. p is the current process: start = p.cpu_percent(interval=1) y_hat = clf....
Yurroffian's user avatar
0 votes
0 answers
51 views

I am currently attempting to program a sort of database in C. When I create a new character for the database, it should not have the same name as any other character, case-insensitive - so, if "...
DivineGoose's user avatar
0 votes
2 answers
1k views

Here is the code I used to calculate average with numpy and pandas def calc_average_books_stock(): text_file = open('book_data_file.txt') values = [] for index,data in df.iterrows(...
Shaheed Blackman's user avatar
0 votes
0 answers
27 views

I know there are plenty of discussions about this topic, like this famous one (see sbi's answer). My goal is to overload the operator + for two vectors, starting from the operator +=, as explained in ...
Vefhug's user avatar
  • 149
19 votes
2 answers
8k views

I have a Kotlin multiplatform project, and I would like to get the current unixtime in the shared code. How do you do that in the Kotlin standard library?
Daniele B's user avatar
  • 20.6k
3 votes
2 answers
2k views

How to get the reference to the actual Node (entry) object from LinkedList - Not the value that it holds? Something like this : import java.util.LinkedList; public class Main { public static ...
Dost Arora's user avatar
1 vote
1 answer
148 views

In Clojure/Script the contains? function can be used to check if a subsequent get will succeed. I believe that the Clojure version will do the test without retrieving the value. The ClojureScript ...
clartaq's user avatar
  • 5,382
-2 votes
1 answer
1k views

I've been trying to create a program which allows users to view a text file's contents and delete some or all of a single entry block. An example of the text's file contents can be seen below: Special ...
TropicalMagic's user avatar
1 vote
0 answers
127 views

What is purpose of iteratorCount in the following code (from https://deno.land/[email protected]/async/mux_async_iterator.ts)? #iteratorCount = 0 #yields = [] #throws = [] #signal = deferred() add () { ++...
kwonryul's user avatar
  • 565
-1 votes
1 answer
619 views

I would like to include pty.h which is not normally available on Unix (Not included in standard library). On the Internet, you can get the related header file content. So how do you add this header ...
Tthrow's user avatar
  • 55

1
2 3 4 5
14