Git Product home page Git Product logo

tools's Introduction

tools

CI codecov Language grade: C++

Some handy C++ tools

tools's People

Contributors

cblck avatar johelegp avatar lefticus avatar n-co avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tools's Issues

Simplified (?) static_views

I wonder whether the compiler would really "do the work twice" in a simplified version of static_views, like so: https://godbolt.org/z/GWzY34P3h

#include <fmt/core.h>

#include <algorithm>
#include <array>
#include <cstddef>
#include <string>

template <std::size_t Size>
constexpr auto to_array(const std::string& str)
{
    std::array<char, Size> result;
    std::copy(str.begin(), str.end(), result.begin());
    return result;
}

template <auto Data>
inline constexpr std::string_view STATIC_STRING_VIEW{Data.data(), Data.size()};

consteval auto to_string_view(const auto callable)
{
    return STATIC_STRING_VIEW<to_array<callable().size()>(callable())>;
}

int main()
{
    static constexpr auto TEST = to_string_view(
        []
        {
            return std::string{"test"};
        });
    fmt::print("{}", TEST);
}

simple_stack_vector bad range check

range check at at functions should probably be if (idx >= size_) instead of if (idx > size_)

https://github.com/lefticus/tools/blob/332c8f58a8311aa2b7771154b826c3275df83fd0/include/lefticus/tools/simple_stack_vector.hpp#L121C1-L131C4

  [[nodiscard]] constexpr value_type &at(const std::size_t idx)
  {
    if (idx > size_) { throw std::out_of_range("index past end of stack_vector"); }
    return data_[idx];
  }


  [[nodiscard]] constexpr const value_type &at(const std::size_t idx) const
  {
    if (idx > size_) { throw std::out_of_range("index past end of stack_vector"); }
    return data_[idx];
  }

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.