Skip to main content
Filter by
Sorted by
Tagged with
4 votes
3 answers
204 views

My instructor gave us this question for homework: 11. Select the TRUE statement. a) This code will not compile.The error will be: local variable c may not have been initialized b) ...
CSP.AT.MASH's user avatar
Advice
3 votes
4 replies
258 views

I have trouble understanding the C++ documentation. Will this cause a dangling pointer, or is it safe to do? I don't trust AI-generated information. #include <iostream> #include <vector> #...
Curious George's user avatar
2 votes
2 answers
169 views

I wrote a method that returns a reference to a variable (ref return), and sometimes the returned reference can be null. After calling this method I have to check if the reference is null, and I am ...
Theodor Zoulias's user avatar
2 votes
2 answers
178 views

I was surprised to get a deprecation warning from google benchmark function DoNotOptimize when calling it on a structured binding: benchmark::DoNotOptimize(const Tp&) [with Tp = int; typename std:...
Oersted's user avatar
  • 4,816
3 votes
1 answer
124 views

is there a way how to get updateable sheet name of the active or any other sheet without using scripts - only native formulae allowed and no hardcoding for example, in the spreadsheet there is a sheet ...
player0's user avatar
  • 132k
1 vote
0 answers
53 views

As I build a datagrid with elements that each have a command associated with them based on a template, I realized that I can't just have a DisplayAlert on the buttons that execute a command. I ...
Vlad SD's user avatar
  • 363
3 votes
2 answers
271 views

I'm trying to figure out how the signature of a completely transparent function might look. That is, a function that takes an argument T and that itself (i.e. from its return value) then looks exactly ...
Kamajii's user avatar
  • 1,929
2 votes
1 answer
95 views

I am trying to allow for the interface in an outer struct to allow using fields that it does not hold representing information of an inner struct. I will explain with an example because reading it ...
MrMoon01000010's user avatar
1 vote
1 answer
63 views

This works fine: fn main() { test1(); } fn test1() { let data = "data".to_string(); std::thread::scope(|scope| { scope.spawn(move || { println!("print ...
DanielV's user avatar
  • 675
-1 votes
2 answers
191 views

Having a Java and C background, I am currently learning C++ with an old but good book which explains that all members of a class including variables have to be declared but not initialized in its ...
Torsten Römer's user avatar
5 votes
1 answer
198 views

Consider the following code where I test whether a type is copy-assignable by using the std::is_copy_assignable_v type-trait: #include <print> #include <type_traits> struct IntProxy { ...
TemplateRex's user avatar
  • 71.1k
4 votes
3 answers
374 views

Consider the code below: for (T &t : some_vector_) { futures.push_back(thread_pool.submit([&t] { t.do_something(); })); } On some iteration i, t is initialized to a reference to a vector ...
Jack Humphries's user avatar
Best practices
0 votes
2 replies
108 views

I'm trying to make a struct that has dynamic methods by storing FnMuts in the struct. The FnMuts would be a function written in a scripting language like Python or Lua, but there might be some cases ...
Choosechee's user avatar
1 vote
1 answer
275 views

I am trying to create an event emitter similar to NodeJS: emitter.cc #include "event/emitter.h" namespace game { void Emitter::on(std::string eventName, Listener *listener) { std::list&...
Natan Camargos's user avatar
1 vote
1 answer
84 views

From references-change-permissions-on-places, places have three kinds of permission on their data: Read (R): data can be copied to another location. Write (W): data can be mutated. Own (O): data ...
Steven Lu's user avatar
  • 113
1 vote
1 answer
54 views

I would like to paste from one tab to the address of a cell in another tab, where the value changes. The problem I'm trying to solve is: how do I write the Apps Script code so that: var spreadsheet = ...
shacum's user avatar
  • 13
3 votes
1 answer
166 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
  • 25.7k
3 votes
1 answer
230 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
111 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
87 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,996
1 vote
1 answer
161 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
194 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
2 votes
1 answer
190 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
123 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
95 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.5k
5 votes
2 answers
321 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
309 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
91 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
114 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
143 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
1 vote
1 answer
88 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
108 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
118 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
44 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
188 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
220 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
95 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
80 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
150 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
341 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
131 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
172 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
46 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,105
1 vote
2 answers
119 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
219 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
84 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
1 vote
1 answer
101 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
2 votes
2 answers
2k 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

1
2 3 4 5
347