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 type conversion to row::get() #1127

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions include/soci/row.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class SOCI_DECL row
template <typename T>
inline void add_holder(T* t, indicator* ind)
{
holders_.push_back(new details::type_holder<T>(t));
holders_.push_back(details::holder::make_holder(t));
indicators_.push_back(ind);
}

Expand All @@ -78,7 +78,8 @@ class SOCI_DECL row
typedef typename type_conversion<T>::base_type base_type;
static_assert(details::can_use_from_base<type_conversion<T>>(),
"Can't use row::get() with this type (not convertible/copy-assignable from base_type) - did you mean to use move_as?");
base_type const& baseVal = holders_.at(pos)->get<base_type>();
base_type const& baseVal =
holders_.at(pos)->get<base_type>(details::value_cast_tag{});

T ret;
type_conversion<T>::from_base(baseVal, *indicators_.at(pos), ret);
Expand All @@ -91,7 +92,8 @@ class SOCI_DECL row
typedef typename type_conversion<T>::base_type base_type;
static_assert(details::can_use_move_from_base<T, base_type>(),
"row::move_as() can only be called with types that can be instantiated from a base type rvalue reference");
base_type & baseVal = holders_.at(pos)->get<base_type>();
base_type & baseVal =
holders_.at(pos)->get<base_type>(details::value_reference_tag{});

T ret;
type_conversion<T>::move_from_base(baseVal, *indicators_.at(pos), ret);
Expand Down
1 change: 0 additions & 1 deletion include/soci/soci-platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
//base class must have dll interface
#pragma warning(disable:4251 4275)


// Define if you have the vsnprintf variants.
#if _MSC_VER < 1500
# define vsnprintf _vsnprintf
Expand Down
Loading