top | item 46275846

(no title)

cjfd | 2 months ago

With 'auto' it is so very verbose. It can be shorter. Let us put "using TP = std::chrono::steady_clock::time_point;" in some header file to be used in many places. Now you can write

  TP start = TP::clock::now();
  do_some_work(size);
  TP end = TP::clock::now();

discuss

order

moregrist|2 months ago

I prefer to put the `using` in the block where you need the std::chrono code, which keeps it local and tidy. Putting it in a header is declaring a global type and asking for trouble; at least bound it in a namespace or a class.

UncleMeat|2 months ago

Some organizations don't like putting using declarations in headers since now you've got a global uniqueness requirement for the name "TP."

dosshell|2 months ago

You put the using as class member (private) or as local in the function.

gpderetta|2 months ago

how is TP more descriptive than auto here?