How does this template work?
    rikki cattermole 
    rikki at cattermole.co.nz
       
    Sun Jun 16 15:14:37 UTC 2019
    
    
  
On 17/06/2019 3:11 AM, Robert M. Münch wrote:
> How does the observerObject Template and function work? I'm struggling 
> because both use the same name and how is the template parameter R 
> deduced/where is it coming from? Looks like it's somehow implicitly 
> deduced.
> 
> 
> class ObserverObject(R, E...){...}
> 
> template observerObject(E)
> {
>     ObserverObject!(R, E) observerObject(R)(R range)
>     {
>         return new ObserverObject!(R, E)(range);
>     }
> }
> 
> struct TestObserver {...}
> 
> auto observer = observerObject!int(TestObserver());
observerObject is an eponymous template.
What this means (in essence) is the symbol inside the template block == 
template block.
Yes R is being inferred by the argument.
    
    
More information about the Digitalmars-d-learn
mailing list