ard-stdlib (community library)

Summary

Name Value
Name ard-stdlib
Version 1.0.0
Installs 632
License GPL-3.0 License.
Author Vladimir Talybin
URL https://github.com/talybin/ard-stdlib
Repository https://github.com/talybin/ard-stdlib.git
Download .tar.gz

Type traits and utilities from C++17/20/23 and experimental TS.

Library Read Me

This content is provided by the library maintainer and has not been validated or approved.

ARD-STDLIB

Library of type traits and utilities from C++17/20/23 and experimental TS.

Currently supporting

variant.hpp

optional.hpp

string_view.hpp

memory.hpp

utility.hpp

type_traits.hpp

functional.hpp

Get started

All header files has the same name as original but with postfix .hpp. For example, to include variant use variant.hpp.

#include "Particle.h"
#include "variant.hpp"

void setup()
{
std::variant<int, float> v;
v = 19.5f; // v contains float

bool success = std::visit([](auto temp) {
return Particle.publish("temperature", String::format("%.1f", temp));
}, v);
}

void loop() { }
Exception handling

As you may know, exceptions are disabled on Arduino. Instead of throwing exception, library will call special handler function with exception as argument. It is defined in exception.hpp and in case of an exception, will abort the program (call std::abort).

To catch exceptions override exception handler.

#include "Particle.h"
#include "exception.hpp"

void ard::on_exception(const std::exception& ex) {
// Log exception
Particle.publish("Error", ex.what(), PRIVATE);
// Reboot
System.reset();
}

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

Note! The exception handler is located in ard namespace.

Browse Library Files