assignment-operator Questions
1
Solved
Here is my Python code that creates an infinitely nested dictionary:
a = a['k'] = {}
print(a)
print(a['k'])
print(a['k']['k'])
print(a is a['k'])
Here is the output:
{'k': {...}}
{'k': {...}}
{'k...
Judsonjudus asked 21/2, 2019 at 13:37
1
Solved
Please help me understand the following snippets:
my $count = @array;
my @copy = @array;
my ($first) = @array;
(my $copy = $str) =~ s/\\/\\\\/g;
my ($x) = f() or die;
my $count = () = f();
print(...
Sloop asked 7/2, 2019 at 0:0
4
Solved
The assignment operator in base class does not seem to be available in derived class. Given this code:
#include <iostream>
class A{
int value;
public:
A& operator=(int value){
this-&...
Raynata asked 6/2, 2019 at 10:44
2
Consider the following C++ code with my failed attempt to avoid preference of non-template copy&move constructors and assignment operators:
template<typename T> class A {
public:
A() { ...
Freeload asked 5/1, 2019 at 10:2
2
Solved
Just came from is_assignable and std::unique_ptr. @Angew tells me that because std::unique_ptr<int, do_nothing> and std::unique_ptr<int> are different types, so static_assert(not std::i...
Cordierite asked 21/12, 2018 at 13:23
1
Solved
Here is a test file from gcc, live demo
struct do_nothing
{
template <class T>
void operator()(T*) {}
};
int
main()
{
int i = 0;
std::unique_ptr<int, do_nothing> p1(&i);
std:...
Mumps asked 21/12, 2018 at 9:48
1
Solved
@g-grothendieck's answer to this question inspired me to play with some assignment functions such as ==<- or ><-.
See the following :
`><-` <- function(e1,e2,value) replace(e1, ...
Grownup asked 14/12, 2018 at 13:23
3
Solved
I was just looking at the implementation of functools.lru_cache, when I stumbled across this snippet:
root = [] # root of the circular doubly linked list
root[:] = [root, root, None, None] # initi...
Doublure asked 28/11, 2018 at 17:20
2
Solved
I am using the ++: operator to get a collection of two collections, but the results I get using these two methods are inconsistent:
scala> var r = Array(1, 2)
r: Array[Int] = Array(1, 2)
scala&...
Affluent asked 16/11, 2018 at 6:9
2
Solved
This is something I have wondered for a long time. Take the following example:
struct matrix
{
float data[16];
};
I know what the default constructor and destructor do in this specific example ...
Quip asked 12/11, 2010 at 11:50
2
Solved
According to the C++ reference on Copy assignment operator:
A defaulted copy assignment operator for class T is defined as deleted if any of the following is true
T has a non-static data member of...
Circumbendibus asked 8/11, 2018 at 18:6
2
Solved
I want to make the type of record that uses dynamic arrays.
Using the variables A and B of this type I want to be able to perform operations A: = B (and other) and be able to modify the content o...
Octavie asked 31/7, 2013 at 20:5
2
Solved
To be more specific why
std::is_assignable_v<int, int> << '\n';
returns false? Is it because an int has no overloaded assignment operator (being a primitive type and all)?
(by the way...
Quigley asked 20/9, 2018 at 16:23
1
Solved
This question is meant to be a FAQ entry for all initialization/assignment between integer and pointer issues.
I want to do write code where a pointer is set to a specific memory address, for ex...
Proof asked 5/9, 2018 at 13:52
2
Solved
Scala only sometimes desugars
a += b
to
a = a + b
but not always. For example, some mutable collections define a += method, where instead it becomes
a.+=(b)
Is this behaviour
entirely de...
Brame asked 21/8, 2018 at 15:28
2
I tried the following code as a naive attempt to implement swapping of R and B bytes in an ABGR word
#include <stdio.h>
#include <stdint.h>
uint32_t ABGR_to_ARGB(uint32_t abgr)
{
ret...
Patentor asked 25/7, 2018 at 5:0
2
I want to define (<- and access the name of the left hand side argument :
*<- functions use internally an intermediate '*tmp*' variable. Is it still possible to get the name of x ?
`(<-`...
Anna asked 9/7, 2018 at 13:12
9
Solved
In Java, I understand that assignment evaluates to the value of the right operand, so statements like x == (y = x) evaluate to true.
This code, however, outputs false.
public static void main(Str...
Sycamore asked 21/6, 2018 at 13:40
3
Solved
Consider the following code:
#include <memory>
#include <vector>
class A
{
private:
std::vector<std::unique_ptr<int>> _vals;
};
int main()
{
A a;
//A a2(a);
return 0;...
Megdal asked 21/6, 2018 at 17:26
5
Solved
I overloaded both subscript operator and assignment operator and I am trying to get right value to assignment operator
example
Array x;
x[0]=5;
by overloading subscript operator i can get value 0 ...
Selfdenial asked 23/11, 2013 at 22:13
2
Solved
Trying the make simple piece of code work:
std::thread threadFoo;
std::thread&& threadBar = std::thread(threadFunction);
threadFoo = threadBar; // thread& operator=( thread&&...
Gerlachovka asked 16/7, 2013 at 10:28
8
Solved
I have a long set of comparisons to do in Java, and I'd like to know if one or more of them come out as true. The string of comparisons was long and difficult to read, so I broke it up for readabil...
Vedavedalia asked 21/3, 2010 at 9:6
2
Solved
Let's have this code:
Test1 t1;
Test2 t2;
t1 = t2;
I believe there are three (or more?) ways how to implement t1 = t2
to overload assign operator in Test1
to overload type cast operator in Tes...
Tabloid asked 9/9, 2012 at 0:54
2
This is my first question to Stackoverflow, although I have been a consumer for many years. Please forgive me if I break rules. That is certainly not my intent. I have strenuously reviewed the rule...
Chyme asked 25/2, 2018 at 18:49
3
By digging into R source code (file R-3.2.2/src/main/gram.y lines 2836 to 2852) I found that the R parser/tokenizer considers that := is a LEFT_ASSIGNMENT token.
But when trying to use it as an as...
Kyle asked 28/9, 2015 at 7:31
© 2022 - 2024 — McMap. All rights reserved.