operator-overloading Questions
3
Solved
I need to read all attributes from a tеxt file that looks like the following for one Stern (engl.: Star) object. I need to replace the string "leer" with "" but there can also be a valid string whi...
Neolatin asked 30/8, 2017 at 9:6
6
Solved
Why is it not possible to overload the ternary operator ' ?: '?
I use the ternary operator often to consolidate if statements, and am curious why the language designers chose to forbid this operat...
Faunia asked 30/7, 2013 at 17:23
3
Solved
I have gone through some examples in the internet for operator overloading where the return type of operator+= is T&. Since we can't chain += like T a = b = c; is it okay to declare the return ...
Remde asked 26/3, 2016 at 5:58
3
For my matrix class I want to do some sort of operator overloading (probably using expression templates) on range-v3 views for + - / * % .
For example if I want to get a view of the sum of two colu...
Compatible asked 15/2, 2019 at 17:36
12
Solved
In the Boost Signals library, they are overloading the () operator.
Is this a convention in C++? For callbacks, etc.?
I have seen this in code of a co-worker (who happens to be a big Boost fan). ...
Nuggar asked 25/11, 2008 at 14:7
5
Solved
Sometimes I have structs such as this --
struct aggregate1 {
std::string name;
std::vector<ValueT> options;
size_t foobar;
// ...
};
-- where (in)equality is simply defined as (in)equa...
Fijian asked 14/2, 2011 at 11:30
3
Solved
I'm trying to write an abstract class with some pure virtual binary operators, which should be implemented by the derived class in order to accomplish operator polymorphism. Here's a simplified exa...
Friede asked 21/10, 2012 at 14:10
3
Solved
According to the Groovy docs, the == is just a "clever" equals() as it also takes care of avoiding NullPointerException:
Java’s == is actually Groovy’s is() method, and Groovy’s == is a ...
Creepie asked 13/3, 2012 at 10:24
1
Solved
template<typename Integral>
struct IntegralWrapper {
Integral _value;
IntegralWrapper() = default;
IntegralWrapper(Integral value)
: _value(value) {}
operator Integral() const {
ret...
Offhand asked 26/3, 2022 at 16:20
5
I have a 2D array and I want to define a function that returns the value of the index that the user gives me using operator overloading.
In other words:
void MyMatrix::ReturnValue()
{
int row = 0,...
Supralapsarian asked 25/12, 2015 at 8:50
1
Solved
I want to overload the operator @ in python for a class I have written. I know how to do operator overloading in general (i.e. by defining __add__ and __radd__ to overload +) but I could not find a...
Isaacson asked 17/3, 2022 at 12:2
2
Solved
My question is if there is operator overloading in typescript, if it exists I could give an example or a link where you can read about it.
Bushtit asked 20/3, 2016 at 3:55
4
Solved
I'm doing some revision of my C++, and I'm dealing with operator overloading at the minute, specifically the "="(assignment) operator. I was looking online and came across multiple topics discussin...
Medieval asked 30/1, 2012 at 23:6
1
I know the general use cases for the friend keyword with regards to encapsulation but one a couple of occasions, I have needed the friend keyword just to "get the job done". These use cas...
Christology asked 20/12, 2021 at 6:43
1
Based on the answer in Implicit conversion when overloading operators for template classes I was able to write the following code that works perfectly fine (simplified example):
namespace my_librar...
Mestee asked 4/12, 2021 at 23:28
4
Solved
How to make two objects in Java comparable using "<" or ">"
e.g.
MyObject<String> obj1= new MyObject<String>(“blablabla”, 25);
MyObject<String> obj2= new MyObject<String&g...
Multidisciplinary asked 21/3, 2015 at 4:18
4
Solved
Someone can explain me a warning from g++ ?
Given the following code
#include <iostream>
namespace foo
{
struct bar
{ friend std::ostream & operator<< (std::ostream &, bar...
Sarong asked 25/6, 2017 at 19:37
1
Solved
Consider the following code, which mixes a member and a non-member operator|
template <typename T>
struct S
{
template <typename U>
void operator|(U)
{}
};
template <typename T&g...
Avisavitaminosis asked 28/10, 2021 at 21:14
1
Solved
In the following example struct S inherits from two functional objects A and B each with its own operator (), and then declares using A::operator() to take the operator from A:
using A = decltype([...
Psia asked 17/10, 2021 at 5:47
6
Solved
a.h
#include "logic.h"
...
class A
{
friend ostream& operator<<(ostream&, A&);
...
};
logic.cpp
#include "a.h"
...
ostream& logic::operator<<(ostream& os,...
Dorkus asked 24/5, 2012 at 20:26
9
Solved
C++ syntax allows defining overloaded operators either inside the struct/class like:
struct X
{
void operator+(X);
}
or outside of the struct/class like:
void operator+(X, X);
but not as:
struct...
Loram asked 10/8, 2012 at 1:4
8
Solved
Is it possible to overload the default function operator (the () operator) in C#? If so - how? If not, is there a workaround to create a similar affect?
EDIT:
I'm trying to give a class a default o...
Earthly asked 15/3, 2010 at 20:15
1
Solved
A class can declare several conversion operators. In particular it can be conversion operators to some type and to const-reference of the same type. Which of the two conversion operators must be se...
Capillaceous asked 12/9, 2021 at 5:46
2
Solved
It is not specified if call to ostream operator<< can fail or throw any exception and I have never encounter this.
Is there a case where ostream operator<< could fail ?
If no, why sta...
Illdisposed asked 7/11, 2019 at 15:50
1
Solved
I'm studying about operator overloading in kotlin and I ran into invoke method. When I did my research about it I found out it works much similar to init constructor of every class.
I cannot get my...
Provo asked 14/7, 2021 at 8:2
© 2022 - 2024 — McMap. All rights reserved.