-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
view::generate always std::input_range
- Loading branch information
1 parent
4463663
commit 898745b
Showing
6 changed files
with
139 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#pragma once | ||
|
||
// Copyright 2020 Ole Erik Peistorpet | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
|
||
#include "core_util.h" | ||
|
||
|
||
namespace oel::_detail | ||
{ | ||
template< typename T, typename U, | ||
bool = std::is_empty_v<U> > | ||
struct TightPair | ||
{ | ||
T first; | ||
U _sec; | ||
|
||
OEL_ALWAYS_INLINE constexpr const U & second() const { return _sec; } | ||
OEL_ALWAYS_INLINE constexpr U & second() { return _sec; } | ||
}; | ||
|
||
// MSVC needs unique names to guard against name collision due to inheritance | ||
template< typename T_Qai6Y, typename U_Qai6Y > | ||
struct TightPair<T_Qai6Y, U_Qai6Y, true> | ||
: U_Qai6Y | ||
{ | ||
T_Qai6Y first; | ||
|
||
TightPair() = default; | ||
constexpr TightPair(T_Qai6Y f, U_Qai6Y s) | ||
: U_Qai6Y{s}, first{std::move(f)} | ||
{} | ||
|
||
OEL_ALWAYS_INLINE constexpr const U_Qai6Y & second() const { return *this; } | ||
OEL_ALWAYS_INLINE constexpr U_Qai6Y & second() { return *this; } | ||
}; | ||
|
||
|
||
template< typename T, typename F, | ||
bool = std::is_empty_v<F> > | ||
struct TightPairMutableFn | ||
{ | ||
T first; | ||
F mutable _fn; | ||
|
||
OEL_ALWAYS_INLINE constexpr F & func() const { return _fn; } | ||
}; | ||
|
||
template< typename T_Qai6Y, typename F_Qai6Y > | ||
struct TightPairMutableFn<T_Qai6Y, F_Qai6Y, true> | ||
: F_Qai6Y | ||
{ | ||
T_Qai6Y first; | ||
|
||
TightPairMutableFn() = default; | ||
constexpr TightPairMutableFn(T_Qai6Y fir, F_Qai6Y fn) | ||
: F_Qai6Y{fn}, first{std::move(fir)} | ||
{} | ||
|
||
OEL_ALWAYS_INLINE constexpr F_Qai6Y & func() const | ||
{ | ||
return const_cast<TightPairMutableFn &>(*this); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.