17,334 questions
Advice
3
votes
2
replies
213
views
Using a C++ const reference from a return value
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>
#...
2
votes
2
answers
145
views
How to simplify checking whether a reference variable is null?
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 ...
2
votes
2
answers
168
views
What are exactly structured bindings?
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:...
2
votes
1
answer
99
views
how to get update-able sheet name in google sheets
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 ...
1
vote
0
answers
52
views
C# Maui passing a reference of 'this' down a code chain in order to use a DisplayAlert, does not display the alert, but awaits a result [duplicate]
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 ...
3
votes
2
answers
266
views
"Transparent" function: perfectly forwarding an argument to the return value
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 ...
2
votes
1
answer
90
views
Allowing Access to Fields in Inner Struct with Different Names in Rust
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 ...
1
vote
1
answer
61
views
How to pass a std::thread::scope as a parameter with another reference
This works fine:
fn main() {
test1();
}
fn test1() {
let data = "data".to_string();
std::thread::scope(|scope| {
scope.spawn(move || {
println!("print ...
-1
votes
2
answers
185
views
Declaring member variables in a class interface header file
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 ...
5
votes
1
answer
196
views
std::copy_assignable_v not working for reference types, how to fix?
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
{
...
4
votes
3
answers
362
views
Passing a local reference to a closure
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 ...
Best practices
0
votes
2
replies
93
views
How should I store a dyn FnMut in a struct?
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 ...
1
vote
1
answer
270
views
Loss of reference
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&...
1
vote
1
answer
79
views
Question about reference of permission Read and Own
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 ...
1
vote
1
answer
53
views
I am trying to use the value in a cell as an address to paste to another cell in google sheets via apps scripts. Use cell F8 which = C6 to paste to C6
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 = ...