Giter Site home page Giter Site logo

justasmasiulis / circular_buffer Goto Github PK

View Code? Open in Web Editor NEW
65.0 6.0 15.0 53 KB

A constexpr STL style circular buffer implementation

License: Apache License 2.0

C++ 95.96% CMake 4.04%
buffer circular-buffer ring-buffer constexpr stl modern cpp

circular_buffer's Issues

Exception when using user defined class with stl containers as attribute

May suggest a test that fails?
Insert a vector as an attribute

struct leak_checker {

leak_checker() { ++num_constructions; }

~leak_checker() { ++num_deletions; }

leak_checker(const leak_checker&) { ++num_constructions; }

leak_checker(leak_checker&&) { ++num_constructions; }

leak_checker& operator=(const leak_checker&) = default;
leak_checker& operator=(leak_checker&&) = default;

std::vector<float> numbers;

};

Create buffer from user defined class

I couldn't use your circular_buffer with any of my defined types. For instance, none of the classes defined here https://en.cppreference.com/w/cpp/language/rule_of_three
I am using msvc 2017 and it throws an error nad a warning:

  • warning C4624: 'jm::circular_buffer<my_type,3>': destructor was implicitly defined as deleted
  • 'jm::circular_buffer<my_type,3>::~circular_buffer(void)': attempting to reference a deleted function

Thanks

How to extract the numbers in a specific position gracefully?

Thank you very much for your project.

circular_buffer<int, 4> cb{1, 2, 3};
cb.push_back(4); 
cb.push_back(5);
// 2,3,4,5
std::cout << "cb back():" << cb.back() << " cb back()-1:" << *(cb.data() + 3) <<  *(&cb.back() - 1) << std::endl;

Is there a more beautiful way?

Can the size template parameter 'N' be made into a variable?

First, thanks for the nice package.

My request is whether the template parameter N be made into a variable rather a constant? I have use cases that the size of the buffer is unknown, and is set in a configuration file. It is one less constraint for the circular buffer class. Let me know how you think.

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.