1 // Copyright 2015 Google Inc. All rights reserved.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #include <benchmark/benchmark.h>
21 // Compute the total size of a pack of std::strings
22 size_t size_impl() { return 0; }
24 template <typename Head
, typename
... Tail
>
25 size_t size_impl(const Head
& head
, const Tail
&... tail
) {
26 return head
.size() + size_impl(tail
...);
29 // Join a pack of std::strings using a delimiter
30 // TODO: use absl::StrJoin
31 void join_impl(std::string
&, char) {}
33 template <typename Head
, typename
... Tail
>
34 void join_impl(std::string
& s
, const char delimiter
, const Head
& head
,
35 const Tail
&... tail
) {
36 if (!s
.empty() && !head
.empty()) {
42 join_impl(s
, delimiter
, tail
...);
45 template <typename
... Ts
>
46 std::string
join(char delimiter
, const Ts
&... ts
) {
48 s
.reserve(sizeof...(Ts
) + size_impl(ts
...));
49 join_impl(s
, delimiter
, ts
...);
54 std::string
BenchmarkName::str() const {
55 return join('/', function_name
, args
, min_time
, iterations
, repetitions
,
58 } // namespace benchmark