Skip to main content

Questions tagged [reference]

A reference is a value that enables a program to indirectly access a particular datum, such as a variable or a record, in the computer's memory or in some other storage device.

Filter by
Sorted by
Tagged with
3 votes
1 answer
174 views

I created a simple custom refernce_wrapper class template, which, in contrast to std::reference_wrapper, has some additional ...
Daniel Langr's user avatar
3 votes
0 answers
85 views

I recently had this (admittedly slightly crazy idea) on how to design a building block that can be used in safe Rust to build self-referential structs. Unlike gsrs or selfref it works completely ...
Feanor's user avatar
  • 233
-3 votes
1 answer
108 views

I was working on a code base where I have a function definition like this: ...
Himanshuman's user avatar
1 vote
1 answer
59 views

So I have this helper script that I use to move points around manually while debugging: ...
FaffyWaffles's user avatar
2 votes
2 answers
562 views

I am trying to create a non-generic slice function. I want a 'view' not a copy. The scan_from arg is so that successive calls ...
A T's user avatar
  • 535
1 vote
1 answer
872 views

I have written a code snippet to use HashMap<String, Vec<&String>> as the main data structure, and finally, I want to return a collected ...
prehistoricpenguin's user avatar
1 vote
1 answer
76 views

I have made a function to drop a row in a pandas.DataFrame. Since, in general, the input dataframe of a function is just a reference to the dataframe. So any change made in that function to the ...
aura's user avatar
  • 251
2 votes
1 answer
373 views

Needs A container holds two collections: Parent instances and Child instances; their items can be searched by name; A child can ...
yolenoyer's user avatar
  • 193
4 votes
1 answer
2k views

Here is a good article on an optional reference type in C++. They discuss std::optional<T&>, but as that doesn't compile I have made my own. One purpose ...
Blue7's user avatar
  • 373
5 votes
0 answers
145 views

I have a class that creates an object, PlannedYear, and then passes that object into several other classes to manipulate it. The ultimate goal of the class is to ...
MSOACC's user avatar
  • 211
2 votes
0 answers
138 views

I have a team lead that used to write references in a single script then access it in every script. Like for accessing a variable he has to write code in this way ...
Muhammad Faizan Khan's user avatar
4 votes
2 answers
277 views

I've recently started building an API that allows a consumer to create and manipulate musical entities such as notes, intervals, scales and chords. The first step is to create a a foundation of base ...
dfhwze's user avatar
  • 14.2k
2 votes
0 answers
35 views

My scenario is the following: I'm modelling a Program which has many Modules. Each Module has Symbols, some of which pointing at dependencies, which are other Modules. So a Module can be pointed to by ...
Thibaut Schaeffer's user avatar
4 votes
1 answer
287 views

The Fortran program 'MAIN' below calls 3 subroutines. It opens a file if it is not present, (overwrites if it is already present). writes something on the file using the file identifier integer and ...
Ather Cheema's user avatar
8 votes
1 answer
547 views

Looking forward for C# Nullable Reference Types in C# 8.0. I do not like to use the preview implementation in a production code though, so just went with these simple helper classes intending them to ...
Dmitry Nogin's user avatar
  • 6,131
4 votes
3 answers
830 views

I am using an offset variable to track the iteration position, and modifying / returning it. Is the below considered bad practice in Rust? I ask this because I don'...
Ross MacArthur's user avatar
1 vote
1 answer
5k views

I created these functions that will take any object and stringify it, and can then de-stringify it later. ...
Markus Fjellheim's user avatar
2 votes
1 answer
338 views

I have some hardware for which I have a driver for which I have a library which can be used to easily configure and probe the device. Now I want to add support for this library to python because the ...
cypheratheist's user avatar
2 votes
2 answers
159 views

I have following homework exercise from lecture "Variables, references and pointers": Write the function set (...) so that the following code works correctly: ...
user avatar
2 votes
1 answer
141 views

I have following homework exercise from lecture "Variables, references and pointers": Write the function zero (...) so that the following code works correctly: int x = 3; zero(x); ...
user avatar
8 votes
4 answers
3k views

Context: In a larger project, I am trying to build an utility class to encapsulate the parsing of input data. And I want it to be able to process either an already existing input stream, or a file ...
Serge Ballesta's user avatar
5 votes
1 answer
2k views

this is my implementation of std::forward ...
Fletcher Blight's user avatar
-1 votes
1 answer
6k views

I have a class that contains (among other things) a large vector. I need to pass an object of this class to a function. According to best practices, in C++ vectors and arrays should be passed by ...
BillyJean's user avatar
  • 161
4 votes
1 answer
334 views

I am trying to solve the Travelling Salesman Problem. This function creates the first level in the form of a linked list. This is what the levels look like: This is the code that creates it: ...
HelloImJon's user avatar
2 votes
0 answers
580 views

I have design a little class to allow to overload a function with universal references for a known type, but I'm not sure if that class will work as expected in any contexts. The indended purpose is ...
ABu's user avatar
  • 143
5 votes
1 answer
103 views

This is a self-teaching implementation to get files for a given directory in order to simplify os.Walk in Go (avoid to pass a func for recursively walking across ...
Natalie Perret's user avatar
12 votes
1 answer
1k views

I omitted all free operators but the equality comparisons ones because of verbosity. I am glad about any comments and improvements. Motivation I know that optional references are equivalent to ...
Maikel's user avatar
  • 750
6 votes
1 answer
329 views

In a previous post at Simplifying complex setf expressions, @sds suggested using the get-setf-expansion macro for implementing place modification, as discussed in ...
davypough's user avatar
  • 405
2 votes
1 answer
396 views

My original deque implementation and efficiency question lacked move semantics. After ratchet freak provided an example of how to define them I decided to try adding them to my deque. The unit test + ...
TOM__'s user avatar
  • 105
2 votes
1 answer
2k views

I am building an implementation of System.Windows.Input.ICommand that is like the commonly used RelayCommand, but doesn't keep a ...
AlexKven's user avatar
6 votes
3 answers
1k views

I'm trying to achieve, for lack of a better term, a "view" pattern in C++. It's probably most comparable to "views" in the Database world, where one can make a query, and then perhaps aggregate the ...
matt_fabina's user avatar
1 vote
1 answer
409 views

Follow up question to Binary Search Tree insert while keeping track of parent for node to be added I am implementing a red black tree for fun and am wondering how I should modify my basic BST insert....
httpNick's user avatar
  • 125
1 vote
2 answers
732 views

This question has a follow up question: Binary Search Tree insert while keeping track of parent for node to be added - iteration 2 I am implementing a red black tree for fun and am wondering how I ...
httpNick's user avatar
  • 125
5 votes
1 answer
1k views

I have the following class: ...
Mikey's user avatar
  • 412
7 votes
2 answers
6k views

I have modularized my code and currently my "main" function is movieSalesReport(). I am coming from Python where you can have the functions return multiple values. ...
Clever Programmer's user avatar
10 votes
3 answers
4k views

I have the following code which iterates on an Integer[] and makes sure that the the values in the array are in ascending order and that there are no neighbouring ...
Rich's user avatar
  • 237
2 votes
1 answer
7k views

Idea behind the class is same as boost::string_ref or llvm::SrtingRef. StringRef is immutable and not-owning. I did not ...
Nick's user avatar
  • 1,656
7 votes
1 answer
186 views

I posted this on Stack Overflow, but it was suggested that I move it over to Code Review. I would like some feedback on the way I decided to clean up code from the in a .NET project that had ...
tophstar's user avatar
4 votes
1 answer
1k views

I need a function call(f, args...) which calls the "function" f with the arguments args.... ...
leemes's user avatar
  • 515
2 votes
2 answers
4k views

In this I have written the setAnalyticsInfo() method. The code inside this is common to almost all other (30) classes, so I have created ...
Programmer's user avatar
1 vote
2 answers
510 views

I'm curious if this is the right way of going about the issue: ...
Gregorio Di Stefano's user avatar
6 votes
2 answers
14k views

Wouldn't it be better to always pass parameters by reference to avoid creating unnecessary copies? ...
user9029342's user avatar
4 votes
4 answers
235 views

Code in Java but should be readable also for c#... Let's assume I have a class with some reference types. Example: ...
radekEm's user avatar
  • 944
3 votes
2 answers
1k views

I am a newbie to C++ programming and am currently reading this book called Jumping to C++ by Alex Allain. I have finished the pointers chapter and I am doing the exercises at the end of the chapter. ...
Rojee's user avatar
  • 33