Git Product home page Git Product logo

sleip's Introduction

Dynamic Array

sleip::dynamic_array is An AllocatorAwareContainer that represents a dynamically-allocated fixed-size buffer. It is a combination of the constructors for std::vector with the member functions from std::array.

Unlike many containers in the STL, sleip::dynamic_array supports array objects and has a noinit constructor overload that enables default initialization of its underlying elements.

The dynamic_array is useful wherever a user may need a managed dynamic allocation where they won't need resizing or push_back-like functionality. Because it supports Allocators and can default-initialize its elements, dynamic_array is suitable for performance-oriented applications.

Example

#include <sleip/dynamic_array.hpp>

auto buff = sleip::dynamic_array<char>(480 * 640 * 3, sleip::noinit);
auto file = std::fstream("file.dat", std::ios::in | std::ios::binary);
file.read(buff.data(), buff.size());

Using

Via vcpkg

dynamic_array is available as a vcpkg package from the port directory here.

# navigate to the vcpkg root on your system
cd ~/vcpkg

git clone https://github.com/LeonineKing1199/sleip-port.git
./vcpkg install sleip --overlay-ports=sleip-port

# The package sleip:x64-linux provides CMake targets:
#
#     find_package(sleip 1.0.0 CONFIG REQUIRED)
#     target_link_libraries(main PRIVATE Sleip::dynamic_array)

Via CMake Install

dynamic_array supports installation with CMake.

cd ~
git clone https://github.com/LeonineKing1199/sleip.git
cd sleip
mkdir build
cd build
cmake \
  -DBoost_DIR=/home/exbigboss/boosts/71/lib/cmake/Boost-1.71.0 \
  -DBUILD_TESTING=OFF \
  -DCMAKE_INSTALL_PREFIX=../install \
  ..
cmake --install .

tree ../install/
# ../install/
# ├── include
# │   └── sleip-1.0.0
# │       └── sleip
# │           ├── dynamic_array.hpp
# │           └── dynamic_array_fwd.hpp
# └── lib
#     └── cmake
#         └── sleip-1.0.0
#             ├── sleip-config-version.cmake
#             ├── sleip-config.cmake
#             └── sleip-targets.cmake

Now find_package(Sleip 1.0.0) will work when the sleip_DIR is set to: <INSTALL_PREFIX>/lib/cmake/sleip-1.0.0.

Using our above example:

cmake -Dsleip_DIR=~/sleip/install/lib/cmake/sleip-1.0.0 ..

The following will now work in CMake:

find_package(sleip 1.0.0 CONFIG REQUIRED)
target_link_libraries(main PRIVATE Sleip::dynamic_array)

Via CMake add_subdirectory

dynamic_array can be used directly as a CMake sub-project.

cd ~/project
git clone https://github.com/LeonineKing1199/sleip.git

Then in your project's CMakeLists.txt,

cmake_minimum_required(VERSION 3.13)

project(sleip-test LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(SLEIP_ADD_SUBDIRECTORY ON CACHE BOOL "")

add_subdirectory(sleip)
add_executable(test main.cpp)

target_link_libraries(test PRIVATE Sleip::dynamic_array)

By default, this will build the tests for dynamic_array alongside the consuming project's.

sleip's People

Contributors

cmazakas avatar k-ballo avatar

Watchers

 avatar

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.