update ArxContainer to v0.3.9

master
Hideaki Tai 4 years ago
parent 4514d46dbb
commit a7fb95ce81

@ -251,7 +251,7 @@ Please use only sender OR receiver.
## Embedded Libraries
- [ArxContainer v0.3.8](https://github.com/hideakitai/ArxContainer)
- [ArxContainer v0.3.9](https://github.com/hideakitai/ArxContainer)
- [TeensyDirtySTLErrorSolution v0.1.0](https://github.com/hideakitai/TeensyDirtySTLErrorSolution)

@ -3,17 +3,26 @@
#ifndef ARX_RINGBUFFER_H
#define ARX_RINGBUFFER_H
#if __cplusplus < 201103L
#error "C++11 must be enabled in the compiler for this library to work, please check your compiler flags"
#endif
#include "ArxContainer/has_include.h"
#include "ArxContainer/has_libstdcplusplus.h"
#include <Arduino.h>
#if defined(ARDUINO_ARCH_AVR)\
|| defined(ARDUINO_ARCH_MEGAAVR)\
|| defined(ARDUINO_ARCH_SAM)\
|| defined(ARDUINO_ARCH_SAMD)\
|| defined(ARDUINO_spresense_ast)
#define ARX_CONTAINER_DISABLED
#endif
#include "ArxContainer/replace_minmax_macros.h"
#include "ArxContainer/initializer_list.h"
#if ARX_HAVE_LIBSTDCPLUSPLUS >= 201103L // Have libstdc++11
#include <vector>
#include <deque>
#include <map>
#else // Do not have libstdc++11
#ifdef ARX_CONTAINER_DISABLED
#ifndef ARX_VECTOR_DEFAULT_SIZE
#define ARX_VECTOR_DEFAULT_SIZE 16
@ -27,25 +36,6 @@
#define ARX_MAP_DEFAULT_SIZE 16
#endif // ARX_MAP_DEFAULT_SIZE
#ifndef ARX_TYPE_TRAITS_INITIALIZER_LIST_DEFINED
#define ARX_TYPE_TRAITS_INITIALIZER_LIST_DEFINED
namespace std
{
template<class T>
class initializer_list
{
private:
const T* array;
size_t len;
initializer_list(const T* a, size_t l) : array(a), len(l) {}
public:
initializer_list() : array(nullptr), len(0) {}
size_t size() const { return len; }
const T *begin() const { return array; }
const T *end() const { return array + len; }
};
}
#endif // ARX_TYPE_TRAITS_INITIALIZER_LIST_DEFINED
namespace arx {
@ -560,5 +550,5 @@ template<typename T, size_t N>
using ArxRingBuffer = arx::RingBuffer<T, N>;
#endif // ARX_CONTAINER_DISABLED
#endif // Do not have libstdc++11
#endif // ARX_RINGBUFFER_H

@ -0,0 +1,29 @@
#pragma once
#ifndef ARX_TYPE_TRAITS_HAS_INCLUDE_H
#define ARX_TYPE_TRAITS_HAS_INCLUDE_H
// Check whether __has_include is available, but also check the GCC
// version (__has_include was introduced in gcc 5) to catch
// environments (such as ESP8266) where gcc is old, but some system
// header provides a fake __has_include. We also need to check
// against __clang__ here, since clang pretends to be GCC
// 4.something and would otherwise be detected incorrectly here...
#if !defined(__has_include) || defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__)
#if defined(ARDUINO_ARCH_ESP8266)
// ESP8266 does not have a working __has_include, but we
// know it does have a working libstdc++ with all the
// headers we care about, so provide a fake has_include
#define ARX_SYSTEM_HAS_INCLUDE(x) 1
#elif defined(ARDUINO_SAM_DUE)
// Arduino DUE's GCC version is 4.8.3 (GCC < 5.0).
// And it has not libstdc++
#define ARX_SYSTEM_HAS_INCLUDE(x) 0
#else
#error "Compiler does not support __has_include, please report a bug against the ArxTypeTraits library about this."
#endif
#else
#define ARX_SYSTEM_HAS_INCLUDE(x) __has_include(x)
#endif
#endif // ARX_TYPE_TRAITS_HAS_INCLUDE_H

@ -0,0 +1,25 @@
#pragma once
#ifndef ARX_TYPE_TRAITS_HAS_LIBSTDCPLUSPLUS_H
#define ARX_TYPE_TRAITS_HAS_LIBSTDCPLUSPLUS_H
#if !defined(ARX_HAVE_LIBSTDCPLUSPLUS)
#if ARX_SYSTEM_HAS_INCLUDE(<cstdlib>)
#include <cstdlib>
#if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION)
// For gcc's libstdc++ and clang's libc++, assume that
// __cplusplus tells us what the standard includes support
#define ARX_HAVE_LIBSTDCPLUSPLUS __cplusplus
#elif defined(__UCLIBCXX_MAJOR__)
// For uclibc++, assume C++98 support only.
#define ARX_HAVE_LIBSTDCPLUSPLUS 199711L
#else
#error "Unknown C++ library found, please report a bug against the ArxTypeTraits library about this."
#endif
#else
// Assume no standard library is available at all (e.g. on AVR)
#define ARX_HAVE_LIBSTDCPLUSPLUS 0
#endif
#endif
#endif // ARX_TYPE_TRAITS_HAS_LIBSTDCPLUSPLUS_H

@ -0,0 +1,30 @@
#pragma once
#ifndef ARX_TYPE_TRAITS_INITIALIZER_H
#define ARX_TYPE_TRAITS_INITIALIZER_H
// Initializer_list *must* be defined in std, so take extra care to only
// define it when <initializer_list> is really not available (e.g.
// ArduinoSTL is C++98 but *does* define <initializer_list>) and not
// already defined (e.g. by ArxContainer).
#if __has_include(<initializer_list>)
#include <initializer_list>
#else
namespace std {
template<class T>
class initializer_list
{
private:
const T* array;
size_t len;
initializer_list(const T* a, size_t l) : array(a), len(l) {}
public:
initializer_list() : array(nullptr), len(0) {}
size_t size() const { return len; }
const T *begin() const { return array; }
const T *end() const { return array + len; }
};
} // namespace std
#endif
#endif // ARX_TYPE_TRAITS_INITIALIZER_LIST_H

@ -0,0 +1,33 @@
#pragma once
#ifndef ARX_TYPE_TRAITS_REPLACE_MINMAX_MACROS_H
#define ARX_TYPE_TRAITS_REPLACE_MINMAX_MACROS_H
// Make sure Arduino.h is actually included, since otherwise it might be
// included later and break *uses* of the min/max methods, rather than
// the declarations of it.
#include <Arduino.h>
// These macros are defined by Arduino.h on some platforms, and conflict
// with min/max methods defined or included by ArxTypeTraits, so replace
// them with macros here.
#ifdef max
#undef max
template <typename T1, typename T2>
constexpr auto max(T1 x, T2 y)
-> decltype(x + y)
{
return (x > y) ? x : y;
}
#endif
#ifdef min
#undef min
template <typename T1, typename T2>
constexpr auto min(T1 x, T2 y)
-> decltype(x + y)
{
return (x < y) ? x : y;
}
#endif
#endif // ARX_TYPE_TRAITS_REPLACE_MINMAX_MACROS_H

@ -1,12 +1,14 @@
# ArxContainer
C++ container-like classes (vector, map, etc.) for Arduino which cannot use STL
C++ container-like classes (`vector`, `deque`, `map` etc.) for Arduino which cannot use STL
## Note
`ArxContainer` is C++ container-__like__ classes for Arduino.
All of the functions is not supported currently.
Detail of these containers are described in Detail section.
- `ArxContainer` is C++ container-__like__ classes for Arduino
- Containers in this library is defined inside namespace `arx` instad of `std` (e.g. `arx::vector`)
- All of the functions is not supported currently
- If standard libraries are available, automatically use `std` version instead of `arx` version
## Supported Container Types
@ -17,14 +19,12 @@ Detail of these containers are described in Detail section.
## Supported Boards
This library is currently enabled only if you use following architecture.
Please use C++ Standard Template Library for other boards.
`arx` version of containers are enabled only if you use following architecture.
In other borads, `arx` version is disabled and standard libraries (`std` version) will be imported (because they can use them).
- AVR (Uno, Nano, Mega, etc.)
- MEGAAVR (Uno WiFi, Nano Ecery, etc.)
- SAM (Due)
- SAMD (Zero, MKR, M0, etc.)
- SPRESENSE
## Usage

@ -2,18 +2,16 @@
"name": "ArxContainer",
"keywords": "ringbuffer, vector, deque, map",
"description": "C++ container-like classes (vector, map, etc.) for Arduino which cannot use STL",
"repository":
{
"repository": {
"type": "git",
"url": "https://github.com/hideakitai/ArxContainer.git"
},
"authors":
{
"authors": {
"name": "Hideaki Tai",
"url": "https://github.com/hideakitai",
"maintainer": true
},
"version": "0.3.8",
"version": "0.3.9",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*"

@ -1,9 +1,9 @@
name=ArxContainer
version=0.3.8
version=0.3.9
author=hideakitai
maintainer=hideakitai
sentence=C++ container-like classes (vector, map, etc.) for Arduino which cannot use STL
paragraph=C++ container-like classes (vector, map, etc.) for Arduino which cannot use STL
category=Data Storage
url=https://github.com/hideakitai
url=https://github.com/hideakitai/ArxContainer
architectures=*

Loading…
Cancel
Save