view: add validator specialisation
This commit is contained in:
parent
88df4459f0
commit
c24b0fd0f7
33
view.hpp
33
view.hpp
@ -3,18 +3,17 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 2015-2018 Danny Robson <danny@nerdcruft.net>
|
||||
* Copyright 2015-2019 Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRUFT_UTIL_VIEW_HPP
|
||||
#define CRUFT_UTIL_VIEW_HPP
|
||||
#pragma once
|
||||
|
||||
#include "annotation.hpp"
|
||||
#include "cast.hpp"
|
||||
#include "types/traits.hpp"
|
||||
#include "debug.hpp"
|
||||
#include "maths.hpp"
|
||||
#include "platform.hpp"
|
||||
#include "types/traits.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iosfwd>
|
||||
@ -893,9 +892,25 @@ namespace cruft {
|
||||
|
||||
return res < 0 || (res == 0 && la < lb);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
namespace cruft::debug {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename IteratorT, typename ...ArgsT>
|
||||
struct validator<
|
||||
view<IteratorT>,
|
||||
ArgsT&&...
|
||||
> {
|
||||
static bool
|
||||
is_valid (view<IteratorT> data, ArgsT &&...args)
|
||||
{
|
||||
return std::all_of (
|
||||
std::begin (data),
|
||||
std::end (data),
|
||||
[&] (auto const &i)
|
||||
{
|
||||
return ::cruft::debug::is_valid (i, args...);
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user