Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91241981
arraysize.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 9, 07:16
Size
1 KB
Mime Type
text/x-c++
Expires
Mon, Nov 11, 07:16 (2 d)
Engine
blob
Format
Raw Data
Handle
22228020
Attached To
R12667 gbench-stream
arraysize.h
View Options
#ifndef BENCHMARK_ARRAYSIZE_H_
#define BENCHMARK_ARRAYSIZE_H_
#include "internal_macros.h"
namespace
benchmark
{
namespace
internal
{
// The arraysize(arr) macro returns the # of elements in an array arr.
// The expression is a compile-time constant, and therefore can be
// used in defining new arrays, for example. If you use arraysize on
// a pointer by mistake, you will get a compile-time error.
//
// This template function declaration is used in defining arraysize.
// Note that the function doesn't need an implementation, as we only
// use its type.
template
<
typename
T
,
size_t
N
>
char
(
&
ArraySizeHelper
(
T
(
&
array
)[
N
]))[
N
];
// That gcc wants both of these prototypes seems mysterious. VC, for
// its part, can't decide which to use (another mystery). Matching of
// template overloads: the final frontier.
#ifndef COMPILER_MSVC
template
<
typename
T
,
size_t
N
>
char
(
&
ArraySizeHelper
(
const
T
(
&
array
)[
N
]))[
N
];
#endif
#define arraysize(array) (sizeof(::benchmark::internal::ArraySizeHelper(array)))
}
// end namespace internal
}
// end namespace benchmark
#endif
// BENCHMARK_ARRAYSIZE_H_
Event Timeline
Log In to Comment