-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Reduce duplication in rate helpers constructors #1911
Reduce duplication in rate helpers constructors #1911
Conversation
I would further remove duplication by having all the constructors taking a |
I thought of that, but wasn't sure if we want to keep the optimization of not registering to the handle. There are a few ways we can try to preserve it if we care. We could also use |
I don't think the optimization is really an optimization, so I wouldn't put any effort into preserving it. A variant looks way too much clever to me—if we want to reduce the overloads, we can deprecate the ones taking a double and add a convenience function like, for instance,
|
Variant is actually very easy. We typedef it to something like |
I do agree with adding the convenience function. In one version of this PR I wrote it under |
I don't doubt the variant is easy to add, but I'm not sure it's common vocabulary yet. Anyway—we can reduce duplication and keep the 2x constructors in this PR, and think about it later. |
A related question: some of the duplication is because some constructors create an IborIndex from scratch while others clone an existing index. We can remove the duplication by making the former call the latter if we don't mind the cost of the extra clone. We may be able to avoid the clone with some if check. |
Ok for me. Again, if the instrument underlying the helper asks for an index, in the long run it's probably better for the helper to take an index, not the stuff to build an index, so we can deprecate the constructor taking the latter. |
24309ab
to
cef64cc
Compare
@lballabio I left the indexes for now, but made the other changes. |
Thanks! I made a few more changes: I used the convenience method in a few examples, turned it into a method for brevity, and made it return a relinkable handle (not needed in the helpers, but possibly in other use cases). |
I think the name |
Another option is we can make an implicit conversion operator from |
Hmm, I didn't want it to be too long to write. Oh well, I'll let it rest over the weekend and come back with a fresh mind—hopefully. |
I settled on |
This makes sense to me. |
No description provided.