-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
I have an AutoVector<T> template class in our codebase which inherits publicly from std::vector<T*> and handles ownership (created before the days of C++11).
I've noticed that I get compiler errors when I try to have an instance of this type implicitly convert to the associated span type, for example, something like
namespace Simba { namespace Support { class SqlTypeMetadata; } }
void UseMeta(simba_thirdparty_tcb::span<const Foo* const> meta);
void bar()
{
AutoVector<Foo> meta(GetMeta());
UseMeta(meta); // error C2440: 'return': cannot convert from 'Simba::Support::AutoVector<Simba::Support::SqlTypeMetadata>' to 'simba_thirdparty_tcb::span<const Simba::Support::SqlTypeMetadata *const ,18446744073709551615>'
// UseMeta({ meta.data(), meta.size() }); // This works
}
similar code works fine when using std::vector<T*> directly. Looking at the C++20 std::span documentation, this should work as long as the AutoVector<T> type models the Range concept, and I think if std::vector does, so should a subclass (that doesn't explicitly delete any member functions)?
I'm having the problem in Visual Studio 2019, haven't tried any other compilers/platforms yet.
Metadata
Metadata
Assignees
Labels
No labels