ps-lite icon indicating copy to clipboard operation
ps-lite copied to clipboard

Why using template function for GetEnv?

Open microwish opened this issue 8 years ago • 0 comments

include/ps/internal/utils.h:

29 template<typename V> 30 inline V GetEnv(const char *key, V default_val) { 31 const char *val = Environment::Get()->find(key); 32 if (val == nullptr) { 33 return default_val; 34 } else {
35 return atoi(val);
36 }
37 }

Both the comments of this function and where this function is called indicate the return value is of type int.

So I wonder why you use template.

Thanks.

microwish avatar Mar 25 '17 01:03 microwish