Closed labodj closed 4 years ago
Which release are you using?
I always use latest version I'm currently using Embedded Template Library: 18.1.1
There may have been a mistake in platform.h with the definition of certain macros. Give me a few moments and I'll tag the latest push. (18.1.2)
No problem, I'm here to test :)
OK, done.
Since the new version is not out on PlatforIO I just replaced 18.1.1 library with 18.1.2 you just released.
I noted 2 things:
This is the output with 18.1.2 and the same MCVE with c++14
Compiling .pio/build/megaatmega2560/src/main.cpp.o
In file included from .pio/libdeps/megaatmega2560/avr_stl/src/memory:20,
from .pio/libdeps/megaatmega2560/avr_stl/src/char_traits:22,
from .pio/libdeps/megaatmega2560/avr_stl/src/iosfwd:21,
from .pio/libdeps/megaatmega2560/avr_stl/src/serstream:48,
from .pio/libdeps/megaatmega2560/avr_stl/src/ArduinoSTL.h:12,
from src/main.cpp:2:
.pio/libdeps/megaatmega2560/avr_stl/src/new:40:58: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
40 | _UCXXEXPORT void* operator new(std::size_t numBytes) throw(std::bad_alloc);
| ^~~~~
.pio/libdeps/megaatmega2560/avr_stl/src/new:50:60: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
50 | _UCXXEXPORT void* operator new[](std::size_t numBytes) throw(std::bad_alloc);
| ^~~~~
In file included from .pio/libdeps/megaatmega2560/Embedded Template Library_ID930/include/etl/iterator.h:36,
from .pio/libdeps/megaatmega2560/Embedded Template Library_ID930/include/etl/container.h:37,
from .pio/libdeps/megaatmega2560/Embedded Template Library_ID930/include/etl/algorithm.h:44,
from .pio/libdeps/megaatmega2560/Embedded Template Library_ID930/include/etl/map.h:40,
from src/main.cpp:3:
.pio/libdeps/megaatmega2560/Embedded Template Library_ID930/include/etl/utility.h: In instantiation of 'constexpr etl::pair<T1, T2>::pair(etl::pair<U1, U2>&&) [with U1 = const char*&; U2 = unsigned char; T1 = const char*&; T2 = unsigned char]':
.pio/libdeps/megaatmega2560/Embedded Template Library_ID930/include/etl/utility.h:238:65: required from 'etl::pair<T1, T2> etl::make_pair(T1&&, T2&&) [with T1 = const char*&; T2 = unsigned char]'
.pio/libdeps/megaatmega2560/Embedded Template Library_ID930/include/etl/map.h:925:49: required from 'etl::imap<TKey, TMapped, TKeyCompare>::mapped_type& etl::imap<TKey, TMapped, TKeyCompare>::operator[](etl::imap<TKey, TMapped, TKeyCompare>::key_parameter_t) [with TKey = const char*; TMapped = unsigned char; TKeyCompare = etl::less<const char*>; etl::imap<TKey, TMapped, TKeyCompare>::mapped_type = unsigned char; etl::imap<TKey, TMapped, TKeyCompare>::key_parameter_t = const char*]'
src/main.cpp:13:18: required from here
.pio/libdeps/megaatmega2560/Embedded Template Library_ID930/include/etl/utility.h:159:39: error: cannot bind non-const lvalue reference of type 'const char*&' to an rvalue of type 'etl::remove_reference<const char*&>::type' {aka 'const char*'}
159 | , second(etl::move(other.second))
| ^
.pio/libdeps/megaatmega2560/Embedded Template Library_ID930/include/etl/utility.h: In instantiation of 'constexpr etl::pair<T1, T2>::pair(etl::pair<U1, U2>&&) [with U1 = etl::imap<const char*, unsigned char, etl::less<const char*> >::iterator; U2 = bool&; T1 = etl::imap<const char*, unsigned char, etl::less<const char*> >::iterator; T2 = bool&]':
.pio/libdeps/megaatmega2560/Embedded Template Library_ID930/include/etl/utility.h:238:65: required from 'etl::pair<T1, T2> etl::make_pair(T1&&, T2&&) [with T1 = etl::imap<const char*, unsigned char, etl::less<const char*> >::iterator; T2 = bool&]'
.pio/libdeps/megaatmega2560/Embedded Template Library_ID930/include/etl/map.h:1142:35: required from 'etl::pair<etl::imap<TKey, TMapped, TKeyCompare>::iterator, bool> etl::imap<TKey, TMapped, TKeyCompare>::insert(etl::imap<TKey, TMapped, TKeyCompare>::rvalue_reference) [with TKey = const char*; TMapped = unsigned char; TKeyCompare = etl::less<const char*>; etl::imap<TKey, TMapped, TKeyCompare>::rvalue_reference = etl::pair<const char* const, unsigned char>&&; etl::imap<TKey, TMapped, TKeyCompare>::value_type = etl::pair<const char* const, unsigned char>]'
.pio/libdeps/megaatmega2560/Embedded Template Library_ID930/include/etl/map.h:925:71: required from 'etl::imap<TKey, TMapped, TKeyCompare>::mapped_type& etl::imap<TKey, TMapped, TKeyCompare>::operator[](etl::imap<TKey, TMapped, TKeyCompare>::key_parameter_t) [with TKey = const char*; TMapped = unsigned char; TKeyCompare = etl::less<const char*>; etl::imap<TKey, TMapped, TKeyCompare>::mapped_type = unsigned char; etl::imap<TKey, TMapped, TKeyCompare>::key_parameter_t = const char*]'
src/main.cpp:13:18: required from here
.pio/libdeps/megaatmega2560/Embedded Template Library_ID930/include/etl/utility.h:159:39: error: cannot bind non-const lvalue reference of type 'bool&' to an rvalue of type 'etl::remove_reference<bool&>::type' {aka 'bool'}
*** [.pio/build/megaatmega2560/src/main.cpp.o] Error 1
Opps! My bad! I've been jumping back and forth between jobs today and forgot I hadn't merged to master yet. Sorry, I get that done now.
Hopefully that's sorted it. (fingers crossed)
I've just tested it, the version is now correct but the error still appears. You solved it in the past in https://github.com/ETLCPP/etl/issues/210 That time I've tested it with c++17 only, today that I'm trying to manage to get my code back compatible with c++11 and c++14 the problem appears. I've tried to replace move with forward, but I'm not so c++ advanced, my random trial make only things worse.
Are you saying one of the previous changes has been reversed?
No, i'm not. I'm saying that this problem has been fixed with 17.7.1 but at that time I've tested it compiling with c++17 option only, it doesn't work if compiled with c++14 or c++11 options.
I've just tested old 17.8.0 library version, with c++17 it's ok, with c++14 ot 11 it's not.
Ok, I think I may I found the cause. C++17 seems to be better at deducing types for 'forward' as used in pair. Also it seems that there were a couple of more places where 'move' should have been replaced with 'forward' (I checked against another library's implementation) I've re-released 18.1.2
Ooooh yes!!! You nailed it! It now works as expected! Thanks a lot!
Phew! I was getting worried there.
Same problem of closed issue https://github.com/ETLCPP/etl/issues/210
Hello, I just noted that I'm having problem compiling my code when I use etl::map and c++ < 17.
I'm currently using platformio to compile my project with a custom GCC, I created a MCVE code that always spawn errors.
platformio.ini:
etl_profile.h:
main.cpp:
compiler used (gcc 9.3.0 with patch and fixes): https://blog.zakkemble.net/avr-gcc-builds/comment-page-1/#comment-209216
compilation output when compiled with c++11 or c++14 option:
When it's compiled using c++17 option it runs just fine.