-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
4,027 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#ifndef SFL_BENCHMARK_COMMON_HPP | ||
#define SFL_BENCHMARK_COMMON_HPP | ||
|
||
#include <string_view> | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
template <typename T> | ||
constexpr std::string_view name_of_type_raw() | ||
{ | ||
#if defined(_MSC_VER) | ||
return __FUNCSIG__; | ||
#else | ||
return __PRETTY_FUNCTION__; | ||
#endif | ||
} | ||
|
||
template <typename T> | ||
constexpr std::string_view name_of_type() | ||
{ | ||
using namespace std::literals; | ||
|
||
// idea from https://github.com/TheLartians/StaticTypeInfo/blob/master/include/static_type_info/type_name.h | ||
auto for_double = name_of_type_raw<double>(); | ||
auto n_before = for_double.find("double"sv); | ||
auto n_after = for_double.size() - (n_before + "double"sv.size()); | ||
|
||
auto str = name_of_type_raw<T>(); | ||
str.remove_prefix(n_before); | ||
str.remove_suffix(n_after); | ||
return str; | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
template <typename Container, typename = void> | ||
struct has_emplace_front : std::false_type {}; | ||
|
||
template <typename Container> | ||
struct has_emplace_front | ||
< | ||
Container, | ||
std::void_t<decltype(std::declval<Container>().emplace_front())> | ||
> : std::true_type {}; | ||
|
||
template <typename Container> | ||
inline constexpr bool has_emplace_front_v = has_emplace_front<Container>::value; | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
#endif // SFL_BENCHMARK_COMMON_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# | ||
# This is GNU makefile for Linux OS and GCC/Clang compiler | ||
# | ||
|
||
# C++ compiler | ||
CXX = clang++ | ||
|
||
# C++ compiler flags | ||
CXXFLAGS = -std=c++20 -Wall -Wextra -Wfatal-errors -I ../include -DNDEBUG -O3 | ||
|
||
# Command for removing all files and directories | ||
RM_RF = rm -rf | ||
|
||
# List of all source files that must be compiled and tested | ||
SRCS := $(wildcard *.cpp) | ||
|
||
# First rule | ||
.PHONY: all | ||
all: | ||
|
||
# This function generates build rule for given source file. | ||
# Usage: $(call generate_rules,source_file) | ||
define generate_rules | ||
|
||
.PHONY: $(basename $(1)) | ||
all: $(basename $(1)) | ||
$(basename $(1)): | ||
$(CXX) $(CXXFLAGS) $(1) -o $(basename $(1)).out | ||
|
||
endef | ||
|
||
# Generate rules for all source files | ||
$(foreach file,$(SRCS),$(eval $(call generate_rules,$(file)))) | ||
|
||
.PHONY: clean | ||
clean: | ||
$(RM_RF) *.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# | ||
# This is GNU makefile for Windows OS and Visual C++ compiler | ||
# | ||
|
||
# Default shell used by GNU Make on Windows | ||
SHELL = cmd | ||
|
||
# C++ compiler | ||
CXX = cl | ||
|
||
# C++ compiler flags | ||
CXXFLAGS = /std:c++20 /nologo /EHsc /W4 /WX /I ..\include /O2 | ||
|
||
# Command for removing all files and directories | ||
RM_RF = del /f /s /q | ||
|
||
# List of all source files that must be compiled and tested | ||
SRCS := $(wildcard *.cpp) | ||
|
||
# First rule | ||
.PHONY: all | ||
all: | ||
|
||
# This function generates build rule for given source file. | ||
# Usage: $(call generate_rules,source_file) | ||
define generate_rules | ||
|
||
.PHONY: $(basename $(1)) | ||
all: $(basename $(1)) | ||
$(basename $(1)): | ||
$(CXX) $(CXXFLAGS) $(1) | ||
|
||
endef | ||
|
||
# Generate rules for all source files | ||
$(foreach file,$(SRCS),$(eval $(call generate_rules,$(file)))) | ||
|
||
.PHONY: clean | ||
clean: | ||
$(RM_RF) *.exe | ||
$(RM_RF) *.ilk | ||
$(RM_RF) *.obj | ||
$(RM_RF) *.pdb |
Oops, something went wrong.