Code Monkey home page Code Monkey logo

ard-boost's Introduction

ARD-BOOST

This is a mini port of Boost library, version 1.72.0 (latest on time of writing). Boost is a set of C++ libraries that provide support for tasks and structures such as linear algebra, pseudorandom number generation, multithreading, image processing, regular expressions, unit testing and many more. It contains 160 individual libraries.

Not all libraries are included in this port. Some libraries, such as threading and filesystem, makes no sence on Arduino hardware. Others are already in the standard, like chrono and array, and can be used from standard namespace. But there are many libraries that are not yet in standard or require C++17 or just great parts of Boost. These parts ported to this library.

So far it includes only libraries I was able to compile for Arduino. My intention is to add more libraries as needed. Requests are welcome.

Currently supporting

The following is a list of supported libraries with all their dependencies:

Get started

Before include of any Boost library make sure to include ard-boost.h. This will setup exception handling and fix some compile problems. Otherwise the usage is the same as usual. Include any of supported library and you are good to go.

#include "ard-boost.h"
#include "boost/range.hpp"

void setup()
{
    int sum = 0;
    for (int i : boost::irange(5, 10))
        sum += i;
}

void loop() { }

Exception handling

As you may know, exceptions are disabled on Arduino. Instead of throwing exception, Boost will call special handler function with exception as argument. It is defined in ard-boost.h and by default, in case of an exception, will reboot the device.

To provide your own exception handler, make sure to define CUSTOM_EXCEPTION_HANDLER before include of ard-boost.h and override exception function. For example:

#define CUSTOM_EXCEPTION_HANDLER
#include "ard-boost.h"

void boost::throw_exception(const std::exception& ex) {
    // Log exception and reboot
    Particle.publish("Error", ex.what(), PRIVATE);
    System.reset();
}

void setup() { }
void loop() { }

Note! The exception handler must not return (protected by noreturn attribute).

ard-boost's People

Contributors

talybin avatar

Watchers

 avatar

ard-boost's Issues

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.