C++ namespace question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

C++ namespace question

Rik-4
I need a little C++ help.  I'm deprecating is_NA in favor of isna within
the octave::math namespace.  The modified code in lo-mappers.h is

namespace octave
{
  namespace math
  {
    extern OCTAVE_API bool isna (double x);
    OCTAVE_DEPRECATED (4.4, "use 'octave::math::isna' instead")
    inline bool is_NA (double x) { return isna (x); }

    extern OCTAVE_API bool isna (float x);
    OCTAVE_DEPRECATED (4.4, "use 'octave::math::isna' instead")
    inline bool is_NA (float x) { return octave::math::isna (x); }

In one case, I wrote the inline substitute function without using the
namespace prefix, in the other I kept the prefix.  The code compiles fine,
but which is preferred?

--Rik

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: C++ namespace question

John W. Eaton
Administrator
On 06/16/2017 12:38 PM, Rik wrote:

> I need a little C++ help.  I'm deprecating is_NA in favor of isna within
> the octave::math namespace.  The modified code in lo-mappers.h is
>
> namespace octave
> {
>   namespace math
>   {
>     extern OCTAVE_API bool isna (double x);
>     OCTAVE_DEPRECATED (4.4, "use 'octave::math::isna' instead")
>     inline bool is_NA (double x) { return isna (x); }
>
>     extern OCTAVE_API bool isna (float x);
>     OCTAVE_DEPRECATED (4.4, "use 'octave::math::isna' instead")
>     inline bool is_NA (float x) { return octave::math::isna (x); }
>
> In one case, I wrote the inline substitute function without using the
> namespace prefix, in the other I kept the prefix.  The code compiles fine,
> but which is preferred?

I don't guess it matters in this case since the base name is changing as
well, but maybe use the namespace tag just to be clear and avoid any
confusion?

If the base name is the same, say "isna" both inside and outside the
namespace , then the tag is obviously required.

jwe



Loading...