Re: InvalidOid & C++

From: "Jeroen T(dot) Vermeulen" <jtv(at)xs4all(dot)nl>
To: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: InvalidOid & C++
Date: 2003-03-18 17:00:19
Message-ID: 20030318170019.GB32109@xs4all.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

On Tue, Mar 18, 2003 at 01:54:17AM +0000, Nigel J. Andrews wrote:
>
> > How widespread is Oid(0) in C++? I have never seen anything like that.
> > It looks like a function call!
>
> It is, sort of, probably. Looks like a constructor of an instance of type
> Oid. Certainly valid C++ I think, at least I'm sure something like
> int(0) should work but then this is trawling through my memory somewhat.

That's right, it's a perfectly normal constructor. This is the standard
way of converting one type into another without going to such radical
measures as casting.

> As I don't know anything about this old style cast warning I can't say
> which is supposed to be more acceptable.

C++ introduces new types of casts that are more specialized and well-defined
than the C-style "sledgehammer" casts:

const_cast<type>(value) // (add/remove consts)
static_cast<type>(value)
dynamic_cast<type>(value)
reinterpret_cast<type>(value) // (nasty)

In this case, however, no cast is required since an Oid can simply be
constructed from the number 0. This is standard. Perfectly normal.
Everyday practice. Straight out of the manual, both now and 15 years
ago. Nothing unusual. Acceptable in polite conversation. Probably
legal in most countries of the world. Non-carcinogenic. Safe for
children of all ages. No assembly required. Full warranty. No
strings attached. Safe.

Jeroen

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2003-03-18 17:21:19 Re: InvalidOid & C++
Previous Message Bruce Momjian 2003-03-18 14:34:53 Re: XML ouput for psql