diff --git a/util/Packetizer/Packetizer/util/ArxContainer/ArxContainer/has_include.h b/util/Packetizer/Packetizer/util/ArxContainer/ArxContainer/has_include.h index 76b39a9..d605d71 100644 --- a/util/Packetizer/Packetizer/util/ArxContainer/ArxContainer/has_include.h +++ b/util/Packetizer/Packetizer/util/ArxContainer/ArxContainer/has_include.h @@ -17,7 +17,8 @@ #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++ + // If libstdc++ is used, std::function causes error + // so currently we disable libstdc++ and use ArxTypeTraits #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." diff --git a/util/Packetizer/Packetizer/util/ArxContainer/ArxContainer/initializer_list.h b/util/Packetizer/Packetizer/util/ArxContainer/ArxContainer/initializer_list.h index cdd1e5d..b1cd74f 100644 --- a/util/Packetizer/Packetizer/util/ArxContainer/ArxContainer/initializer_list.h +++ b/util/Packetizer/Packetizer/util/ArxContainer/ArxContainer/initializer_list.h @@ -7,7 +7,7 @@ // define it when is really not available (e.g. // ArduinoSTL is C++98 but *does* define ) and not // already defined (e.g. by ArxContainer). -#if __has_include() +#if ARX_SYSTEM_HAS_INCLUDE() #include #else namespace std { diff --git a/util/Packetizer/Packetizer/util/ArxContainer/README.md b/util/Packetizer/Packetizer/util/ArxContainer/README.md index 4a90558..749d310 100644 --- a/util/Packetizer/Packetizer/util/ArxContainer/README.md +++ b/util/Packetizer/Packetizer/util/ArxContainer/README.md @@ -163,6 +163,8 @@ PRs are welcome! - [ArtNet](https://github.com/hideakitai/ArtNet) - [Tween](https://github.com/hideakitai/Tween) - [TimeProfiler](https://github.com/hideakitai/TimeProfiler) +- [SceneManager](https://github.com/hideakitai/SceneManager) +- [TaskManager](https://github.com/hideakitai/TaskManager) ## License diff --git a/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr.h b/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr.h index 8db67d1..705feff 100644 --- a/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr.h +++ b/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr.h @@ -17,12 +17,12 @@ namespace std { } // Import everything from the std namespace into arx::std, so that // anything we import rather than define is also available through -// arx::arx_std. +// arx::stdx. // This includes everything yet to be defined, so we can do this early // (and must do so, to allow e.g. the C++14 additions in the arx::std // namespace to reference the C++11 stuff from the system headers. namespace arx { - namespace arx_std { + namespace stdx { using namespace ::std; } } @@ -32,9 +32,9 @@ namespace arx { // the standard library version if it is available, falling back to arx // versions for things not supplied by the standard library. Only when // you really need the arx version (e.g. for constexpr numeric_limits -// when also using ArduinoSTL), you need to qualify with arx::arx_std:: +// when also using ArduinoSTL), you need to qualify with arx::stdx:: namespace std { - using namespace ::arx::arx_std; + using namespace ::arx::stdx; } #include "ArxSmartPtr/detail/replace_minmax_macros.h" diff --git a/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr/detail/has_include.h b/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr/detail/has_include.h index 76b39a9..d605d71 100644 --- a/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr/detail/has_include.h +++ b/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr/detail/has_include.h @@ -17,7 +17,8 @@ #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++ + // If libstdc++ is used, std::function causes error + // so currently we disable libstdc++ and use ArxTypeTraits #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." diff --git a/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr/detail/shared_count.h b/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr/detail/shared_count.h index f688d0b..54659be 100644 --- a/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr/detail/shared_count.h +++ b/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr/detail/shared_count.h @@ -7,7 +7,7 @@ // imported and simplified from https://github.com/boostorg/smart_ptr -namespace arx { namespace arx_std { +namespace arx { namespace stdx { namespace detail { @@ -150,7 +150,7 @@ namespace arx { namespace arx_std { } // namespace detail -}} // namespace arx::arx_std +}} // namespace arx::stdx diff --git a/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr/shared_ptr.h b/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr/shared_ptr.h index 9f1bfc5..6eb842a 100644 --- a/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr/shared_ptr.h +++ b/util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr/shared_ptr.h @@ -8,7 +8,7 @@ // imported and simplified from https://github.com/boostorg/smart_ptr -namespace arx { namespace arx_std +namespace arx { namespace stdx { template class shared_ptr; @@ -370,6 +370,6 @@ namespace arx { namespace arx_std return shared_ptr(new T(sp::detail::forward(args)...)); } -}} // namespace arx::arx_std +}} // namespace arx::stdx #endif // ARX_SMART_PTR_SHARED_PTR_H diff --git a/util/Packetizer/Packetizer/util/ArxSmartPtr/README.md b/util/Packetizer/Packetizer/util/ArxSmartPtr/README.md index ed34c2b..c4d6007 100644 --- a/util/Packetizer/Packetizer/util/ArxSmartPtr/README.md +++ b/util/Packetizer/Packetizer/util/ArxSmartPtr/README.md @@ -63,6 +63,8 @@ Please see example for more information. - [MsgPacketizer](https://github.com/hideakitai/MsgPacketizer) - [ArduinoOSC](https://github.com/hideakitai/ArduinoOSC) - [Tween](https://github.com/hideakitai/Tween) +- [SceneManager](https://github.com/hideakitai/SceneManager) +- [TaskManager](https://github.com/hideakitai/TaskManager) ## Roadmap diff --git a/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits.h b/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits.h index 77b4d73..b0adb68 100644 --- a/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits.h +++ b/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits.h @@ -15,12 +15,12 @@ namespace std { } // Import everything from the std namespace into arx::std, so that // anything we import rather than define is also available through -// arx::arx_std. +// arx::stdx. // This includes everything yet to be defined, so we can do this early // (and must do so, to allow e.g. the C++14 additions in the arx::std // namespace to reference the C++11 stuff from the system headers. namespace arx { - namespace arx_std { + namespace stdx { using namespace ::std; } } @@ -30,9 +30,9 @@ namespace arx { // the standard library version if it is available, falling back to arx // versions for things not supplied by the standard library. Only when // you really need the arx version (e.g. for constexpr numeric_limits -// when also using ArduinoSTL), you need to qualify with arx::arx_std:: +// when also using ArduinoSTL), you need to qualify with arx::stdx:: namespace std { - using namespace ::arx::arx_std; + using namespace ::arx::stdx; } #include "ArxTypeTraits/replace_minmax_macros.h" diff --git a/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/functional.h b/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/functional.h index 06208de..ed25943 100644 --- a/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/functional.h +++ b/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/functional.h @@ -28,7 +28,7 @@ inline void* operator new (const size_t size, void* ptr) noexcept { (void)size; return ptr; } #endif -namespace arx { namespace arx_std { +namespace arx { namespace stdx { // reference: // stack overflow https://stackoverflow.com/questions/32074410/stdfunction-bind-like-type-erasure-without-standard-c-library diff --git a/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/has_include.h b/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/has_include.h index 76b39a9..d605d71 100644 --- a/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/has_include.h +++ b/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/has_include.h @@ -17,7 +17,8 @@ #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++ + // If libstdc++ is used, std::function causes error + // so currently we disable libstdc++ and use ArxTypeTraits #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." diff --git a/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/tuple.h b/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/tuple.h index 1489533..2c13d95 100644 --- a/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/tuple.h +++ b/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/tuple.h @@ -9,7 +9,7 @@ #else // Do not have libstdc++11 -namespace arx { namespace arx_std { +namespace arx { namespace stdx { // https://theolizer.com/cpp-school2/cpp-school2-15/ // https://wandbox.org/permlink/C0BWIzjqg4iO3kKZ diff --git a/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/type_traits.h b/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/type_traits.h index 7475830..a24c946 100644 --- a/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/type_traits.h +++ b/util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits/type_traits.h @@ -9,7 +9,7 @@ #else // Do not have libstdc++98 -namespace arx { namespace arx_std { +namespace arx { namespace stdx { template void swap(T& a, T& b) @@ -18,7 +18,7 @@ namespace arx { namespace arx_std { a = move(b); b = move(t); } -} } // namespace arx::arx_std +} } // namespace arx::stdx #endif // Do not have libstdc++98 @@ -34,7 +34,7 @@ namespace arx { namespace arx_std { #include #include -namespace arx { namespace arx_std { +namespace arx { namespace stdx { using nullptr_t = decltype(nullptr); @@ -145,10 +145,6 @@ namespace arx { namespace arx_std { template struct remove_extent { typedef T type; }; - template - T&& move(T& t){ return static_cast(t); } - - template constexpr T&& forward(typename remove_reference::type& t) noexcept { @@ -381,10 +377,31 @@ namespace arx { namespace arx_std { template using result_of = details::result_of; -} } // namespace arx::arx_std +} } // namespace arx::stdx #endif // Do not have libstdc++11 + +#if ARX_HAVE_LIBSTDCPLUSPLUS >= 201402L // Have libstdc++14 + +#else // Do not have libstdc++14 + +namespace arx { namespace stdx { + + // `move` must be declared before including `functional.h` + // C++14 constexpr version should be inside of C++14, + // but moved before `functional.h` + template + constexpr typename remove_reference::type&& move(T&& t) noexcept + { + return static_cast::type&&>(t); + } + +} } // namespace arx::stdx + +#endif // Do not have libstdc++14 + + #include "initializer_list.h" #include "tuple.h" #include "functional.h" @@ -394,7 +411,7 @@ namespace arx { namespace arx_std { // for C++11 above. #else // Do not have libstdc++14 -namespace arx { namespace arx_std { +namespace arx { namespace stdx { template using enable_if_t = typename enable_if::type; @@ -448,7 +465,7 @@ namespace arx { namespace arx_std { template using index_sequence_for = make_index_sequence; -} } // namespace arx::arx_std +} } // namespace arx::stdx #endif // Do not have libstdc++14 @@ -458,7 +475,7 @@ namespace arx { namespace arx_std { // for C++11 above. #else // Do not have libstdc++17 -namespace arx { namespace arx_std { +namespace arx { namespace stdx { template struct Tester { using type = void; }; @@ -506,7 +523,7 @@ namespace arx { namespace arx_std { ); } -} } // namespace arx::arx_std +} } // namespace arx::stdx #endif // Do not have libstdc++17 @@ -516,7 +533,7 @@ namespace arx { namespace arx_std { // for C++11 above. #else // Do not have libstdc++2a -namespace arx { namespace arx_std { +namespace arx { namespace stdx { template struct remove_cvref @@ -527,7 +544,7 @@ namespace arx { namespace arx_std { template< class T > using remove_cvref_t = typename remove_cvref::type; -} } // namespace arx::arx_std +} } // namespace arx::stdx #endif // Do not have libstdc++2a diff --git a/util/Packetizer/Packetizer/util/ArxTypeTraits/README.md b/util/Packetizer/Packetizer/util/ArxTypeTraits/README.md index db6f74a..a36ee61 100644 --- a/util/Packetizer/Packetizer/util/ArxTypeTraits/README.md +++ b/util/Packetizer/Packetizer/util/ArxTypeTraits/README.md @@ -8,13 +8,13 @@ C++ type_traits for Arduino which cannot use it as default - automatically use standard library first if the boards can - if standard library is not enough (e.g. only C++11 is available), add missing parts listed below - works almost all Arduino platforms (Let me know if you have errors) -- compatible with [ArduinoSTL](https://github.com/mike-matera/ArduinoSTL) or other [uClibc++](https://www.uclibc.org/) libraries (include them before `ArxTypeTraits`) +- compatible with [ArduinoSTL](https://github.com/mike-matera/ArduinoSTL) or other [uClibc++](https://www.uclibc.org/) libraries - thx @matthijskooijman ## Supported Class Templates -### C++11 (defined only for platforms above which cannot use `type_traits`) +### C++11 (defined only for boards before C++11) - `std::integral_constant` - `std::true_type` @@ -102,6 +102,7 @@ C++ type_traits for Arduino which cannot use it as default - [PollingTimer](https://github.com/hideakitai/PollingTimer) - [Tween](https://github.com/hideakitai/Tween) - [ArxStringUtils](https://github.com/hideakitai/ArxStringUtils) +- [Filters](https://github.com/hideakitai/Filters) ## Contributors