How does this template work?

Robert M. Münch robert.muench at saphirion.com
Sun Jun 16 15:11:29 UTC 2019


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());


-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



More information about the Digitalmars-d-learn mailing list