forked from boostorg/iterator
Extracted and unified default template parameter handling helpers.
The new eval_if_default helper replaces both ia_dflt_help and ia_eval_if_default helpers. Additionally, added a new if_default helper, which expands to the type or the default parameter directly. The new helpers are placed in separate headers which can be used without the iterator_adaptor template.
This commit is contained in:
1 parent
cb81a1dfc3
commit
6e60ea7a88
6 files changed
+190
-124
No files matched your search
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* https://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* Copyright (c) 2025 Andrey Semashev
|
||||
*/
|
||||
|
||||
#ifndef BOOST_ITERATOR_DETAIL_IF_DEFAULT_HPP_INCLUDED_
|
||||
#define BOOST_ITERATOR_DETAIL_IF_DEFAULT_HPP_INCLUDED_
|
||||
|
||||
#include <boost/core/use_default.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace iterators {
|
||||
namespace detail {
|
||||
|
||||
// If T is use_default, return Default, otherwise - Nondefault.
|
||||
// By default, Nondefault is T, which means
|
||||
// the metafunction can be called with just two parameters
|
||||
// and in that case will return either T or Default.
|
||||
template< typename T, typename Default, typename Nondefault = T >
|
||||
struct if_default
|
||||
{
|
||||
using type = Nondefault;
|
||||
};
|
||||
|
||||
template< typename Default, typename Nondefault >
|
||||
struct if_default< use_default, Default, Nondefault >
|
||||
{
|
||||
using type = Default;
|
||||
};
|
||||
|
||||
template< typename T, typename Default, typename Nondefault = T >
|
||||
using if_default_t = typename if_default< T, Default, Nondefault >::type;
|
||||
|
||||
} // namespace detail
|
||||
} // namespace iterators
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ITERATOR_DETAIL_IF_DEFAULT_HPP_INCLUDED_
|
||||
Reference in new issue
Block a user