fix template api for const methods and returned objects