Coder Social home page Coder Social logo

guillaumedua / gcl_cpp Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 1.0 12.03 MB

Makes my C++ projects easier and faster to develop

License: Apache License 2.0

C++ 99.53% CMake 0.47%
c-plus-plus cpp cpp17 cpp20 cpp20-library gcl-cpp cpp-library cpp17-library metaprogramming template-metaprogramming

gcl_cpp's Introduction

GCL C++

Ubuntu CMake Clang latest Ubuntu CMake GCC 10 MSBuild-Windows-CL_latest Windows CMake ClangCL

๐Ÿšง WIP : see milestone v1 -> v2


This modern-C++, header-only library is a stack of useful and convinient components that make my everyday projects & jobs way easier.

Each component (spli by namespaces) aims to be :

  • easy-to-use
  • easy-to-maintain
  • powerful

NB : This library is a never-ending WIP, as it matches needs according to the C++ standards and compilers implementations.
Thus, many components only exists to fill what I consider to be STL holes, and so are likely to disappear when standard features are implemented -and released- in the standard and by compilers.

Build

This library is header-only, meaning you only need to add includes/gcl to your include path.

However, a CMake target exposes an gcl_cpp INTERFACE library target that you can integrate into your build.

Currently, the only available option is gcl_cpp_BUILD_TEST - which is set to OFF by default - that generates a binary to run runtime tests.

Tests

As this library components are mainly template-metaprogramming or constexpr ones, most of the tests are processed at compile-time.

Currently, there is no option to disable compile-time tests.
If you need such option, create a Github issue, or make a pull-request.

As mentioned in the previous section, a CMake target can be generate, when enabling the gcl_cpp_BUILD_TEST option.
However, it only cover runtime tests.

Versions

Name Description
v2 WIP/refactoring to only use C++17/2a/20 implementations
v1 Legacy tag that still exists for projects that depends on, but is no longer maintained
Offers C++11/14/17 implementations in gcl namespace
as well as C++98/03 implementations in gcl::deprecated namespace

Features

table-of-content

component name description
mp meta-programming elements to provide computation at compile-time
cx constexpr elements
ctc compile-time constants.
mainly provides algorithms to manipulate std::array and std::tuple at compile-time
io io manipulation, mainly for serialization
container containers
pattern mid-level design patterns, such as ECS
algorithms some algorithms
functional function-related elements
concepts concepts definition. Note that most concepts are defined within components they are related to.
For instance, gcl::mp::concepts and gcl::io::concepts

Compilers support

This library aims to compile using the following compilers :

  • GCC
  • Clang
  • MsVC-CL
  • MS Clang-CL

If at some point, a compiler does not support a specific feature, this information will be register as a limitation in-code comment
Also, a warning will be generated at compile-time accordingly.

  • Example : Clang 11.0.0 does not implement "Lambdas in unevaluated contexts" (P0315R4)

Currently known limitations

Clang / Clang-CL

File Element Description
gcl/mp/pack_traits.hpp gcl::mp::type_traits::index_of<T, Ts...> uses an alternative implementation that use recursion, in opposition to other compilers
gcl/mp/pack_traits.hpp gcl::mp::pack_traits<...>::index_of_v
gcl::mp::pack_traits<...>::first_index_of_v
gcl::mp::pack_traits<...>::last_index_of_v
Known limitation of Clang 12.0.0
Invalid operands to binary expression ('const auto' and 'int')

Clang-CL

File Element Description
gcl/cx/array.hpp gcl::cx::array::remove_duplicates_v<datas> a non-type template parameter cannot have type 'std::array<T, N>'

GCC

None.

MsVC-CL

None.

STL implementations support

libstdc++

None.

libc++

Broken on release prior to 13 (requires concepts implementations)

About the name

GCL stands for Guss's Common Library

gcl_cpp's People

Contributors

guillaumedua avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gcl_cpp's Issues

[gcl::v2] Refactor tests

[gcl::v2] Refactor tests

  • Add CMake / preprocessor directive to enable/disable tests
  • compile-time tests
  • runtime tests

EventControlCenter

  • Use GCL::Experimental::Pattern::ControlCenter
  • Modules chain sequence : Log, Stats, Recovery
  • Subscription map
  • Event : static const std::string description.
  • Event : Serializable.
  • Event : Can be transfered to core, thread, socket

[BUG] Clang-CL support

** Component name **

See https://developercommunity.visualstudio.com/t/msvc-clang-cl-stl-issue-error-use-of-undeclared-id/1392703

Context

  • OS : Windows 10
  • Compiler name + release : Clang-CL, latest
  • Runtime or compile-time issue ?
    • Compile time issue
    • Runtime issue
  • Project build / generation
    • CMake
    • MSVC
    • Direct include gcl/includes (git submodule, CMake FetchContent/ExternalProject_Add, etc.)

Describe the bug

>------ Build All started: Project: GCL_CPP, Configuration: x64-Clang-Debug ------
  [1/2] Building CXX object tests\CMakeFiles\gcl_test_binary.dir\Main.cpp.obj
  FAILED: tests/CMakeFiles/gcl_test_binary.dir/Main.cpp.obj 
  C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\Llvm\x64\bin\clang-cl.exe  /nologo -TP  -I..\..\..\includes -m64 -fdiagnostics-absolute-paths  /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 -std:c++latest /showIncludes /Fotests\CMakeFiles\gcl_test_binary.dir\Main.cpp.obj /Fdtests\CMakeFiles\gcl_test_binary.dir\ -c -- ..\..\..\tests\Main.cpp
  In file included from ..\..\..\tests\Main.cpp:19:
  In file included from ..\..\..\includes\gcl/mp/pack_traits.hpp:3:
  In file included from ..\..\..\includes\gcl/mp/type_traits.hpp:61:
  In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\bitset:11:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\iosfwd(109,39): error : use of undeclared identifier 'is_integral_v'
      template <class _Int, enable_if_t<is_integral_v<_Int>, int> = 0>
                                        ^
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\iosfwd(114,39): error : use of undeclared identifier 'is_integral_v'
      template <class _Int, enable_if_t<is_integral_v<_Int>, int> = 0>
                                        ^
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\iosfwd(123,39): error : use of undeclared identifier 'is_integral_v'
      template <class _Int, enable_if_t<is_integral_v<_Int>, int> = 0>
                                        ^
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\iosfwd(128,39): error : use of undeclared identifier 'is_integral_v'
      template <class _Int, enable_if_t<is_integral_v<_Int>, int> = 0>
                                        ^

To Reproduce

#include <gcl/mp/function_traits.hpp>
#include <gcl/mp/pack_traits.hpp>
int main(void)
{
    return 0;
}

Expected behavior

Should compile,
or get stuck to another Clang/Clang-CL related error cannot mangle std::tuple<auto>

Additional context

See https://developercommunity.visualstudio.com/t/msvc-clang-cl-stl-issue-error-use-of-undeclared-id/1392703

gcl::event

gcl::event

Static direct dispatch

todo : synthax here
(SFINAE/detection-idiom || concept) + CRTP + std::visit + overloaded pattern

Entity

Serialization : _id
Garbage collector that do not modify the ID.
Events : Actions

[REQUEST] Automate runtime tests into the CI

Scope

  • C++
    • New gcl component
    • New language standard support
  • CMake
  • CI
  • Configuration support
    • Compiler support
    • OS support
    • Architecture support
  • Documentation

Description

Automate - runtime - tests into the CI

Examples :

  • CMake
    • Test library dependency (Gtest, Catch2, ... ?)
    • Test target ?

Details

Even if the GCL tests are mostly compile-time runned, the CI should run the few runtime-tests to ensure that runtime components are correct

[REQUEST] gcl::[tbd]::trie

Scope

  • C++
    • New gcl component
    • New language standard support
  • CMake
  • CI
  • Configuration support
    • Compiler support
    • OS support
    • Architecture support
  • Documentation

Description

See wiki/Trie

I suggest 3 implementations, based on usage.

  • gcl::containers::sequence_tree for runtime usage
  • gcl::cx::sequence_tree for consteval initialization and runtime usage
  • gcl::mp::sequence_tree for compile-time usage

Q : Also, consider using ctc namespace instead of cx ?

Usage scenarios :

  • Easily store complete language dictionaries, in order to assert if a given word exists.
  • [optional] Permissively search for existing sequence (see error-permissive search algorithms)

Summary :

  • A sequence tree is an asymmetric tree that maps values using a minimal amount of memory space,
    in a way that each node represents an element of a sequence.

The interface is the following :

  • Create a tree using given multiples sequence values
  • [optional?] Add a new sequence value into an existing tree
  • Search for an existing value

Sequences can be char sequences, so each

Details

CI / automation

CI / automation

CI checks :

Build :

  • Ms build
  • Ms Clang-cl build
  • gcc build
  • clang build

todo : extends to other configurations mentioned in #31

Code quality

  • CppCoreGuideline static checks

Runtime tests

  • run rt tests

Integrates CI tools such as static-analysis and format to this repository.

Must includes Cpp Core Guideline checks using SonarCube ou LLVM/Clang-tidy

Refactor README.md for V2

Refactor README.md for V2

  • Add CI checks (status badge)
  • Refactor available components (remove deprecated/stale)
  • Add demo for each top-level/macro component
  • Add compiler supports infos + matrix

[REQUEST] gcl::io::serialization : error_handling_policy

Scope

  • C++
    • New gcl component
    • New language standard support
  • CMake
  • CI
  • Configuration support
    • Compiler support
    • OS support
    • Architecture support
  • Documentation

Description

Merge POC with error_handling_policy :

  • throw_exception
  • callback
  • skip_unknown / do_nothing

Also, check why this was not merge before.

[gcl::io::serialization] : new interface+impl

gcl::serialization

Motivation synthax

The aimed synthax should be closed to :

std::stringstream ss;
using namespace gcl::serialization;

serializer{ss}.serialize(42, 'a', true);
deserializer{gcl::functional::overload{
    [](int i) { std::cout << "int : " << i << '\n'; },
    [](auto arg) { std::cout << "other : " arg << '\n'; }
}}.deserialize_all(ss);

Expected output :

int : 42
other : a
other : true

Problematic

Type identifier - thus dynamic value - mapping to type

Proposal 1 :

Deserialization types are extracted from functors arguments

std::stringstream ss;
using namespace gcl::serialization;

serializer{ss}.serialize(42, 'a', true);
deserializer{gcl::functional::overload{
    [](int i) { std::cout << "int : " << i << '\n'; },
    [](char c) { std::cout << "char : " << c << '\n'; },
    [](bool b) { std::cout << "bool : " << b << '\n'; },
    [](float f) { std::cout << "float : " << f << '\n'; },
}}.deserialize_all(ss);

Proposal 2 :

Deserialization types are template parameters

std::stringstream ss;
using namespace gcl::serialization;

serializer{ss}.serialize(42, 'a', true);
deserializer<int, char, bool, float>{gcl::functional::overload{
    [](int i) { std::cout << "int : " << i << '\n'; },
    [](auto arg) { std::cout << "other : " arg << '\n'; }
}}.deserialize(ss);

Proposal 3 :

Deserialization types are std::variants

using namespace gcl::serialization;

using event_type = std::variant<event_1, event_2, event_3>;
using user_input  = std::variant<key_stroke, mouse_click, mouse_move, pad_button_pressed>
using entity_type = std::variant<entity_1, entity_2, entity_3>;

std::stringstream ss;
serializer{ss}.serialize
(
    entity_1{},
    mouse_click{},
    entity_3{}
);

deserializer<event_type, user_input, entity_type>{gcl::functional::overload{
    [](event_1 ev) {  }, // only a type
    [](user_input input) {}, // type pack
    [](auto arg) {  } // every other types : handle event_2, event_3, and entity_type 
}}.deserialize(ss);

Proposal 4 :

Hidden Y-shaped inheritance adapter ?

Add CMake support

Relies on CMake instead (or beside) MsVS

Use MsVS remote plateform to work on :

  • WSL containers
  • local/remote Docker containers (based on latest GCC, LLVM and CMake Docker images)
  • Local MsVS compilers : CL and MsClang

[REQUEST] gcl::cx::type_name_v : formatter

Scope

  • C++

Description

C++ : gcl::cx::type_name_v with pretty print that indent types

  • Can be a formatter (fmt and/or std::formatter) of a user-defined type with implicit std::string_view (to) conversion
  • break before/after < and >
  • add indentation levels

Details

Current behavior :

const csl::wf::details::overload<csl::wf::details::overload<csl::wf::details::overload<main()::<lambda(int)>, main()::<lambda(char)> >, csl::wf::details::overload<main()::<lambda(double)>, main()::<lambda(float)> > >, main()::<lambda(bool)> >

Expected output :

const csl::wf::details::overload<
   csl::wf::details::overload<
      csl::wf::details::overload<
          main()::<lambda(int)>,
          main()::<lambda(char)>
       >, 
       csl::wf::details::overload<
           main()::<lambda(double)>,
           main()::<lambda(float)>
       >
     >,
     main()::<lambda(bool)>
>

Recovery

Using GCL, seriailiazation module on events pushed to EventControlCenter

[gcl::mp::reflection] Aggregate to std::tuple

Aggregate to std::tuple

Motivation synthaxes :

struct smthg
{
   int i;
   char * c_ptr;
   double d;
};
using smthg_fields = gcl::tmp::as_tuple_t<smthg>;
smthg value;
auto fields_as_tuple_ref = gcl::tmp::fields_as_tuple_ref(value);
std::get<int>(fields_as_tuple_ref) = 42;
template<class Tuple, std::size_t... Is>
void print_impl(std::ostream & os,
                      const Tuple& t,
                      std::index_sequence<Is...>)
{
    os << gcl::typeinfo::type_name<> << "\n{\n";
    ((os << gcl::typeinfo::type_name<decltype(std::get<Is>(t)) << '\n'), ...);
    os << "}\n";
}

Expected output :

smthg
{
   int
   char*
   double
}

[REQUEST] CMake option to enable/disable compile-time tests

Scope

  • C++
    • New gcl component
    • New language standard support
  • CMake
  • CI
  • Configuration support
    • Compiler support
    • OS support
    • Architecture support
  • Documentation

Description

Part of #24

In order to decrease compilation time of external project that DEPENDS ON gcl,
create a CMake option to enable/disable compile-time tests

The CI MUST keep testing at compile-time.

Details

CMake option like GCL_ENABLE_COMPILE_TIME_TESTS:BOOL

[optional] Expected behavior

  • By default, compilation should not trigger compile-time tests but only critical static_asserts.

[gcl::v2] Refactor documentation

Refactor documentation

  • Top-level README.md
  • Components dependency tree
  • Per macro-components README.md
    • mp
    • cx
    • ctc
    • io
    • container
    • pattern
    • algorithms
    • functional
    • concepts

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.