Mirror reflection library - Lagoon run-time layer 0.5.13

lagoon/range/transform.hpp

Go to the documentation of this file.
00001 
00010 #ifndef LAGOON_RANGE_TRANSFORM_1011291729_HPP
00011 #define LAGOON_RANGE_TRANSFORM_1011291729_HPP
00012 
00013 #include <lagoon/lagoon_fwd.hpp>
00014 #include <cassert>
00015 
00016 LAGOON_NAMESPACE_BEGIN
00017 
00018 namespace aux {
00019 
00020 template <class Range, typename Transform>
00021 struct transformed
00022 {
00023 private:
00024     Range range;
00025     Transform transform;
00026 public:
00027     transformed(transformed&& other)
00028      : range(std::move(other.range))
00029      , transform(std::move(other.transform))
00030     { }
00031 
00032     transformed(const transformed& other)
00033      : range(other.range)
00034      , transform(other.transform)
00035     { }
00036 
00037     transformed(const Range& rng, const Transform& transf)
00038      : range(rng)
00039      , transform(transf)
00040     { }
00041 
00042     transformed(Range&& rng, Transform&& transf)
00043      : range(std::forward(rng))
00044      , transform(std::forward(transf))
00045     { }
00046 
00047     inline bool empty(void) const
00048     {
00049         return range.empty();
00050     }
00051 
00052     inline void step_front(void)
00053     {
00054         range.step_front();
00055     }
00056 
00057     inline size_t leap_front(size_t amount)
00058     {
00059         return range.leap_front(amount);
00060 
00061     }
00062 
00063     inline auto front(void) const -> decltype(transform(range.front()))
00064     {
00065         return transform(range.front());
00066     }
00067 
00068     friend inline bool same_position(
00069         const transformed& a,
00070         const transformed& b
00071     )
00072     {
00073         return same_position(a.range, b.range);
00074     }
00075 };
00076 
00077 } // namespace aux
00078 
00079 #ifdef MIRROR_DOCUMENTATION_ONLY
00080 
00081 
00089 template <class Range, typename Transform>
00090 UnspecifiedRange transform(Range range, Transform transf);
00091 #else
00092 template <class Range, typename Transform>
00093 inline aux::transformed<Range, Transform>
00094 transform(Range range, Transform transf)
00095 {
00096     return aux::transformed<Range, Transform>(range, transf);
00097 }
00098 #endif
00099 
00100 LAGOON_NAMESPACE_END
00101 
00102 #endif //include guard
00103 

Copyright © 2006-2011 Matus Chochlik, University of Zilina, Zilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Fri Dec 16 2011 by Doxygen (version 1.7.3).
Important note: Although the 'boostified' version of Mirror uses the Boost C++ libraries Coding Guidelines and is implemented inside of the boost namespace, it IS NOT an officially reviewed and accepted Boost library. Mirror is being developed with the intention to be submitted for review for inclusion to the Boost C++ libraries.