From e0629a21cef335d74885789de6477a2e18e7c2a4 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Thu, 17 Oct 2013 18:46:31 +0900 Subject: [PATCH] support Generator Requirement: generator_iterator, random_redult --- sprout/iterator/generator_iterator.hpp | 3 +++ sprout/random/random_result.hpp | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/sprout/iterator/generator_iterator.hpp b/sprout/iterator/generator_iterator.hpp index 84a25cfd..0962b5c8 100644 --- a/sprout/iterator/generator_iterator.hpp +++ b/sprout/iterator/generator_iterator.hpp @@ -72,6 +72,9 @@ namespace sprout { SPROUT_CONSTEXPR generator_iterator next_generator() const { return (*this)(); } + SPROUT_CONSTEXPR operator reference() const { + return generated_value(); + } SPROUT_CXX14_CONSTEXPR void swap(generator_iterator& other) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(gen_, other.gen_))) { diff --git a/sprout/random/random_result.hpp b/sprout/random/random_result.hpp index 7ec968bf..b6a17042 100644 --- a/sprout/random/random_result.hpp +++ b/sprout/random/random_result.hpp @@ -114,6 +114,12 @@ namespace sprout { SPROUT_CONSTEXPR distribution_type const& distribution() const SPROUT_NOEXCEPT { return distribution_; } + SPROUT_CXX14_CONSTEXPR operator result_type&() SPROUT_NOEXCEPT { + return generated_value(); + } + SPROUT_CONSTEXPR operator result_type const&() const SPROUT_NOEXCEPT { + return generated_value(); + } SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT { return distribution_.min(); } @@ -233,6 +239,12 @@ namespace sprout { SPROUT_CONSTEXPR random_result const& next_generator() const SPROUT_NOEXCEPT { return *this; } + SPROUT_CXX14_CONSTEXPR operator result_type&() SPROUT_NOEXCEPT { + return generated_value(); + } + SPROUT_CONSTEXPR operator result_type const&() const SPROUT_NOEXCEPT { + return generated_value(); + } SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT { return engine_.min(); }