Skip to main content
Filter by
Sorted by
Tagged with
3 votes
1 answer
142 views

My program changed its behavior after updating Visual Studio to the latest version (2026). Simplifying it, I got the following minimal example, which contains a ternary operator with a throw in ...
Fedor's user avatar
  • 24.7k
3 votes
1 answer
214 views

I have the following code to normalize std::filesystem::path to always use forward slashes as separators: static decltype(auto) fix_path_separator(const std::filesystem::path& path) { if ...
Dominik Kaszewski's user avatar
1 vote
1 answer
109 views

I have an array $arr = ['a', ['b',['c','d','e']]];. So $arr[1][1][0] is 'c'. I have these indexes listed in n array: $idx = [1,1,0]; (this may sound tricky, but comes from the fact that I got them ...
fpierrat's user avatar
  • 818
0 votes
1 answer
76 views

Why can't I do it like this in Go? func do(m1 map[int]string) { var m map[int]string = make(map[int]string) *m1 = &m; } I have m1 map, which means I can now it's reference? How to assign ...
Pasha's user avatar
  • 1,988
1 vote
1 answer
128 views

I have the following utility method to get raw bytes of an object (to send via network, etc.): pub fn to_bytes<T>(data: &T) -> &[u8] { unsafe { slice::from_raw_parts((data as *...
Alexander's user avatar
  • 641
5 votes
1 answer
183 views

The following program gives segmentation fault. #include <iostream> using namespace std; class A { public: static int& a; }; int a = 42; int& A::a = a; int main() { a = 100; ...
Keshav Saraf's user avatar
0 votes
0 answers
119 views

I'm trying to understand the rvalue references in C++. Here's what I think they represent. Say we have an object, O. This object exists on the stack and has the name O. This makes this object a lvalue....
Setu's user avatar
  • 1,086
0 votes
0 answers
62 views

I have a mutable variable and a mutable reference to it. When I pass this reference to a function and return it back from there, it seems to violate Rust’s borrowing rules. What’s the reason for this? ...
Enes's user avatar
  • 9
2 votes
1 answer
169 views

We upgrade our codebase from c++17 to c++20 lately, and some code does not work as before. I take the following simplified sample code as show case here. None of the overloaded compare operators is ...
newID's user avatar
  • 343
1 vote
2 answers
116 views

I want to create a variable of type Foo. The class Foo consists of a variable called Bar bar_ which is filled directly in the constructor initialization. The thing is, class Bar has a reference to the ...
peter's user avatar
  • 59
1 vote
1 answer
90 views

I have a set of classes linked into an enum: #[derive(Default)] pub struct A { } #[derive(Default)] pub struct B { } #[derive(Default)] pub struct C { } enum Classes { A(A), B(B), C(C), ...
Alan Birtles's user avatar
  • 38.3k
5 votes
2 answers
315 views

In C++, a function with signature void f(A& a) (non-template) only binds to a lvalue. Is it possible for an rvalue to automatically cast itself to an lvalue? This is what I tried: #include <...
alfC's user avatar
  • 16.8k
12 votes
1 answer
297 views

I am going through "C++ Primer", and it is mentioned that for the following code: double dval = 3.14; const int &ri = dval; //Bind a const int to a plain double object. The ...
mindentropy's user avatar
0 votes
1 answer
83 views

I have a large pandas dataframe df of something like a million rows and 100 columns, and I have to create a second dataframe df_n, same size as the first one. Several rows and columns of df_n will be ...
MBlrd's user avatar
  • 165
28 votes
1 answer
2k views

Rust method calls are desugared to fully-qualified-syntax and function parameters are evaluated left to right. Why then does s.by_mut(s.by_ref(())) compile while other expressions don't? struct S; ...
RedRam's user avatar
  • 537
0 votes
2 answers
95 views

I asked a question about italicizing specific parts of a cell (Making variable strings of text italics in Excel VBA). I run the macro in column N to get what I want italicized, but when I reference ...
Kyle Gorbski's user avatar
3 votes
1 answer
130 views

I'm working on Python bindings of my C++ library (a mathematical optimization solver) and I'm stuck at a point where I create a Python callback evaluate_constraints() that takes two arguments, pass it ...
Charlie Vanaret - the Uno guy's user avatar
0 votes
0 answers
127 views

Is it legal and acceptable to take a pointer from a reference? The following code compiles and work as one might expect, so I assume it is a legal construct. However, it feels wrong to take the ...
slingeraap's user avatar
1 vote
1 answer
79 views

I am trying to use the multiprocessing module to parallelize a CPU-intensive piece code over multiple cores. This module looks terrific in several respects, but when I try to pass lists and ...
SapereAude's user avatar
1 vote
1 answer
97 views

I am creating wrappers for C structs containing register definitions with heavy use of bitfields. I would like to create reference getters for all of them, to provide consistent shorthand API (real ...
Dominik Kaszewski's user avatar
0 votes
0 answers
109 views

I have shot myself in the foot a fair number of times with declare until I started to differentiate its switches that are not all equal. Some set variable attributes, but some just affect scope. So ...
Albert Camu's user avatar
0 votes
0 answers
32 views

I've just noticed that my alt+2 hotkey for opening CodeLens show references window I've been using for years changed to alt+3. This happened only on my PC, on my laptop it's still on alt+2. There is ...
NKatic's user avatar
  • 17
0 votes
1 answer
148 views

There's some interesting shenanigans going on with references: #!/bin/bash read -r -d '' payload << EOF apple: vinegar orange: juice EOF populate() { declare -n _aa=$1 declare data=&...
Albert Camu's user avatar
-1 votes
2 answers
215 views

How can I reference an associative array and reassign its content from serialized string? (The eval requirement is now spelled out explicitly in the title, but this is natural when it comes to ...
Albert Camu's user avatar
2 votes
1 answer
84 views

I found the following VBA code for PowerPoint which works and allows PowerPoint to reference an Excel file Private Sub test() Dim xlApp As Object Dim xlWorkBook As Object Set xlApp = CreateObject(&...
jqx204s's user avatar
  • 55
-5 votes
1 answer
78 views

function t(..._a) { console.log("t says:", _a[0] === a); // Output: t says: true } function v([..._a]) { console.log("v says:", _a === a); // Output: v says: ...
Freezing Soul's user avatar
0 votes
2 answers
149 views

The Minimal Example that reproduces the issue is as follows: #include <iostream> #include <string> #include <list> #include <iterator> #include <vector> #include <...
user avatar
1 vote
0 answers
18 views

I understand I can pass a reference to an HTML element to my React custom hook in react such as following: let myCustomHook(elem:React.RefObject<any>) { // logic } However, passing by reference ...
Issac Howard's user avatar
3 votes
1 answer
208 views

I have recently started learning Rust from The Book. While learning about ownership, I came up with following piece of code: let mut s = String::from("hello"); let r1 = &mut s; Here it ...
kira5000's user avatar
  • 101
3 votes
1 answer
112 views

I'm trying to learn Rust and I managed to find two ways to solve a question (which was to convert from celsius to fahrenheit). fn convert_only_if_needed(celsius_temp : &f64) -> f64 { if !(*...
Adrián Pinado's user avatar
0 votes
1 answer
159 views

On my main form (frmMain) I host a (Konopka) PageControl (TRzPageControl named pgcMain) with a tabsheet created at design time (pgDashboard). I created at frmMain.Create a dynamic form frm : ...
PETROS GGG's user avatar
1 vote
0 answers
45 views

Initially, to me the answer was obvious. However, I've come across an answer explaining binding temporaries to constant lvalue references which states the following: This only applies to stack-based ...
Kaiyakha's user avatar
  • 2,075
1 vote
2 answers
113 views

What is the semantic difference between defining and initializing an instance of a structure and a reference to structure? In other words, what's the difference in Rust between these two programs? ...
mrn's user avatar
  • 1,093
3 votes
2 answers
196 views

While studying the cppreference spec of std::atomic_ref, I found myself brooding over the following sentence: Like references in the core language, constness is shallow for std::atomic_ref - it is ...
Angle.Bracket's user avatar
0 votes
1 answer
64 views

I'm trying to run the example program at https://developer.android.com/kotlin/coroutines#examples-overview in Android Studio Iguana: import androidx.lifecycle.ViewModel import kotlinx.coroutines....
doru001's user avatar
0 votes
0 answers
45 views

Im currently developing a webpage and during that i wrote some code that looks similar to this: $foo = ['bar1', 'bar2', "bar3"]; foreach($foo as $i => &$bar){ if($bar == "...
Josef Brennecke's user avatar
1 vote
1 answer
91 views

I've been trying to understand closures better. I originally wrote fn main() { let mut x = 0; let f = || x += 1; call_me(f); f(); println!("x = {x}"); } fn call_me<F&...
Daniel Walker's user avatar
1 vote
2 answers
1k views

I'm working with an older C# solution built on .NET Framework 4.8, which contains several libraries. Now, I'm developing a new solution targeting .NET 8 that needs to reuse some of those existing ...
Banshee's user avatar
  • 15.9k
0 votes
0 answers
42 views

I'm facing a problem with setting up project references between an MSTest project and a ConsoleApp in Visual Studio 2022. The MSTest project is not correctly recognizing or linking to the ConsoleApp ...
DanyOS's user avatar
  • 5
0 votes
0 answers
33 views

I have been working on a DOM object in Rust and to insure document integrity I want to implement back references to parent objects, prevent circular references, etc. Minimally my code looks like this: ...
Andrew's user avatar
  • 319
0 votes
1 answer
94 views

I've encountered a problem regarding referencing multiple versions of a DLL. I've tried various methods to solve it. I'm seeking help.Thanks! In a program, I referenced the DLL component of version 13....
Karos's user avatar
  • 1
2 votes
0 answers
55 views

Am I required to hold ref to HTMLImageElement to prevent it from being gc'ed befor its load/error events will be fired? for example: /** * @param { string[] } urls * @returns { Promise<...
vanilla's user avatar
  • 145
2 votes
1 answer
104 views

When writing: std::vector<double> vec{1.0,2.0}; std::span<const double> s(vec); s[0]=1.0; I get a compiler error, as expected: Cannot assign to return value because function 'operator[]' ...
Romain's user avatar
  • 47
2 votes
1 answer
104 views

I'm trying to figure out how C++ actually breaks down the argument-passing when the formal argument is a reference and the actual argument is of a type that requires type-conversion. Here's an ...
Joe Black's user avatar
  • 667
3 votes
1 answer
135 views

I'm confused about the concept of variable in PHP. As far as I know, a variable in PHP has a name ($p) and a value ('Carlo'). $p has an associated entry in symbol table, such an entry actually points ...
CarloC's user avatar
  • 313
0 votes
0 answers
43 views

I have no idea how to use them and why do we even need them But when i try to solve some computer problems it came out that i can simplify my program using referance, so can you show me an example of ...
kenwalker's user avatar
0 votes
1 answer
95 views

With openpyxl, when I use worksheet.move_range(range, rows=12, translate=True) the range will be moved 12 rows down. The translate=True will move the relative references in formulae in the range by ...
Sandy Hope's user avatar
1 vote
0 answers
86 views

I refactored some code and now my unit test is crashing. The code being tested runs fine in the project, but when I inherit from the class in the test fixture there is an error when running the ...
agmessier's user avatar
0 votes
0 answers
37 views

Sometimes it may be necessary (yes, likely against best practices) to deal with nested objects, such as lists, which can require multi-level indexation. I am curious of the following: 1. In Python, is ...
cherry_popsicle's user avatar
0 votes
0 answers
42 views

The Error error[E0499]: cannot borrow `*self` as mutable more than once at a time --> src\scanner\mod.rs:103:17 | 45 | impl<'a> Scanner<'a> { | -- lifetime `'a` defined ...
Omega500's user avatar

1
2 3 4 5
347