diff --git a/sprout/adapt/std/complex.hpp b/sprout/adapt/std/complex.hpp new file mode 100644 index 00000000..66f282aa --- /dev/null +++ b/sprout/adapt/std/complex.hpp @@ -0,0 +1,17 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + 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 SPROUT_ADAPT_STD_COMPLEX_HPP +#define SPROUT_ADAPT_STD_COMPLEX_HPP + +#include +#include +//#include +#include +#include + +#endif // #ifndef SPROUT_ADAPT_STD_COMPLEX_HPP diff --git a/sprout/functional/hash/std/complex.hpp b/sprout/functional/hash/std/complex.hpp new file mode 100644 index 00000000..94d100ad --- /dev/null +++ b/sprout/functional/hash/std/complex.hpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + 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 SPROUT_FUNCTIONAL_HASH_STD_COMPLEX_HPP +#define SPROUT_FUNCTIONAL_HASH_STD_COMPLEX_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // hash_value + // + template + inline SPROUT_CONSTEXPR std::size_t + hash_value(std::complex const& v) { + return sprout::hash_values(v.real(), v.imag()); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_HASH_STD_COMPLEX_HPP diff --git a/sprout/tuple/std/complex.hpp b/sprout/tuple/std/complex.hpp new file mode 100644 index 00000000..9c63654f --- /dev/null +++ b/sprout/tuple/std/complex.hpp @@ -0,0 +1,129 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + 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 SPROUT_TUPLE_STD_COMPLEX_HPP +#define SPROUT_TUPLE_STD_COMPLEX_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace tuples { + namespace detail { + template + struct tuple_element_impl; + template + struct tuple_element_impl > + : public sprout::detail::nil_base + {}; + template + struct tuple_element_impl<0, std::complex > + : public sprout::identity + {}; + template + struct tuple_element_impl<1, std::complex > + : public sprout::identity + {}; + + template + struct get_impl; + template + struct get_impl<0, std::complex > { + public: + SPROUT_CONSTEXPR T operator()(std::complex const& t) const { + return t.real(); + } + }; + template + struct get_impl<1, std::complex > { + public: + SPROUT_CONSTEXPR T operator()(std::complex const& t) const { + return t.imag(); + } + }; + } // namespace detail + } // namespace tuples +} // namespace sprout + +namespace sprout { + namespace tuples { + // + // tuple_size + // + template + struct tuple_size > + : public sprout::integral_constant + {}; + + // + // tuple_element + // + template + struct tuple_element > + : public sprout::tuples::detail::tuple_element_impl > + {}; + } // namespace tuples +} // namespace sprout + +namespace sprout { + namespace tuples { + // + // tuple_traits + // + template + struct tuple_traits > { + public: + SPROUT_STATIC_CONSTEXPR std::size_t size = sprout::tuples::tuple_size >::value; + public: + template + struct element + : public sprout::tuples::tuple_element > + {}; + template + struct lvalue_reference + : public element + {}; + template + struct const_lvalue_reference + : public element + {}; + template + struct rvalue_reference + : public element + {}; + template + struct const_rvalue_reference + : public element + {}; + }; + template + SPROUT_CONSTEXPR_OR_CONST std::size_t sprout::tuples::tuple_traits >::size; + + // + // tuple_access_traits + // + template + struct tuple_access_traits > { + public: + template + static SPROUT_CONSTEXPR T + tuple_get(std::complex const& t) SPROUT_NOEXCEPT { + static_assert(I < 2, "tuple_get: index out of range"); + return sprout::tuples::detail::get_impl >()(t); + } + }; + } // namespace tuples +} // namespace sprout + +#endif // #ifndef SPROUT_TUPLE_STD_COMPLEX_HPP