Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
9d8fe60
chore: Add EnumBase for base of specialization with test
cwahn Jan 30, 2024
7795209
chore: Implement copy constructor for Enum with test
cwahn Jan 30, 2024
46a0a93
feat: Implement move constructor for Enum with test
cwahn Jan 30, 2024
def0b38
feat: Implement ca, ma, destructor for Enum with test
cwahn Jan 30, 2024
320d5e5
feat: Implement equality operator of Enum with test
cwahn Jan 30, 2024
3a8b109
chore: Typo
cwahn Jan 30, 2024
caf029e
chore: Make sequences to throw runtime_error instead of abort with test
cwahn Jan 30, 2024
29cb016
refactor: Make Enum to be default constructable if the first element …
cwahn Jan 30, 2024
5fb89c2
chore Use placement new for cyclic data types with test
cwahn Jan 30, 2024
759d22e
chore Use placement new for cyclic data types with test
cwahn Jan 30, 2024
2ee1a28
chore Use placement new for cyclic data types with test
cwahn Jan 30, 2024
920691a
fix: Fix omitted index on CA and MA
cwahn Jan 31, 2024
041e5f4
test: Add rule of 5 tests for Enum
cwahn Jan 31, 2024
494e37b
perf: Use custom storage instead of c-style array to avoid redundant …
cwahn Jan 31, 2024
3a039dd
fix: Fix push back of Vcq
cwahn Jan 31, 2024
a318b70
test: Add rule of 5 test cases for Vcq
cwahn Jan 31, 2024
dc7793e
fix: Fix Vcq memory management with test
cwahn Jan 31, 2024
394cf6c
chore: Remove _middles as they are not changing
cwahn Jan 31, 2024
fdabf30
chore: Remove clutters
cwahn Jan 31, 2024
e6742b5
build: Change directory structure
cwahn Jan 31, 2024
df04a5c
build: Change build structure
cwahn Jan 31, 2024
d17840f
chore: Change clang-format
cwahn Jan 31, 2024
d00257c
perf: Use RawStorage for Array with test
cwahn Feb 1, 2024
b6a4852
perf: Apply RawStorage to ArrVec with test
cwahn Feb 1, 2024
c609425
chore: Add rule of five tests for ArrVec
cwahn Feb 1, 2024
17a7c27
test: Add rule of five tests for Vector
cwahn Feb 1, 2024
95c1212
chore: Change to use String instead of std::string
cwahn Feb 1, 2024
17f5f1a
refactor: Now String is inheriting detail::VectorBase
cwahn Feb 1, 2024
10bf43a
refactor: Make String to inherit from detail::VectorBase<char>
cwahn Feb 1, 2024
1fbeb64
chore: Change clang-format
cwahn Feb 1, 2024
64f2227
chore: Remove clutter
cwahn Feb 1, 2024
bdb5a2e
chore: Add make test and example directories are only included only i…
cwahn Feb 10, 2024
2b035ae
chore: Add freestanding headers per ISO standard
cwahn Feb 15, 2024
dc07a27
refactor: Use std::integral_constant
cwahn Feb 15, 2024
8644a7b
reafactor: Use std::integral_constant with test
cwahn Feb 15, 2024
56209ea
refactor: Rename to IntegralConst to CtConst
cwahn Feb 15, 2024
290c69c
refactor: Rename to IntegralConst to CtConst with test
cwahn Feb 15, 2024
4e8f2e5
perf: Use std::enable_if
cwahn Feb 15, 2024
4e1280b
perf: Use std::conditional
cwahn Feb 15, 2024
fbec993
refactor: Change operator functions name with test
cwahn Feb 15, 2024
084f993
refactor: Rename operators with test
cwahn Feb 15, 2024
c4952fb
reafactor: Rename compile time operators with underscore with test
cwahn Feb 15, 2024
e4934c0
perf: Use IsSame
cwahn Feb 15, 2024
e7227f2
perf: Make foldl_ to use loop if C++ > 17 with test
cwahn Feb 15, 2024
4ce814c
perf: Use reference removed with test
cwahn Feb 15, 2024
2c8ce8d
refactor: Change qualifier related names with test
cwahn Feb 15, 2024
73094f6
chore: Remove clutters with test
cwahn Feb 15, 2024
fa46479
chore: Remove clutters with test
cwahn Feb 15, 2024
f5553e5
refacor: Change signature of operators
cwahn Feb 15, 2024
e62d5fc
refactor: Make arithmatic operator to take sigle type parameter
cwahn Feb 16, 2024
e4a9580
chore: Use efp::move instead of std::move with test
cwahn Feb 16, 2024
4fa1d0b
chore: Use type hinting
cwahn Feb 16, 2024
a4fa9ab
chore: Use constexpr for some meta functions
cwahn Feb 16, 2024
1412d96
chore: Add some static asserts to prelude
cwahn Feb 16, 2024
83d2eb2
chore: Remove std from std::size_t
cwahn Feb 16, 2024
746683f
chore: Move some numeric functions to hosted only with test
cwahn Feb 16, 2024
47898ae
chore: Remove clutters from the cyclic
cwahn Feb 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
209 changes: 149 additions & 60 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,95 +1,184 @@
Language: Cpp
BasedOnStyle: LLVM
# Language: Cpp
# BasedOnStyle: LLVM

AccessModifierOffset: -4
AlignAfterOpenBracket: Align
# AccessModifierOffset: -4
# AlignAfterOpenBracket: AlwaysBreak
# AlignConsecutiveAssignments: false
# AlignConsecutiveDeclarations: false
# AlignEscapedNewlines: Left
# AlignOperands: false
# AlignTrailingComments: true
# AllowAllParametersOfDeclarationOnNextLine: true
# AllowShortBlocksOnASingleLine: false
# AllowShortCaseLabelsOnASingleLine: false
# AllowShortFunctionsOnASingleLine: None
# AllowShortIfStatementsOnASingleLine: false
# AllowShortLoopsOnASingleLine: false
# AlwaysBreakAfterReturnType: None
# AlwaysBreakBeforeMultilineStrings: true
# AlwaysBreakTemplateDeclarations: true
# BinPackArguments: false
# BinPackParameters: false
# BreakBeforeBinaryOperators: All
# BreakBeforeBraces: Attach
# BraceWrapping:
# AfterClass: true
# AfterControlStatement: true
# AfterEnum: true
# AfterFunction: true
# AfterNamespace: true
# AfterStruct: true
# AfterUnion: true
# AfterExternBlock: true
# BeforeCatch: true
# BeforeElse: true
# IndentBraces: false
# BreakBeforeTernaryOperators: true
# BreakConstructorInitializersBeforeComma: false
# ColumnLimit: 100
# CommentPragmas: "^ IWYU pragma:"
# ConstructorInitializerAllOnOneLineOrOnePerLine: false
# ConstructorInitializerIndentWidth: 4
# ContinuationIndentWidth: 4
# Cpp11BracedListStyle: true
# DerivePointerAlignment: false
# ExperimentalAutoDetectBinPacking: false
# FixNamespaceComments: true
# ForEachMacros:
# - foreach
# - Q_FOREACH
# - BOOST_FOREACH
# IncludeBlocks: Preserve
# IncludeCategories:
# - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
# Priority: 2
# - Regex: '^(<|"(gtest|isl|json)/)'
# Priority: 3
# - Regex: ".*"
# Priority: 1
# IndentCaseLabels: true
# IndentWidth: 4
# IndentWrappedFunctionNames: false
# KeepEmptyLinesAtTheStartOfBlocks: true
# MacroBlockBegin: ""
# MacroBlockEnd: ""
# MaxEmptyLinesToKeep: 1
# NamespaceIndentation: Inner
# ObjCBlockIndentWidth: 2
# ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: true
# PenaltyBreakBeforeFirstCallParameter: 19
# PenaltyBreakComment: 300
# PenaltyBreakFirstLessLess: 80
# PenaltyBreakString: 1000
# PenaltyExcessCharacter: 1000000
# PenaltyReturnTypeOnItsOwnLine: 10
# PointerAlignment: Left
# ReflowComments: true
# SortIncludes: false
# SpaceAfterCStyleCast: false
# SpaceAfterTemplateKeyword: true
# SpaceBeforeAssignmentOperators: true
# SpaceBeforeCpp11BracedList: false
# SpaceBeforeCtorInitializerColon: true
# SpaceBeforeInheritanceColon: true
# SpaceBeforeParens: ControlStatements
# SpaceBeforeRangeBasedForLoopColon: true
# SpaceInEmptyParentheses: false
# SpacesBeforeTrailingComments: 1
# SpacesInAngles: false
# SpacesInContainerLiterals: true
# SpacesInCStyleCastParentheses: false
# SpacesInParentheses: false
# SpacesInSquareBrackets: false
# Standard: Cpp11
# TabWidth: 4
# UseTab: Never

AccessModifierOffset: -2
AlignAfterOpenBracket: BlockIndent # New in v14. For earlier clang-format versions, use AlwaysBreak instead.
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignEscapedNewlines: DontAlign
AlignOperands: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Attach
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 0
CommentPragmas: "^ IWYU pragma:"
ConstructorInitializerAllOnOneLineOrOnePerLine: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: AfterColon
BreakStringLiterals: false
ColumnLimit: 100
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: ".*"
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*\.h>'
Priority: 1
IndentCaseLabels: false
SortPriority: 0
CaseSensitive: false
- Regex: "^<.*"
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: ".*"
Priority: 3
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: "([-_](test|unittest))?$"
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ""
MacroBlockEnd: ""
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
ReferenceAlignment: Left # New in v13. int &name ==> int& name
ReflowComments: false
SeparateDefinitionBlocks: Always # New in v14.
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeInheritanceColon: false
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
TabWidth: 4
UseTab: Never
27 changes: 12 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,20 @@ if(MSVC)
endif()
endif()

include(CTest)

find_package(Catch2 QUIET)
if(NOT Catch2_FOUND)
# message("Catch2 not found on the system.\nBuild from source.")
FetchContent_Declare(
Catch2
URL https://github.com/catchorg/Catch2/archive/refs/tags/v3.4.0.tar.gz
URL_HASH MD5=2c802a4938ed842e2942c60d1d231bb7
)
FetchContent_MakeAvailable(Catch2)
endif()
option(ENABLE_ASAN "Enable AddressSanitizer" OFF)

include(Catch)
enable_testing()
if(ENABLE_ASAN)
# Add the -fsanitize=address flag to the compiler and linker
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()

add_library(efp INTERFACE)
target_include_directories(efp INTERFACE "./include")

add_subdirectory("./test")

# Check if this CMakeLists.txt is the top-most CMake project
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_subdirectory("./example")
add_subdirectory("./test")
endif()
24 changes: 24 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
add_executable(demo demo.cpp)
target_link_libraries(demo
PRIVATE
efp)

add_executable(loop_c loop_c.cpp)
target_link_libraries(loop_c
PRIVATE
efp)

add_executable(loop_efp loop_efp.cpp)
target_link_libraries(loop_efp
PRIVATE
efp)

add_executable(io_demo io_demo.cpp)
target_link_libraries(io_demo
PRIVATE
efp)

# add_executable(format_demo format_demo.cpp)
# target_link_libraries(format_demo
# PRIVATE
# efp)
2 changes: 1 addition & 1 deletion test/demo.cpp → example/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ int main() {

auto stdout = [&](int x) { std::cout << x << " "; };

auto as = from_function(IntegralConst<int, 10>{}, id<int>);
auto as = from_function(CtConst<int, 10>{}, id<int>);

auto minus_square = compose(negate, square<int>);

Expand Down
File renamed without changes.
42 changes: 14 additions & 28 deletions test/io_demo.cpp → example/io_demo.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "io.hpp"
#include <iostream>
#include <string>
#include <vector>
#include "efp/cpp_core.hpp"
#include "efp/io.hpp"

using namespace efp;

Expand All @@ -11,24 +9,18 @@ int main() {
String test_data_string = test_data;

auto maybe_file = File::open(path, "w+");
if (!maybe_file) {
std::cerr << "Failed to open file for writing." << std::endl;
return 1;
}
if (!maybe_file)
throw std::runtime_error("Failed to open file for writing.");

File file = maybe_file.move();

if (!file.write(test_data)) {
std::cerr << "Failed to write char* data to file." << std::endl;
return 1;
}
if (!file.write(test_data))
throw std::runtime_error("Failed to write char* data to file.");

file.flush();

if (!file.seek(0)) {
std::cerr << "Failed to seek to the beginning of the file." << std::endl;
return 1;
}
if (!file.seek(0))
throw std::runtime_error("Failed to seek to the beginning of the file.");

auto lines = file.read_lines();
for (const auto& line : lines) {
Expand All @@ -38,16 +30,12 @@ int main() {
long position = file.tell();
std::cout << "Current file position: " << position << std::endl;

if (!file.write(test_data_string)) {
std::cerr << "Failed to write String data to file." << std::endl;
return 1;
}
if (!file.write(test_data_string))
throw std::runtime_error("Failed to write String data to file.");

maybe_file = File::open(path, "r");
if (!maybe_file) {
std::cerr << "Failed to reopen file for reading." << std::endl;
return 1;
}
if (!maybe_file)
throw std::runtime_error("Failed to reopen file for reading.");

file = maybe_file.move();

Expand All @@ -57,10 +45,8 @@ int main() {
std::cout << line << std::endl;
}

if (!file.close()) {
std::cerr << "Failed to close the file." << std::endl;
return 1;
}
if (!file.close())
throw std::runtime_error("Failed to close the file.");

// file = File::open("test", "w+").move();
// file.write("Hello, world!\nThis is a test file.\nEnd of test.");
Expand Down
File renamed without changes.
File renamed without changes.
Loading