#include <iostream>
#include <string>

template <class In, class Out>
struct Pipe
{
	typedef In in_type ;
	typedef Out out_type ;

	In in_val ;

	Pipe (const in_type &in_val = in_type()) : in_val (in_val)
	{
	}

	virtual auto operator () () const -> out_type
	{
		return out_type () ;
	}
};

template <class In, class Out, class Out2>
auto operator>> (const Pipe <In, Out> &lhs, Pipe <Out, Out2> &rhs) -> Pipe <Out, Out2>&
{
	rhs = lhs () ;
	return rhs ;
}

template <class In, class Out>
auto operator>> (const Pipe <In, Out> &lhs, Out &rhs) -> Out&
{
	rhs = lhs () ;
	return rhs ;
}

struct StringToInt : public Pipe <std::string, int>
{
	StringToInt (const std::string &s = "") : Pipe <in_type, out_type> (s)
	{
	}

	auto operator () () const -> out_type
	{
		return std::stoi (in_val) ;
	}
};

struct IntSquare : public Pipe <int, int>
{
	IntSquare (int n = 0) : Pipe <in_type, out_type> (n)
	{
	}

	auto operator () () const -> out_type
	{
		return in_val * in_val ;
	}
};

struct DivideBy42F : public Pipe <int, float>
{
	DivideBy42F (int n = 0) : Pipe <in_type, out_type> (n)
	{
	}

	auto operator () () const -> out_type
	{
		return static_cast <float> (in_val) / 42.0f ;
	}
};

int main ()
{
	float out = 0 ;
	StringToInt ("42") >> IntSquare () >> DivideBy42F () >> out ;
	std::cout << out << "\n" ;

	return 0 ;
}
