From e12edc6c0a18c1f279bb8ce36d21780c3590b041 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 6 Oct 2015 15:20:51 +1100 Subject: [PATCH] types: add elems implementation for container types --- types.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/types.hpp b/types.hpp index 1af648d4..55e28795 100644 --- a/types.hpp +++ b/types.hpp @@ -25,10 +25,17 @@ //----------------------------------------------------------------------------- /// Returns the number of elements of a statically allocated array template -constexpr size_t elems(const T (&)[N]) +constexpr size_t +elems (const T (&)[N]) { return N; } +template +constexpr typename T::size_type +elems (const T &t) + { return t.size (); } + + //----------------------------------------------------------------------------- template T