-
-
Notifications
You must be signed in to change notification settings - Fork 717
update stdcomplex wrapping #5748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Simplifies the code and prevents std::complex
for that are not supported by c++.
• cppreference std::complex (template parameter requirements):
Notes that behavior is unspecified (and may fail to compile) if T is not
a (cv-unqualified) floating-point type. 
• Apache STDCXX user guide <complex> (older but explicit):
States the template argument “must be” one of
- float,
- double, or
- long double
Non cv-qualified types may compile on some standard libraries, fail on
others, and semantics are not guaranteed by the standard. The only fully
supported specializations are the floating-point ones.
This code seems to no longer be needed with newer swig wrappings.
dzenanz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good upon cursory review.
| else: | ||
| assert ( | ||
| False | ||
| ), f"Unknown stdcomplex type: {typedef.name}, only D and F are supported." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ), f"Unknown stdcomplex type: {typedef.name}, only D and F are supported." | |
| ), f"Unknown stdcomplex type: {typedef.name}, only LD, D, and F are supported." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dzenanz I did into want to change this. I am looking at removing all LD support.
Implications for an automated wrapping pipeline (e.g., ITK/CastXML/SWIG)
Conclusion from references:
• SWIG’s own documentation does not support long double out of the box and treats it as unsupported. 
• There is active ongoing concern in the SWIG community about long double handling. 
• Scripting languages (Python, etc.) map floating types to double, not long double, so the practical utility of exposing long double wrappers is low. 
Therefore, the conservative/widely practiced advice is:
• Do not generate SWIG bindings for long double automatically.
• Prefer double versions of functions if available.
• Only expose long double if you write explicit custom typemaps and verify target support.
This is effectively equivalent to a blacklist approach for automatically wrapping long double in a general automation pipeline.
thewtex
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Hans!
|
\azp run ITK.macOS.Python |
STYLE: Simplify std::complex wrapping
PR Checklist