This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: something that would be nice


"Matt Wells" <mwells@gigablast.com> writes:

| Gabriel, Thanks for the response!
| But having to define a Result struct for each of my functions
| does not simplify things.

That is why I alluded to temlates (C++)

  template<class T>
    Faillible {
     T value;
     int status;
     Faillible(const T& v, int s) : value(v), status(s) { }
    };

  template<class T>
    inline Faillible<T> result(const T& t, int s)
    { return Faillible<T>(t, s); }

| I think it actually is more complicated
| and messy than passing in pointers as parameters.

If you don't like templates, you can approximate the above with macro
hackery 

| The code you added below undoubtedly works, but it
| doubles the number of lines and makes things a lot more
| confusing to look at. I have hundreds of these functions
| and I'd prefer not to have to declare a Results structure 
| for each one.

I would suggest use of templates or macro hackery.

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]