From a2f2ed9cefbe206310158e45c57307dbe331bc14 Mon Sep 17 00:00:00 2001 From: mcopik Date: Sun, 20 Aug 2017 15:04:27 +0200 Subject: [PATCH] Add missing files --- .gitignore | 3 + include/generator/properties/constant.hpp | 74 +++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 include/generator/properties/constant.hpp diff --git a/.gitignore b/.gitignore index 4581ef2..2f197b3 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ *.exe *.out *.app + +cmake-build-* +.idea diff --git a/include/generator/properties/constant.hpp b/include/generator/properties/constant.hpp new file mode 100644 index 0000000..1e04afd --- /dev/null +++ b/include/generator/properties/constant.hpp @@ -0,0 +1,74 @@ +// Copyright (c) 2017 Marcin Copik +// +// 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) + +#ifndef LINALG_PROPERTIES_ZEROS_HPP +#define LINALG_PROPERTIES_ZEROS_HPP + +#include + +#include +#include +#include + +namespace generator { namespace property { + + // look for the first object + namespace detail { + + template + struct is_const_property : std::false_type {}; + template<> + struct is_const_property : std::true_type {}; + template<> + struct is_const_property : std::true_type {}; + template<> + struct is_const_property : std::true_type {}; + + template + auto call(Property && x, Properties &&...) + -> typename std::enable_if< is_const_property::value, double>::type + { + return x.fill_value; + } + + template + auto call(Property &&, Properties &&... props) + -> typename std::enable_if< !is_const_property::value, double>::type + { + return call(std::forward(props)...); + } + + template + struct constant_generator + { + template + static void fill(Shape && shape, RndGen &&, Properties &&... props) + { + T val = static_cast(call(std::forward(props)...)); + detail::fill(std::forward(shape), + [&]() { return val; } + ); + } + }; + } + + template + struct property; + + template + struct property()> : detail::constant_generator + {}; + + template + struct property()> : detail::constant_generator + {}; + + template + struct property()> : detail::constant_generator + {}; + +}} + +#endif //LINALG_TESTS_ZEROS_HPP