Skip to content

Commit

Permalink
feat: made method virtual and get rid of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
varshneydevansh committed Aug 12, 2023
1 parent 73867c7 commit a41e9d6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
19 changes: 9 additions & 10 deletions include/benchmark/benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ class Counter {
Counter(double v = 0., Flags f = kDefaults, OneK k = kIs1000)
: value(v), flags(f), oneK(k) {}

BENCHMARK_ALWAYS_INLINE operator double const&() const { return value; }
BENCHMARK_ALWAYS_INLINE operator double const &() const { return value; }
BENCHMARK_ALWAYS_INLINE operator double&() { return value; }
};

Expand Down Expand Up @@ -712,11 +712,9 @@ enum Skipped
#if defined(BENCHMARK_HAS_CXX11)
: unsigned
#endif
{
NotSkipped = 0,
{ NotSkipped = 0,
SkippedWithMessage,
SkippedWithError
};
SkippedWithError };

} // namespace internal

Expand Down Expand Up @@ -1881,15 +1879,16 @@ class BENCHMARK_EXPORT BenchmarkReporter {
/**
* @brief Lists and describes the provided benchmarks.
*
* This static method is intended to be overridden by derived classes
* This virtual method is intended to be overridden by derived classes
* to provide specific implementations for listing benchmarks.
* It can be used for outputting, logging, or any other operation
* needed to handle or display the benchmarks' names and metadata.
*
* @param benchmarks A vector containing names and details of benchmarks
* that need to be listed or processed.
*/
static void List(const std::vector<internal::BenchmarkInstance>& benchmarks);
virtual void List(
const std::vector<internal::BenchmarkInstance>& benchmarks) = 0;

private:
std::ostream* output_stream_;
Expand All @@ -1912,7 +1911,7 @@ class BENCHMARK_EXPORT ConsoleReporter : public BenchmarkReporter {

bool ReportContext(const Context& context) BENCHMARK_OVERRIDE;
void ReportRuns(const std::vector<Run>& reports) BENCHMARK_OVERRIDE;
static void List(const std::vector<internal::BenchmarkInstance>& benchmarks);
void List(const std::vector<internal::BenchmarkInstance>& benchmarks);

protected:
virtual void PrintRunData(const Run& report);
Expand All @@ -1930,7 +1929,7 @@ class BENCHMARK_EXPORT JSONReporter : public BenchmarkReporter {
bool ReportContext(const Context& context) BENCHMARK_OVERRIDE;
void ReportRuns(const std::vector<Run>& reports) BENCHMARK_OVERRIDE;
void Finalize() BENCHMARK_OVERRIDE;
static void List(const std::vector<internal::BenchmarkInstance>& benchmarks);
void List(const std::vector<internal::BenchmarkInstance>& benchmarks);

private:
void PrintRunData(const Run& report);
Expand All @@ -1945,7 +1944,7 @@ class BENCHMARK_EXPORT BENCHMARK_DEPRECATED_MSG(
CSVReporter() : printed_header_(false) {}
bool ReportContext(const Context& context) BENCHMARK_OVERRIDE;
void ReportRuns(const std::vector<Run>& reports) BENCHMARK_OVERRIDE;
static void List(const std::vector<internal::BenchmarkInstance>& benchmarks);
void List(const std::vector<internal::BenchmarkInstance>& benchmarks);

private:
void PrintRunData(const Run& report);
Expand Down
8 changes: 4 additions & 4 deletions src/benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,10 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* display_reporter,

if (FLAGS_benchmark_list_tests) {
if (FLAGS_benchmark_format == "json") {
dynamic_cast<JSONReporter*>(display_reporter)->List(benchmarks);
} else {
//ConsoleReporter::List(benchmarks);
dynamic_cast<ConsoleReporter*>(display_reporter)->List(benchmarks);
display_reporter->List(benchmarks);
} else {
// ConsoleReporter::List(benchmarks);
display_reporter->List(benchmarks);
}
} else {
internal::RunBenchmarks(benchmarks, display_reporter, file_reporter);
Expand Down
2 changes: 1 addition & 1 deletion src/console_reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <tuple>
#include <vector>

#include "benchmark/benchmark.h"
#include "benchmark_api_internal.h"
#include "check.h"
#include "colorprint.h"
#include "commandlineflags.h"
Expand Down
2 changes: 1 addition & 1 deletion src/csv_reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <tuple>
#include <vector>

#include "benchmark/benchmark.h"
#include "benchmark_api_internal.h"
#include "check.h"
#include "complexity.h"
#include "string_util.h"
Expand Down
2 changes: 1 addition & 1 deletion src/json_reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <tuple>
#include <vector>

#include "benchmark/benchmark.h"
#include "benchmark_api_internal.h"
#include "complexity.h"
#include "string_util.h"
#include "timers.h"
Expand Down

0 comments on commit a41e9d6

Please sign in to comment.