Skip to main content
-4 votes
1 answer
173 views

I am trying to overload the % operator in C++ to make it do division instead of modulo. For example, 5 % 4 should give me 1.25 after overloading. But I get "nan". Why? This is the code I ...
RAVINDRA DIVEKAR's user avatar
1 vote
1 answer
161 views

I want to redefine new and delete operators to use a custom allocator in a c++ project with multiple translation units. Here are the redefines written in the memops.hpp file: #pragma once #include &...
mdjukan's user avatar
  • 173
0 votes
1 answer
165 views

[Note: I'm stuck with C++17.] I have a class template that is instantiated over a fairly large number of types (~25). A few of them can correctly be converted among one another, and I would like to ...
chenel's user avatar
  • 43
3 votes
2 answers
197 views

According to what I know, the result value of an overloaded operator->() can be any type T provided that T is either a pointer type or it is a class/struct which also exposes an overloaded operator-...
Die4Toast's user avatar
  • 123
3 votes
2 answers
142 views

The member arrow operator is treated by the compiler in a special way. Since an overloaded arrow operator can have an arbitrary return type, several such operators from different classes may need to ...
Die4Toast's user avatar
  • 123
2 votes
3 answers
171 views

Im trying to define the spaceship operator for a simple template string class. namespace mylib { template <size_t N> struct String { String() { *data = '\...
Andreas0815's user avatar
7 votes
1 answer
175 views

My program after porting to Visual Studio shows some weird results. After reduction I came to this minimal reproducible example: consteval auto operator +( auto x, auto&& y ) { return x += ...
Fedor's user avatar
  • 24.7k
0 votes
1 answer
98 views

I am developing quite a large Class whose objects require relatively costly validation if they are created by the public constructors, but for which the validation can be dispensed with for private ...
jedynygucio's user avatar
2 votes
0 answers
88 views

Compile Silo and get the following error error: no match for ‘operator<<’ (operand types are ‘std::ostringstream’ {aka ‘std::__cxx11::basic_ostringstream<char>’} and ‘std::pair<const ...
Miya's user avatar
  • 29
0 votes
0 answers
85 views

I got a function: bool equal(int var, std::initializer_list<int> list) { return std::find(list.begin(), list.end(), var) != list.end(); } which works, I got no error when I use the function....
Alexandre Man's user avatar
-1 votes
1 answer
143 views

package test; public class Test { public static void main(String [] args) { int a = 10; int b = 12; System.out.println( ++a == 11 || b++ == 12); ...
Mustafa Quraishi's user avatar
3 votes
2 answers
123 views

In the program below, class A has a convert-to-int operator. Class B has a convert-to-A operator. While the compiler converts A to int implicitly, it fails to do so for converting B to A: class A { ...
modjtabaf's user avatar
-1 votes
1 answer
235 views

In .pxd file, I wrote _Point operator+(const _Point other) const _Point operator -(const _Point other) const bool operator==(const _Point other) const In .pyx file, I wrote def __eq__(...
Punreach Rany's user avatar
4 votes
1 answer
227 views

So I wanted to improve the noexcept of some operators and functions in my code can I mark this function noexcept ? std::string remove_suffix(/*passed by copy*/ std::string s) /*noexcept*/ // is ...
user avatar
1 vote
1 answer
59 views

It seems the operator 'in' on tuple won't only match the whole string if there is only one item in the tuple. The behavior is different from 'list' and 'set'. I don't understand where the difference ...
Alex Chen's user avatar

15 30 50 per page
1
2 3 4 5
181