General Purpose library for Freestanding C++ and POSIX systems
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

72 satır
1.2 KiB

#pragma once
#include "gp/algorithms/tmp_manip.hpp"
namespace gp{
/*template<typename T>
concept IsSubstractible = requires(T a, T b)
{
{a - b} -> std::integral;
};*/
template<typename it, bool Enable = std::is_integral_v<decltype(it{} - it{})>/* IsSubstractible<it> */>
class nameless_range;
template<typename it>
class nameless_range<it, false>
{
it _begin;
it _end;
friend nameless_range<it, true>;
public:
using associated_iterator = it;
nameless_range() = delete;
template<typename othT>
nameless_range(const nameless_range<othT>& oth)
: _begin(oth._begin)
, _end(oth._end)
{}
nameless_range(it sbegin, it send)
: _begin(sbegin)
, _end(send)
{}
it begin() const
{
return _begin;
}
it end() const
{
return _end;
}
};
template<typename it>
class nameless_range<it, true> : public nameless_range<it, false>
{
public:
nameless_range() = delete;
template<typename othT>
nameless_range(const nameless_range<othT>& oth)
: nameless_range<it,false>(oth._begin,oth._end)
{}
nameless_range(it sbegin, it send)
: nameless_range<it,false>(sbegin, send)
{}
std::size_t size() const
{
return this->_end-this->_begin;
}
};
}