How to avoid inout type constructor with Optional type wrapper undoing string type
    Ali Çehreli 
    acehreli at yahoo.com
       
    Tue Jul 24 14:11:51 UTC 2018
    
    
  
On 07/24/2018 02:47 AM, Timoses wrote:
 > Why does this fail while it works when replacing T with U in struct
 > W(T)?? It's so odd. Both T and U seem to resolve to "string".
 >
 >      struct W(T) {
 >          const T value;
 >          // Replacing `T value` with `U value` compiles
 >          this(U : T)(auto ref const T value) {
That means, "any U that can implicitly be converted to string". However, 
when U does not appear in the function parameter list, there is no way 
for the compiler to deduce U. (I don't think there is syntax to specify 
constructor template parameters explicitly.)
And if the parameter is always T, why is the constructor a template? Ok, 
perhaps U is used inside the constructor and the programmer needs to 
specify it... Still, I don't think there is such syntax.
Ali
    
    
More information about the Digitalmars-d-learn
mailing list