C++17 feature proposal: Allow type trait variable templates

53 views
Skip to first unread message

Daniel Cheng

unread,
Jan 6, 2022, 3:41:36 PMJan 6
to cxx
It saves typing, e.g. instead of:
  std::is_pointer<T>::value

One can simply write:
  std::is_pointer_v<T>

With only 80 columns, each character is precious :)

Example:

Daniel

dan...@chromium.org

unread,
Jan 6, 2022, 3:53:31 PMJan 6
to Daniel Cheng, cxx
Yes I would like to see us use these now.

--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAF3XrKrj9LWBQ7Q_7UWvpdQXWZiws0FxMeenvHeN%3DF79cFO8Jw%40mail.gmail.com.

Avi Drissman

unread,
Jan 6, 2022, 3:54:07 PMJan 6
to Daniel Cheng, cxx
+1

On Thu, Jan 6, 2022 at 3:41 PM Daniel Cheng <dch...@chromium.org> wrote:
--

Peter Kasting

unread,
Jan 6, 2022, 3:59:23 PMJan 6
to Daniel Cheng, cxx
+1

PK

--

Jeremy Roman

unread,
Jan 6, 2022, 4:20:07 PMJan 6
to Peter Kasting, Daniel Cheng, cxx
+1, though FWIW std::is_pointer<T>() has always been as short. :)

Will Cassella

unread,
Jan 6, 2022, 5:17:24 PMJan 6
to cxx, Jeremy Roman, Daniel Cheng, cxx, Peter Kasting
+1, code involving <type_traits> can often be somewhat difficult to read, this feature improves readability.

Roland Bock

unread,
Jan 7, 2022, 2:41:39 AMJan 7
to Will Cassella, cxx, Jeremy Roman, Daniel Cheng, Peter Kasting

Honglin Yu

unread,
Jan 7, 2022, 5:39:05 AMJan 7
to Roland Bock, Will Cassella, cxx, Jeremy Roman, Daniel Cheng, Peter Kasting
+1, just noticed that there is also "*_t" for "::type" like std::conditional_t

Peter Kasting

unread,
Feb 21, 2022, 11:08:33 PMFeb 21
to Daniel Cheng, cxx
AFAICT this landed but the text in the markdown still says "[tbd]".  Someone want to fix that quick?  (Sorry, I'm on vacation and not on a work setup)

PK

On Thu, Jan 6, 2022 at 12:41 PM Daniel Cheng <dch...@chromium.org> wrote:
--

Daniel Cheng

unread,
Feb 22, 2022, 1:43:26 AMFeb 22
to Peter Kasting, cxx
Reply all
Reply to author
Forward
0 new messages