2012-12-03 12:48:50 +00:00
|
|
|
#ifndef SPROUT_COMPOST_FORMATS_AS_COMPLEX_HPP
|
|
|
|
#define SPROUT_COMPOST_FORMATS_AS_COMPLEX_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/complex.hpp>
|
|
|
|
#include <sprout/utility/forward.hpp>
|
|
|
|
#include <sprout/range/adaptor/transformed.hpp>
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace compost {
|
|
|
|
//
|
|
|
|
// to_complex_value
|
|
|
|
//
|
|
|
|
struct to_complex_value {
|
|
|
|
public:
|
|
|
|
template<typename FloatType>
|
|
|
|
SPROUT_CONSTEXPR sprout::complex<FloatType> operator()(FloatType const& x) const {
|
|
|
|
return sprout::complex<FloatType>(x);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace formats {
|
|
|
|
//
|
|
|
|
// as_complex_forwarder
|
|
|
|
//
|
|
|
|
class as_complex_forwarder {};
|
|
|
|
|
|
|
|
//
|
|
|
|
// as_complex
|
|
|
|
//
|
|
|
|
namespace {
|
2012-12-17 14:10:23 +00:00
|
|
|
SPROUT_STATIC_CONSTEXPR sprout::compost::formats::as_complex_forwarder as_complex = {};
|
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_complex_forwarder const&)
|
2012-12-03 12:48:50 +00:00
|
|
|
-> decltype(
|
|
|
|
sprout::forward<Range>(lhs)
|
|
|
|
| sprout::adaptors::transformed(sprout::compost::to_complex_value())
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::forward<Range>(lhs)
|
|
|
|
| sprout::adaptors::transformed(sprout::compost::to_complex_value())
|
|
|
|
;
|
|
|
|
}
|
|
|
|
} // namespace formats
|
|
|
|
|
|
|
|
using sprout::compost::formats::as_complex;
|
|
|
|
} // namespace compost
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_COMPOST_FORMATS_AS_COMPLEX_HPP
|