Skip to main content
Filter by
Sorted by
Tagged with
Best practices
0 votes
3 replies
102 views

Philosophically, does GoogleTest's ASSERT_EQ(x, y) mean "check that x is equal to y" or "evaluate x == y and check that the result is truthy"? In the former case, then struct S s1, ...
Ben Voigt's user avatar
  • 286k
1 vote
1 answer
133 views

(I was making an integer class to replace C's stuff, then this hit me. I wanted an overload for pointer arithmetic.) MSVC and GCC pass without errors or warnings. Compilation: g++ -std=c++2c -fsyntax-...
La Creatura's user avatar
5 votes
2 answers
161 views

I am porting a large codebase from Linux/g++ to MacOS/Clang. I hit this compiler error in multiple places in Clang (where g++ builds successfully and does the right thing at run time): error: ...
barnabas's user avatar
  • 157
0 votes
0 answers
107 views

#include <concepts> struct A {}; struct B {}; constexpr bool operator==(A, A) { return true; } constexpr bool operator==(B, B) { return true; } constexpr bool operator==(A, B) { ...
xmllmx's user avatar
  • 44.6k
1 vote
2 answers
248 views

In our large code base (measurement processing application) we've had bugs where values were mixed up because everything is a double. So we decided to try-out strongly named types for things like ...
JHBonarius's user avatar
  • 11.5k
2 votes
1 answer
201 views

A std::reference_wrapper is guaranteed to be initialized (but can be rebound, unlike a normal reference). Being a wrapper class, what's the reason for std::reference_wrapper not to overload operator-&...
darune's user avatar
  • 11.5k
1 vote
0 answers
50 views

I have this generic function: pub fn bounding_circle<V>( points: &dyn Fn(usize) -> V, point_count: usize, ) where V: InnerSpace<f32> + Debug + Copy, for<'x> &...
Makogan's user avatar
  • 9,991
1 vote
1 answer
128 views

I have a template class and a custom std::formatter specialization for that class to be able to format and print it. When I create this class with std::errc data and try to print it, the compiler ...
sakcakoca's user avatar
  • 129
3 votes
1 answer
120 views

An Equals method on a specific class might be used to implement a PowerShell operator as -eq: class TestClass { hidden [String] $_Value TestClass([String]$Value) { $this._Value = $Value } [...
iRon's user avatar
  • 24.4k
1 vote
0 answers
74 views

When I use this code: #include "promise.hpp" #include <thread> using namespace std; int main() { stsb::promise<int> tstint = stsb::promise<int>(); thread waitthr = ...
Stas Badzi's user avatar
0 votes
2 answers
103 views

As has been pointed out elsewhere, the community thinks C++ binary operators like == should be nonmember functions. This presents a problem for me with private inheritance. #include <cassert> ...
Topological Sort's user avatar
0 votes
1 answer
59 views

In Dart, I can implement operator * that is called when someone writes MyClass() * 2: class MyClass { String operator * (int rhs){ return 'MyClass * int'; } } Is it possible to write a ...
user200783's user avatar
  • 14.5k
3 votes
1 answer
172 views

Say I have got a plain old data (POD) struct containing multiple numeric fields. I want to overload the comparison operators so that I can compare two instances of my POD. The problem is that I need ...
Giogre's user avatar
  • 1,664
3 votes
1 answer
269 views

Why is this code ambiguous starting with C++20? template <typename T> struct base_widget { bool operator==(T const&) const; }; struct gadget : base_widget<gadget> {}; bool foo(...
Jaka's user avatar
  • 1,241
1 vote
0 answers
65 views

...such as infix operator fun BigInteger.plus(other: Int) = this + other.toBigInteger() infix operator fun Int.plus(other: BigInteger) = toBigInteger() + other infix operator fun BigInteger....
Boris's user avatar
  • 39
0 votes
0 answers
81 views

The following piece of code compiles fine #include <iostream> #include <map> #include <memory> using namespace std; class child { public: child(std::string name,uint32_t ...
KPathak's user avatar
  • 49
2 votes
2 answers
70 views

I have an hierarchy with an operator() overloading like the following class Base{ public: virtual std::vector<float> operator()(const std::vector<float>& us) const { // ...
dEmigOd's user avatar
  • 640
0 votes
1 answer
49 views

I am trying to get to the point where essentially MyClass(A) << "hi " << 17 << std::endl; compiles and executes MyClass::finish() method on the accumulated stream. So far, ...
Paul Grinberg's user avatar
2 votes
0 answers
116 views

I read the following post : access operators "[ ], ( ), { }" overloading in Fortran 90 or 2003 and I would like to know if the situation has changed in new fortran versions (2008, 2018, 2023)...
Stef1611's user avatar
  • 2,515
0 votes
2 answers
75 views

I try to overide -- operator. I want prefix and postfix -- operator but c# doesnot allowed it even that there is different signature's function. the code: public static Rational operator --(Rational a)...
SHACHA's user avatar
  • 1
0 votes
0 answers
71 views

I practice easy coding on Codewars platform. There is a place where I found following exercise: Write a function that accepts two square matrices (N x N two dimensional arrays), and return the sum of ...
Asmoox's user avatar
  • 662
0 votes
1 answer
59 views

I have various methods for accumulating quantities in fixed-precision numerics based on the following data type: int95_t { long long int x; int y; }; The numbers count forward in x until it may ...
dscerutti's user avatar
  • 333
3 votes
1 answer
120 views

I'm using perfect forwarding to pipe a type through to a associated JsonRecord object. However, compiler is unable to deduce the type of std::endl when I want to pick it up as a token to forward to ...
glades's user avatar
  • 5,356
6 votes
2 answers
185 views

In this example code, why isn't using IParameterBase<TYPE>::operator=; working, and the base class assignment operator working? I recently changed to this templated version, previously I had ...
Paul Sheppard's user avatar
4 votes
2 answers
155 views

I am writing a matlab class and would like to overwrite the subasgn operator to achieve this obj.('elem1').('subelem1').('subsubelem1')=val; where the level of depth can vary. This type of multi-...
FangQ's user avatar
  • 1,564

1
2 3 4 5
173