B
Brian
I've been working on adding support for std::complex to the C++
Middleware Writer -- http://webEbenezer.net/build_integration.html.
So far this is what I have:
template <typename T>
void
complexCount(Counter& cntr, std::complex<T> const& cmplx)
{
cntr.Add(sizeof(T) * 2);
}
template <typename B, typename T>
void
complexSend(B* buf, std::complex<T> const& cmplx)
{
T real = cmplx.real();
buf->Receive(&real, sizeof(T));
T imaginary = cmplx.imag();
buf->Receive(&imaginary, sizeof(T));
}
template <typename B, typename T>
void
complexReceive(B* buf, std::complex<T>& cmplx)
{
T real, imaginary;
buf->Give(real);
cmplx.real(real);
buf->Give(imaginary);
cmplx.imag(imaginary);
}
Both the send and receive functions are suboptimal due
to the marshalling being done externally. Is there interest
in having this common type retrofitted for marshalling?
To my knowledge the C++ Middleware Writer offers the
most efficient marshalling approach available today. I
would like to ask that some accommodations be made
wrt to the standard so as to allow people to marshall
instances of this common type more efficiently than
is possible with the current standard.
If complex were given a stream constructor, rather
than needing complexReceive we would have
something like this:
template <typename B>
explicit complex(B* buf)
{
buf->Give(real_);
buf->Give(imag_);
}
where real_ and imag_ are the names of the private
data members of the complex type.
The C++ Middleware Writer could implement the
constructor based on reading the complex header,
but it would be necessary to add a prototype to
the header --
template <typename B>
explicit complex(B*);
Alternatively it could be --
template <typename B>
explicit complex(B&);
if that were thought to be more appropriate. I'm aware
of comp.std.c++ and may post something there if there
is some interest here.
Brian Wood
http://webEbenezer.net
(651) 251-9384
When a man's ways please the L-RD, He makes
even his enemies to be at peace with him. Proverbs 16:7
Middleware Writer -- http://webEbenezer.net/build_integration.html.
So far this is what I have:
template <typename T>
void
complexCount(Counter& cntr, std::complex<T> const& cmplx)
{
cntr.Add(sizeof(T) * 2);
}
template <typename B, typename T>
void
complexSend(B* buf, std::complex<T> const& cmplx)
{
T real = cmplx.real();
buf->Receive(&real, sizeof(T));
T imaginary = cmplx.imag();
buf->Receive(&imaginary, sizeof(T));
}
template <typename B, typename T>
void
complexReceive(B* buf, std::complex<T>& cmplx)
{
T real, imaginary;
buf->Give(real);
cmplx.real(real);
buf->Give(imaginary);
cmplx.imag(imaginary);
}
Both the send and receive functions are suboptimal due
to the marshalling being done externally. Is there interest
in having this common type retrofitted for marshalling?
To my knowledge the C++ Middleware Writer offers the
most efficient marshalling approach available today. I
would like to ask that some accommodations be made
wrt to the standard so as to allow people to marshall
instances of this common type more efficiently than
is possible with the current standard.
If complex were given a stream constructor, rather
than needing complexReceive we would have
something like this:
template <typename B>
explicit complex(B* buf)
{
buf->Give(real_);
buf->Give(imag_);
}
where real_ and imag_ are the names of the private
data members of the complex type.
The C++ Middleware Writer could implement the
constructor based on reading the complex header,
but it would be necessary to add a prototype to
the header --
template <typename B>
explicit complex(B*);
Alternatively it could be --
template <typename B>
explicit complex(B&);
if that were thought to be more appropriate. I'm aware
of comp.std.c++ and may post something there if there
is some interest here.
Brian Wood
http://webEbenezer.net
(651) 251-9384
When a man's ways please the L-RD, He makes
even his enemies to be at peace with him. Proverbs 16:7