Comments (4)
That line exists solely to silence "no return statement in non-void function" warnings. I wonder if calling std::abort()
and adding [[noreturn]]
would be more elegant.
from rx-ranges.
No. You just need to not create the _get
method with an empty index_sequence, and never call it.
Nevermind you always get a branch with no return statement with my solution.
from rx-ranges.
I end up using your solution as this snippet is ugly (returning the last element if not in range):
template <size_t i, size_t... rest>
constexpr output_type _get(std::index_sequence<i, rest...>) const {
RX_ASSERT(current_input < sizeof...(Rs)); // chain was at end!
if constexpr (sizeof...(rest) <= 0) {
return std::get<i>(inputs).get();
} else {
if (i == current_input) {
return std::get<i>(inputs).get();
} else {
return _get(std::index_sequence<rest...>{});
}
}
}
from rx-ranges.
And now I realize that the drawback of using std::abort()
here is that ChainRange
can no longer be used at all in a constexpr
context. I wonder if throw
can be used instead, but I'm not sure because I think the recursion base case will be compiled for any instantiation of get<size_t...>
. This might have already been true with the assertion.
Alexandrescu has a solution here, but nobody seems to know why it works: https://akrzemi1.wordpress.com/2017/05/18/asserts-in-constexpr-functions/
Hmm. I think it's more important to lift the default-constructibility requirement than to remain constexpr
. I'll have a look at ensuring constexpr
-ness later.
from rx-ranges.
Related Issues (10)
- transform is called twice on transform+filter HOT 2
- VS2017 won't compile without Conformance Mode HOT 8
- First doesn't work after sort HOT 2
- Why is uniq a sink? HOT 1
- Complete exception safety and noexcept hygiene
- missing include <stdexcept> HOT 4
- Make months in calendar constexpr HOT 2
- Test constexpr compatibility for all combinators
- RFE: string extension - split, strip, join HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rx-ranges.