2,499 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
14
votes
2
answers
793
views
Is there a way to have an implicit conversion operator from `null` without specifying the type of `null`?
I have a struct that I allow implicit conversion from string or StringBuilder.
public ref struct StringParam
{
private string s;
private StringBuilder sb;
public static implicit operator ...
4
votes
2
answers
244
views
Unexpected conversion from pointer to object during function call
This piece of code is a synthetic example extracted from a real world app.
This code doesn't make much sense, its only purpose is illustration and everything that is not relevant has been stripped.
#...
0
votes
2
answers
121
views
LAMBDA( value; value) isn't a identity function [closed]
The formula
=SPLIT("110円/1000002円.2";"\")
doesn't result equal to
=MAP(SPLIT("110円/1000002円.2";"\"); LAMBDA(v; v))
At the former, implicity conversion is ...
Best practices
0
votes
7
replies
115
views
SPLIT without implicit conversion
I am experiencing problems with this section of my formula
=LET(
args; MAP(SPLIT("11/11"&CHAR(10)&CHAR(10)&"1"
; CHAR(10)&CHAR(10)); LAMBDA(v; TO_TEXT(v)))...
0
votes
0
answers
41
views
VS Code not printing warnings
I'm trying to set up VS Code to learn C++. I downloaded the latest version of the compiler (g++) and tried running the following simple code, which (if I understand this correctly) should print a &...
3
votes
2
answers
281
views
Why does "0円" give integer in c
So, I am learning C language and was trying to make a function that returns the length of a string. In the if statement I mistakenly used "" instead of ''. So, instead of comparing to char '\...
19
votes
2
answers
832
views
How can a longer C++ implicit conversion chain succeed and a strict subchain of it fail in operator lookup?
Background
Our original problem was that including boost::logic::tribool caused an expression of the form referenceToClass != nullptr to compile happily. We ultimately tracked this down to the ...
6
votes
1
answer
250
views
Why can my C++ class be implicitly converted in one case, but not another?
I'm getting a compiler error about a type conversion that should be legal, to my eyes.
Let's say I have a home-grown string class, convertible from and to char*:
class custom_string
{
public:
...
6
votes
3
answers
268
views
How to create a unique_ptr while guarding against implicit conversion in ctor?
Here's an example:
class Example {
public:
Example(int m, int n, double pad) {}
Example(double size, double pad) {}
};
int main() {
Example example { 1.0, 1.0 };
auto ptr = std::...
3
votes
2
answers
358
views
Unexpected null in implicit operator method
Consider this implicit operator:
public class Person
{
public Person(string name) => Name = name;
public string Name { get; }
public static implicit operator string(Person person) => ...
3
votes
2
answers
153
views
Can't copy initialize string literals for my custom datatype (class object) even when I have the constructor for that
I have a program which lets C++ support arbitrary precision numbers (very large numbers). Takes datatype as string or string literals. Basically "762...."
Compiler: g++ (Debian 10.2.1-6) 10....
5
votes
1
answer
87
views
Implicit conversion from int to union works in designated initializer but otherwise fails to compile
I have a program that maps device registers to unions of bitfields and integers. This is part of a larger code base, so although this is very C-style code, we are compiling it as C++20. Here is a ...
1
vote
1
answer
125
views
Why doesn't the conversion operator prevent ambiguity?
I have this minimal working example:
class A {
public:
A(int i) {}
A(bool b) {}
};
class B {
public:
operator int() { return 1; };
operator bool() { return false; };
operator A() { return A(...
12
votes
2
answers
411
views
How is conversion to function pointer type special that it enables implicit conversion of a callable?
This is a follow up of this question: Why can I call a callable that is const-referenced and where the actual callable is a mutable lambda?
I can mimic the implicit conversion of a const mutable ...
-5
votes
3
answers
124
views
How to fix printing declared function [duplicate]
I'm still new at functions and I tend to print the function which I don't know how to print the declared function. It prints "1" and not "John".
#include <iostream>
void ...