Implemented complex template overloading for tenary functions