Skip to content
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

Add automatic widening conversions in dynamic bindings #1097

Closed
wants to merge 1 commit into from

Conversation

Sildra
Copy link
Contributor

@Sildra Sildra commented Oct 22, 2023

Add the ability to perform lossless conversions in the dynamic bindings.
Also add an opt-in narrowing cast with the define SOCI_WIDENING_CASTS (to be discussed).

Allow for extending the range of casts with the templated struct soci::soci_cast with the model of soci::type_conversion<T>.

@Sildra Sildra force-pushed the automatic-conversion branch 3 times, most recently from 25409e2 to 17582fc Compare October 22, 2023 15:10
@Sildra
Copy link
Contributor Author

Sildra commented Oct 22, 2023

int64_t and long long are the same under Windows and different under linux. I will either need to wait for #954 or temporarily switch to old types for the build to pass.

@Sildra
Copy link
Contributor Author

Sildra commented Oct 22, 2023

I will need to add support for a c++98 version of the metaprog templates and check if adding constexpr to the get function avoids the weird unreachable code on the statements. I can't seems to reproduce both of those issues under VS2022.

@vadz
Copy link
Member

vadz commented Oct 22, 2023

You can base this PR on #954 if it makes things simpler.

As for the unreachable code warnings (do you have a direct link?), they can be suppressed explicitly if nothing else works.

@Sildra Sildra force-pushed the automatic-conversion branch 2 times, most recently from 80479b4 to 697d384 Compare October 22, 2023 20:38
@Sildra Sildra force-pushed the automatic-conversion branch from 697d384 to 7a51edb Compare October 22, 2023 20:41
@Sildra
Copy link
Contributor Author

Sildra commented Oct 22, 2023

Only the Windows builds are missing :

  • for the 2 latest, I will silence the compiler warning,
  • for the 2 oldest, it might be because they don't have std::numeric_limits<long long>.
    Defining a generic alias for soci::numeric_limits<T> + providing specialized soci::numeric_limits<long long> might do the trick.

I will also add tests in common to check the feature.

Edit: the pre-c++11 std::numeric_limits<T> don't have a constexpr evaluation for min/max and can't participate to template resolution. I will relax template def for pre-c++11 and switch to runtime checks. I might tell the windows compiler to use the templates post-c++11 even in std=c++98 if the compiler has the possibility.

@vadz
Copy link
Member

vadz commented Jan 11, 2024

I don't think this change is compatible (semantically and not just syntactically) with the now merged #954, so I think it should probably be closed -- but please let me know if I'm missing something.

@Sildra Sildra closed this Jan 11, 2024
@Sildra Sildra deleted the automatic-conversion branch January 11, 2024 14:57
@Sildra
Copy link
Contributor Author

Sildra commented Jan 11, 2024

I will check the changes proposed by the new types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants