Skip to content

Commit

Permalink
Fixed compilation in visual studio
Browse files Browse the repository at this point in the history
  • Loading branch information
MiSo1289 committed Apr 13, 2020
1 parent 5a82124 commit 0262239
Show file tree
Hide file tree
Showing 7 changed files with 923 additions and 715 deletions.
46 changes: 46 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
BasedOnStyle: WebKit
AccessModifierOffset: '-2'
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: 'false'
AlignConsecutiveDeclarations: 'false'
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowShortBlocksOnASingleLine: 'true'
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: 'true'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakTemplateDeclarations: 'Yes'
BreakBeforeBraces: Allman
BreakConstructorInitializersBeforeComma: 'true'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
ConstructorInitializerIndentWidth: '2'
ContinuationIndentWidth: '4'
ColumnLimit: 0
Cpp11BracedListStyle: 'true'
DerivePointerAlignment: 'false'
FixNamespaceComments: 'true'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
Language: Cpp
MaxEmptyLinesToKeep: '1'
NamespaceIndentation: All
PointerAlignment: Left
SortIncludes: 'true'
IncludeCategories:
- Regex: '^<.*>$'
Priority: 1
- Regex: '^".*"$'
Priority: 2
SpaceAfterCStyleCast: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: 'false'
SpacesBeforeTrailingComments: '2'
SpacesInAngles: 'false'
SpaceBeforeCpp11BracedList: false
UseTab: Never
BinPackArguments: 'false'
BinPackParameters: 'false'
ExperimentalAutoDetectBinPacking: 'false'
AllowAllParametersOfDeclarationOnNextLine: 'false'
...
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@
*.exe
*.out
*.app

CMakeSettings.json
.idea
out
build*
cmake-build*
.vs
29 changes: 29 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.13)
project(SboPtr VERSION 0.1)

enable_testing()

find_package(Catch2 CONFIG REQUIRED)

add_library(sboptr INTERFACE)
add_library(sboptr::sboptr ALIAS sboptr)

target_compile_features(sboptr INTERFACE cxx_std_17)
target_include_directories(sboptr INTERFACE include)
target_sources(sboptr INTERFACE include/sboptr/sboptr.hpp)

add_executable(sboptr_tests)
target_compile_definitions(sboptr_tests PRIVATE CATCH_CONFIG_MAIN)
target_sources(sboptr_tests PRIVATE tests/sboptr/sboptr_tests.cpp)
target_link_libraries(
sboptr_tests
PRIVATE
sboptr::sboptr
Catch2::Catch2
)

add_test(NAME sboptr_tests COMMAND sboptr_tests)

add_executable(sboptr_example)
target_sources(sboptr_example PRIVATE examples/example.cpp)
target_link_libraries(sboptr_example PRIVATE sboptr::sboptr)
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class SboPtr(ConanFile):
version = "0.1"
revision_mode = "scm"
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
generators = "cmake_paths"
exports_sources = (
"include/*",
"tests/*",
Expand Down
31 changes: 31 additions & 0 deletions examples/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <iostream>

#include "sboptr/sboptr.hpp"

namespace
{
class interface
{
public:
virtual ~interface() noexcept = default;

virtual void foo() = 0;
};

class impl : public interface
{
public:
void foo() override
{
std::cout << "Foo!\n";
}
};
} // namespace

auto main() -> int
{
auto ptr = sboptr::sbo_ptr<interface, sizeof(void*) * 4>{impl{}};
ptr->foo();

return 0;
}
Loading

0 comments on commit 0262239

Please sign in to comment.