Skip to content

Commit

Permalink
Add MSVC version, support for ASAN
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Nov 5, 2024
1 parent bd11572 commit 0e6ebfc
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion include/tao/pq/internal/resize_uninitialized.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace tao::pq::internal
template struct string_proxy< std::string, &std::string::_Eos >;

#else
#error "No implementation for resize_uninitialized available."
#error "No implementation for resize_uninitialized for std::string available on this platform."
#endif

#if defined( _LIBCPP_VECTOR )
Expand All @@ -92,11 +92,37 @@ namespace tao::pq::internal
friend void resize_uninitialized_proxy( T& v, const std::size_t n ) noexcept
{
v.*M = v.data() + n; // v.__end_ = v.data() + n;

#ifndef _LIBCPP_HAS_NO_ASAN
__sanitizer_annotate_contiguous_container( v.data(),
v.data() + v.capacity(),
v.data() + v.size(),
v.data() + n );
#endif
}
};

template struct vector_proxy< std::vector< std::byte >, &std::vector< std::byte >::__end_ >;

#elif defined( _MSC_VER )

void resize_uninitialized_proxy( std::vector< std::byte >& v, const std::size_t n ) noexcept;

template< typename T, auto Mypair, auto Myval2, auto Mylast >
struct vector_proxy
{
friend void resize_uninitialized_proxy( T& v, const std::size_t n ) noexcept
{
// v._Mypair._Myval2._Mylast += ( n - v.size() );
v.*Mypair.*Myval2.*Mylast += ( n - v.size() );
}
};

template struct vector_proxy< std::vector< std::byte >,
&std::vector< std::byte >::_Mypair,
&decltype( std::declval< std::vector< std::byte > >()._Mypair )::_Myval2,
&decltype( std::declval< std::vector< std::byte > >()._Mypair._Myval2 )::_Mypair >;

#else

// generic version
Expand Down

0 comments on commit 0e6ebfc

Please sign in to comment.