fix Issue 12237 - Inconsistent behavior of the instantiating enclosing template function