Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: addition of etl::expected #615

Closed
jputcu opened this issue Oct 2, 2022 · 9 comments
Closed

Feature request: addition of etl::expected #615

jputcu opened this issue Oct 2, 2022 · 9 comments
Assignees

Comments

@jputcu
Copy link
Contributor

jputcu commented Oct 2, 2022

Could it be possible to add etl::expected, matching the c++23 std::expected.
Because the lack of exceptions on my AVR platform, I have used etl::variant for this, but having a more standard way would be better.
This could be a replacement of etl::result.

@jwellbelove jwellbelove self-assigned this Oct 2, 2022
@jwellbelove
Copy link
Contributor

Thanks, I'll take a look at that

jwellbelove added a commit that referenced this issue Oct 24, 2022
…ub.com/ETLCPP/etl into feature/#615-addition-of-etl--expected

# Conflicts:
#	.gitignore
jwellbelove added a commit that referenced this issue Oct 27, 2022
…ub.com/ETLCPP/etl into feature/#615-addition-of-etl--expected

# Conflicts:
#	include/etl/expected.h
jwellbelove added a commit that referenced this issue Oct 31, 2022
…ub.com/ETLCPP/etl into feature/#615-addition-of-etl--expected

# Conflicts:
#	include/etl/expected.h
#	test/vs2019/etl.vcxproj.filters
@jwellbelove
Copy link
Contributor

Implementation of etl::unexpected in 20.35.0

@jputcu
Copy link
Contributor Author

jputcu commented Feb 6, 2023

I was planning to use this, but noticed only unexpected was provided.
Looking around I found two nice, active, alternatives:

  1. https://github.com/martinmoene/expected-lite
  2. https://github.com/TartanLlama/expected

To not reinvent the wheel it would be nice if we could use them, but I quickly run into AVR limitations, e.g. missing utility header. Although etl probably provides everything required.
Could it be possible to provide a layer to satisfy the std library?

This layer would allow more lightweight C++ libraries to be used, e.g. https://github.com/boost-ext/sml.

@jwellbelove
Copy link
Contributor

I have an implementation of etl::expected that's almost complete, but I haven't had time to release it yet.

If you are not using the STL they you could try using a namespace alias...
namespace std = etl;
I haven't tried this myself.
The ETL would also need to have STL style header names for it to work without changing any code.

@jwellbelove
Copy link
Contributor

The trouble with the last thing I said about headers is that the compiler would not be able to distinguish which template library (STL or ETL) to use when it sees something like #include <algorithm>.

@jputcu
Copy link
Contributor Author

jputcu commented Feb 6, 2023

I think all etl headers end with .h, so we could perhaps add a directory with the official headers which forward to the .h headers and alias the namespace?

@jwellbelove
Copy link
Contributor

I think the problem is that if you did that, the compiler will will probably still find its own headers before the ETL's.

#include <algorithm> <<< I think the compiler will choose its own header first.

@jwellbelove
Copy link
Contributor

jwellbelove commented Feb 6, 2023

With GCC it seems you can use -nostdinc++ as a compiler option. I don't know about other compilers.

Edit: There also seems to be a -I option.

jwellbelove pushed a commit that referenced this issue Feb 6, 2023
…ub.com/ETLCPP/etl into feature/#615-addition-of-etl--expected

# Conflicts:
#	arduino/library-arduino.json
#	arduino/library-arduino.properties
#	include/etl/expected.h
#	include/etl/private/variant_variadic.h
#	include/etl/result.h
#	include/etl/version.h
#	library.json
#	library.properties
#	support/Release notes.txt
#	version.txt
@jwellbelove
Copy link
Contributor

Fixed 20.35.12

@github-project-automation github-project-automation bot moved this from In progress to Done in Embedded Template Library Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants