Questions tagged [implicit-conversion]

Converting an object, variable or value from one type to another to satisfy a type restriction, without specifically requesting that conversion through language syntax.

Converting an object, variable or value from one type to another to satisfy a type restriction, without specifically requesting that conversion through language syntax.

Implicit conversion is a subset of .

2401 questions
1
vote
3 answers

g++ compiler and implicit conversion

I'm using g++ for compiling my C++ program, but I want to stop the implicit conversion between type like int and dooble for example: I have a function that use a double as parameter, but when I send in this function's parameter an int, the…
CHAKRI
  • 203
  • 1
  • 3
  • 9
1
vote
1 answer

how Remove double quotes from a string ruby on rails?

how Remove double quotes from a string ruby on rails ? I have a string like: "5,5" conversion logic : @a = @cart_id.chomp(',') abort @a.inspect
Ronak Bhatt
  • 113
  • 1
  • 2
  • 14
1
vote
0 answers

How to create a zero-overhead integer-like type that does not implicitly convert to other types?

We have a fairly sized C++ code base which uses signed 32-bit int as the default integer data type. Due to changing requirements, it is necessary that we switch to 64-bit long integers for a particular data structure. Changing the default integer…
1
vote
1 answer

Implicit conversion of return expressions to bool

When trying to build some legacy code (with a recent version of boost), I stumbled upon the following problem: #include bool foo(const boost::scoped_array bar) { return bar; } bool foo2(const…
choeger
  • 3,562
  • 20
  • 33
1
vote
3 answers

Using a class in a header file without access to its definition?

This is excerpt from google's c++ coding guidelines. How can we use a class Foo in a header file without access to its definition? We can declare data members of type Foo* or Foo&. We can declare (but not define) functions with arguments,…
LavaScornedOven
  • 737
  • 1
  • 11
  • 23
1
vote
1 answer

Mixing Implicit resolution with type lambdas

I know this question is deep type level programming and my failure is due to lack of knowledge. but I'd like to know at least how to get this one to compile. I need the compiler to figure out that my tuple2 can be a Higher-Kinded type in the…
shayan
  • 1,211
  • 9
  • 12
1
vote
2 answers

Implicit conversion between templates

I don't quite understand why this code here does not compile. It should be possible to call dist() like so: dist(GenericVec2,GenericVec3) (However horrible this may be). The idea is that the GenericVec3 argument gets implicitly converted into…
Thomas B.
  • 691
  • 4
  • 15
1
vote
1 answer

Stuck creating implicitly convertable from/to Int Natgural numbers class

I started playing with Scala few days ago. What I wanted to do is write a very small class that would represent natural numbers and I'd like it to be implicitly convertible from/to Int. Honestly I haven't done a lot so far. Here is the code: object…
Gonzalez
  • 681
  • 1
  • 11
  • 21
1
vote
2 answers

Implicit user defined conversion not working because operator and conversion constructor are unrecognized when compiling C++

I have included the minimal amount of code to replicate this issue. I would like it if I could assign a Furlong object to a Metric object and vice versa but instead the compiler gives me this error: no operator "=" matches these operands Header…
1
vote
0 answers

Why does implicit conversion require "inbetween" assembly?

I have two projects, Project A is a WPF Application and Project B is a WPF Control Library. Project A References default WPF stuff. But not System.Windows.Controls.Ribbon. Project B defines a class MainWindow which inherits from RibbonWindow,…
LuckyLikey
  • 3,504
  • 1
  • 31
  • 54
1
vote
1 answer

Type of char multiply by another char

What is the type of the result of a multiplication of two chars in C/C++? unsigned char a = 70; unsigned char b = 58; cout << a*b << endl; // prints 4060, means no overflow cout << (unsigned int)(unsigned char)(a*b) << endl; // prints 220, means…
ebi
  • 501
  • 3
  • 12
1
vote
1 answer

Failure of implicit conversion to number in median function in Oracle

I don't understand why implicit conversion isn't working for me for the median function in Oracle. (Obviously I have plenty of ways to work around it with proper explicit conversions, but I'm wondering why it's happening at all. Am I missing…
1
vote
2 answers

Implicit conversion with type constraints using "where" to exclude(or include) types

(Question at the bottom) I have a class which I need to be used like: float [] floatArray=new float[1024]; Foo var1=floatArray; // creates foo, assigns the array to a field var1.compute(); and Foo floatArray2 = new…
huseyin tugrul buyukisik
  • 11,469
  • 4
  • 45
  • 97
1
vote
1 answer

Scala doesn't recognize implicit conversion

I'm trying to define an additional method on Scala's Try via implicit conversions. Here's my isolated, reproducible example-- import scala.util.Try object App { def main(args: Array[String]): Unit = { val t = Try(2) t.getOrThrow() …
1
vote
2 answers

Implicit argument to conversion constructors

tl;dr: Is there a way to add a default argument from the current scope to all implicit constructors in C++? I am currently designing an interface for an embedded language in C++. The goal is to make the creation of syntactically correct expressions…
1 2 3
99
100