view: add validator specialisation

This commit is contained in:
Danny Robson 2019-01-29 21:21:18 +11:00
parent 88df4459f0
commit c24b0fd0f7

View File

@ -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...);
});
}
};
};