[odb-users] Problem using <complex>
Andrew Cunningham
odb at a-cunningham.com
Fri May 5 11:12:27 EDT 2023
Hi Boris,
Yes, that would be a workable solution.
The latest ODB 2.5 does not have this issue, I'll probably just do the
upgrade for the older version. It should be painless.
Andrew
On Fri, May 5, 2023 at 3:50 AM Boris Kolpackov <boris at codesynthesis.com> wrote:
>
> Andrew Cunningham <odb at a-cunningham.com> writes:
>
> > Whenever I include <complex> in a header file to be processed by ODB
> > I get many of the following types of errors. I will be making the
> > complex data member persistent.
> >
> > [...]
> >
> > I have been unable to come up with a workaround so far.
>
> If upgrading to a later version of ODB is not an option here, I would
> probably resort to emulating std::complex during the ODB compilation.
> Something along these lines:
>
> #ifndef ODB_COMPILER
> # include <complex>
> #else
> namespace std
> {
> template <typename T>
> class complex
> {
> T re_;
> T im_;
>
> public:
> using value_type = T;
>
> complex(T re = T(), T im = T()): re_ (re), im_ (im) {}
>
> complex(const complex&) = default;
> complex& operator=(const complex&) = default;
>
> T real() const {return re_;}
> void real(T re) {re_ = re;}
> T imag() const {return im_;}
> void imag(T im) {im_ = im;};
> };
> }
> #endif
>
> You may also need to #ifdef-out any inline code that requires a proper
> definition std::complex based on the ODB_COMPILER macro.
More information about the odb-users
mailing list