2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2016-02-25 09:48:28 +00:00
|
|
|
Copyright (c) 2011-2016 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
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)
|
|
|
|
=============================================================================*/
|
2012-12-03 12:48:50 +00:00
|
|
|
#ifndef SPROUT_COMPOST_FORMATS_AS_REAL_HPP
|
|
|
|
#define SPROUT_COMPOST_FORMATS_AS_REAL_HPP
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/complex.hpp>
|
|
|
|
#include <sprout/utility/forward.hpp>
|
|
|
|
#include <sprout/range/adaptor/transformed.hpp>
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace compost {
|
|
|
|
//
|
|
|
|
// to_real_value
|
|
|
|
//
|
|
|
|
struct to_real_value {
|
|
|
|
public:
|
|
|
|
template<typename Complex>
|
|
|
|
SPROUT_CONSTEXPR decltype(real(std::declval<Complex const&>())) operator()(Complex const& x) const {
|
|
|
|
return real(x);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace formats {
|
|
|
|
//
|
|
|
|
// as_real_forwarder
|
|
|
|
//
|
|
|
|
class as_real_forwarder {};
|
|
|
|
|
|
|
|
//
|
|
|
|
// as_real
|
|
|
|
//
|
|
|
|
namespace {
|
2012-12-17 14:10:23 +00:00
|
|
|
SPROUT_STATIC_CONSTEXPR sprout::compost::formats::as_real_forwarder as_real = {};
|
2012-12-03 12:48:50 +00:00
|
|
|
} // anonymous-namespace
|
|
|
|
|
|
|
|
//
|
|
|
|
// operator|
|
|
|
|
//
|
|
|
|
template<typename Range>
|
|
|
|
inline SPROUT_CONSTEXPR auto
|
2013-07-22 13:00:09 +00:00
|
|
|
operator|(Range&& lhs, sprout::compost::formats::as_real_forwarder const&)
|
2012-12-03 12:48:50 +00:00
|
|
|
-> decltype(
|
2014-02-22 07:32:51 +00:00
|
|
|
SPROUT_FORWARD(Range, lhs)
|
2012-12-03 12:48:50 +00:00
|
|
|
| sprout::adaptors::transformed(sprout::compost::to_real_value())
|
|
|
|
)
|
|
|
|
{
|
2014-02-22 07:32:51 +00:00
|
|
|
return SPROUT_FORWARD(Range, lhs)
|
2012-12-03 12:48:50 +00:00
|
|
|
| sprout::adaptors::transformed(sprout::compost::to_real_value())
|
|
|
|
;
|
|
|
|
}
|
|
|
|
} // namespace formats
|
|
|
|
|
|
|
|
using sprout::compost::formats::as_real;
|
|
|
|
} // namespace compost
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_COMPOST_FORMATS_AS_REAL_HPP
|