Comments (7)
You can see in here how it should work
http://cpp-today.blogspot.com/2017/03/structured-binding-c17-inside.html
from cpp17_in_tts.
In the constexpr-if example, in C++14 I return void
for get when N is out of bounds, but return int const & and string const & for the other 2. I don't see the problem?
For tuple_size/element - I'm leaving that out of the constexpr-if part, but I could be more clear about it in the structured bindings part, so I will update that.
from cpp17_in_tts.
As soon you want to use the get<> the compiler will bash you with something on the line of, I solved with returning auto and I had to not implement the not specialized one otherwise you will get the error at compile time even if you never use the get<2>()
test4.cpp:19:18: error: no function template matches function template specialization 'get'
template<> float get<0>(Y const & foo)
^
test4.cpp:16:22: note: candidate template ignored: could not match 'void (const Y &)' against 'float (const Y &)'
template void get(Y const & foo)
from cpp17_in_tts.
Yep I see it. I need to compile my example more. Thanks.
/working on fix...
from cpp17_in_tts.
Take a look at https://github.com/tvaneerd/cpp17_in_TTs/blob/master/if_constexpr.md before I merge it into ALL_IN_ONE.
from cpp17_in_tts.
You have a pull request that you can merge. Nice the usage of conditional_t however I sill prefer my implementation of tuple_element:
template<size_t I> struct std::tuple_element<I, Y> { using type = decltype(get<I>(declval<Y>())); };
from cpp17_in_tts.
thanks for the pull request
from cpp17_in_tts.
Related Issues (11)
- Parallel execution policies HOT 1
- Indenting in C++ examples is confused. HOT 6
- `std::any` requires no calls to new? HOT 1
- structure binding typo HOT 1
- std::optional usage example with new if is iffy HOT 3
- Byte type HOT 1
- Please consider adding a license HOT 1
- Add a bit about monostate in std::variant section?
- Structured Bindings auto without ref HOT 4
- Mistake in first table in structured_bindings.md? HOT 1
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 cpp17_in_tts.