Comments (5)
I've implemented the analogue to this, but for another function than begin and with a few more options for customization (e.g. static member functions), but lacking the array case in section 6.5.4.1.1 of N4296. Is the priority tag idiom used below a good way to get the fallback mechanism of 6.5.4.1?
constexpr int MaxPrioLevel = 2;
template<int Level> struct Prio : public Prio<Level-1>
{
constexpr Prio(){}
static_assert(Level<=MaxPrioLevel,"Level must not be greater than MaxPrioLevel, to make sure MaxPrio means maximum priority. It is safe to increase MaxPrioLevel if needed.");
};
template<> struct Prio<0>{constexpr Prio(){}};
constexpr Prio<MaxPrioLevel> maxPrio;
struct begin_fn
{
private:
//Array. Case 6.5.4.1.3 of N4296
//TODO with Prio<2>
//Member function. Case 6.5.4.1.2 of N4296
template<typename T, typename... Args>
auto f(Prio<1>, T&& x, Args&&... args) const ->
decltype(std::forward<T>(x).begin(std::forward<Args>(args)...))
{
return std::forward<T>(x).begin(std::forward<Args>(args)...);
}
//Free function (e.g. from argument dependent lookup (ADL)). Case 6.5.4.1.3 of N4296
template<typename... Args>
auto f(Prio<0>, Args&&... args) const ->
decltype(begin(std::forward<Args>(args)...))
{
return begin(std::forward<Args>(args)...);
}
public:
template<typename... Args>
decltype(auto) operator()(Args&&... args) const
{
return this->f(maxPrio, std::forward<Args>(args)...);
}
};
from range-v3.
Should all involved functions be constexpr
?
If I understand 7.1.5.6 of N4296 correctly, it is valid to mark functions and member functions as constexpr
even if for some template arguments they will not be constexpr
? Will they in essence then be constexpr whenever the template arguments allow it then?
Should one always mark forwarding template functions constexpr
?
from range-v3.
Your Prio
class could be a handy way to implement this, but the partial ordering could be tricky once you add the array case.
from range-v3.
Could you elaborate on this?
If the array case is implemented with Prio<2>
, it will be matched first for arrays, then member functions (as Prio<1>
) and finally free functions (adl, as Prio<0>
). Wouldn't this perfectly mimic 6.5.4.1?
from range-v3.
Fixed in e8332a5
from range-v3.
Related Issues (20)
- views::concat doesn't work with std::vector HOT 1
- C++20 HOT 2
- Please add "feature test macros"
- "ranges::to" failed for template type T with universal construction HOT 2
- warning: out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated [-Wdeprecated]
- cannot create any_view from empty_view
- view chunk can't compile? HOT 1
- Cast issue with GCC12 HOT 2
- Remove duplicate elements from multiple input vectors at the same time
- views::generate doesn't work with views::chunk_by HOT 5
- ranges::to eigen HOT 2
- C++23's range_adaptor_closure equivalent HOT 2
- Security disclosure policy
- Range-v3 fails to compile on the latest MSVC version with Visual Studio 2022 HOT 1
- CMAKE_CXX_STANDARD 20 and RANGES_CXX_STD 17 - does not work HOT 1
- pipe adaptor support for tuple_algorithm.hpp
- Nested `key_type` for lazy set algorithms formatting?
- UB in std::views::split HOT 7
- action::remove not included
- Error when using function return value directly 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 range-v3.