Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COIt really never occurred to me that "a convertable type" could mean "a type which can be passed to a constructor to form a valid object of another type". Isn't it a bit weird to say "this object is of type bool" and then convert it by saying "an object of type bool is almost the same as a Description to which a bool is passed"?? That seems completely wrong behavior to me. I would fully expect the compiler to throw an error. I'm trying to find some C++ documentation on this, but I can't find it. Do you know where I can find it?
      singulars
    2. CO@jmbeck: The weirdness comes because you've given the type an implicit conversion constructor, which specifically says it should be convertible from `bool`. As I said, make it `explicit` if that conversion doesn't make sense; then the compiler will give the error you want. (Perhaps one could argue that that should be the default; but it isn't, so you'll just have to learn to use `explicit` when appropriate). User-defined type conversions are described in C++ 12.3 if you want the gory details; they can use a non-explicit conversion constructor or operator.
      singulars
    3. COI don't think of a constructor as "is used to convert from input arguments". I think of a constructor as a function which builds a specific type _from_ the input arguments. Specifying the constructor as `explicit` prevents conversions of the input arguments, such as float to int, or int to boolean. Standard conversions make sense because they describe the types as a subset or superset of each other. I don't see that same relationship with an object's constructor and the constructors input arguments.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload