diff options
author | Robert Guo <robertguo@me.com> | 2018-01-27 11:37:24 -0500 |
---|---|---|
committer | Robert Guo <robertguo@me.com> | 2018-01-27 11:39:46 -0500 |
commit | 8d9b68094ca79bce5da7cf530a2e14383b466a72 (patch) | |
tree | 32ae219957779a2baf60d26a42e7086e015f473a /src/third_party/benchmark-1.3.0/benchmark/src/arraysize.h | |
parent | 0aeb5ce7e8d4a190dac43fd110533eef149f7880 (diff) | |
download | mongo-8d9b68094ca79bce5da7cf530a2e14383b466a72.tar.gz |
SERVER-32785 integrate Google Benchmark with SCons
Diffstat (limited to 'src/third_party/benchmark-1.3.0/benchmark/src/arraysize.h')
-rw-r--r-- | src/third_party/benchmark-1.3.0/benchmark/src/arraysize.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/third_party/benchmark-1.3.0/benchmark/src/arraysize.h b/src/third_party/benchmark-1.3.0/benchmark/src/arraysize.h new file mode 100644 index 00000000000..51a50f2dff2 --- /dev/null +++ b/src/third_party/benchmark-1.3.0/benchmark/src/arraysize.h @@ -0,0 +1,33 @@ +#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_ |