GithubHelp home page GithubHelp logo

georgyfirsov-s-forks / fixed_string Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unterumarmung/fixed_string

0.0 0.0 0.0 1.57 MB

C++17 string with fixed size

License: MIT License

CMake 5.27% C++ 92.24% Python 2.49%

fixed_string's Introduction

fixed_string

C++ library that provides a basic_fixed_string template that combines std::array fixed-size semantic and std::string semantic together

Features

  • C++17 or higher
  • Header-only
  • Dependency-free
  • No dynamic allocations
  • Fully constexpr
  • Can be used as class non-type template parameter (since C++20)

Examples

  • Construction
constexpr fixstr::fixed_string foo = "foo";
  • Concatenation
using namespace fixstr;
constexpr fixed_string first = "Hello, ";
constexpr fixed_string second = "World!";
constexpr auto result = first + second; // "Hello, World!"
  • Comparison
using namespace fixstr;
constexpr fixed_string first = "Hello, ";
constexpr fixed_string second = "World!";
static_assert(first == second); // false
static_assert(first != second); // true
static_assert(first < second);  // true
static_assert(first <= second); // true
static_assert(first > second);  // false 
static_assert(first >= second); // false
static_assert(first <=> second != 0); // true
  • Non-type template parameter
template <fixstr::fixed_string Foo>
void bar()
{
    static_assert(Foo == "foo"sv);
}

void foo()
{
    bar<"foo">();
}

Integration

Since it's a header only library, you need just copy fixed_string.hpp to your project.

If you are using vcpkg on your project for external dependencies, then you can use the fixed-string package.

If you are using Conan on your project for external dependencies, then you can use the Conan recipe located in the root of the repository.

Compiler compatibility

  • GCC >= 7.3
  • Clang >= 5
  • ICC >= 19.0.1
  • MSVC >= 14.28 / Visual Studio 2019 (I don't have access to older VS versions right now, so it can work on older versions too)

Using basic_fixed_string as class non-type template parameter full available in GCC >= 10 and VS 2019 16.9 or newer

fixed_string's People

Contributors

georgyfirsov avatar malibushko avatar unterumarmung 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.