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

Adding data() to Vector. #3123

Merged
merged 1 commit into from
Jul 8, 2020
Merged

Adding data() to Vector. #3123

merged 1 commit into from
Jul 8, 2020

Conversation

crtrott
Copy link
Member

@crtrott crtrott commented Jun 22, 2020

Addresses issue #3077

@masterleinad
Copy link
Contributor

C:\projects\source\tpls\gtest\gtest/gtest.h(18865,1): error C2679: binary '==': no operator found which takes a right-hand operand of type 'const T2' (or there is no acceptable conversion) [C:\projects\source\build\containers\unit_tests\KokkosContainers_UnitTest_Serial.vcxproj]
          with
          [
              T2=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>
          ]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\exception(269,28): message : could be 'bool std::operator ==(const std::exception_ptr &,const std::exception_ptr &) noexcept' [found using argument-dependent lookup] [C:\projects\source\build\containers\unit_tests\KokkosContainers_UnitTest_Serial.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\exception(273,28): message : or       'bool std::operator ==(std::nullptr_t,const std::exception_ptr &) noexcept' [found using argument-dependent lookup] [C:\projects\source\build\containers\unit_tests\KokkosContainers_UnitTest_Serial.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\exception(277,28): message : or       'bool std::operator ==(const std::exception_ptr &,std::nullptr_t) noexcept' [found using argument-dependent lookup] [C:\projects\source\build\containers\unit_tests\KokkosContainers_UnitTest_Serial.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\system_error(161,28): message : or       'bool std::operator ==(const std::error_code &,const std::error_code &) noexcept' [found using argument-dependent lookup] [C:\projects\source\build\containers\unit_tests\KokkosContainers_UnitTest_Serial.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\system_error(165,28): message : or       'bool std::operator ==(const std::error_code &,const std::error_condition &) noexcept' [found using argument-dependent lookup] [C:\projects\source\build\containers\unit_tests\KokkosContainers_UnitTest_Serial.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\system_error(169,28): message : or       'bool std::operator ==(const std::error_condition &,const std::error_code &) noexcept' [found using argument-dependent lookup] [C:\projects\source\build\containers\unit_tests\KokkosContainers_UnitTest_Serial.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\system_error(243,28): message : or       'bool std::operator ==(const std::error_condition &,const std::error_condition &) noexcept' [found using argument-dependent lookup] [C:\projects\source\build\containers\unit_tests\KokkosContainers_UnitTest_Serial.vcxproj]
C:\projects\source\tpls\gtest\gtest/gtest.h(18865,1): message : or       'built-in C++ operator==(T1, T1)' [C:\projects\source\build\containers\unit_tests\KokkosContainers_UnitTest_Serial.vcxproj]
          with
          [
              T1=int *
          ]
C:\projects\source\tpls\gtest\gtest/gtest.h(18865,1): message : while trying to match the argument list '(const T1, const T2)' [C:\projects\source\build\containers\unit_tests\KokkosContainers_UnitTest_Serial.vcxproj]
          with
          [
              T1=int *
          ]
          and
          [
              T2=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>
          ]
C:\projects\source\tpls\gtest\gtest/gtest.h(18902): message : see reference to function template instantiation 'testing::AssertionResult testing::internal::CmpHelperEQ<T1,T2>(const char *,const char *,const T1 &,const T2 &)' being compiled [C:\projects\source\build\containers\unit_tests\KokkosContainers_UnitTest_Serial.vcxproj]
          with
          [
              T1=int *,
              T2=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>
          ]
C:\projects\source\containers\unit_tests\TestVector.hpp(66): message : see reference to function template instantiation 'testing::AssertionResult testing::internal::EqHelper<false>::Compare<_Ty*,std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>>(const char *,const char *,const T1 &,const T2 &)' being compiled [C:\projects\source\build\containers\unit_tests\KokkosContainers_UnitTest_Serial.vcxproj]
          with
          [
              _Ty=int,
              T1=int *,
              T2=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>
          ]

@@ -221,6 +221,8 @@ class vector : public DualView<Scalar*, LayoutLeft, Arg1Type> {
size_type span() const { return DV::span(); }
bool empty() const { return _size == 0; }

iterator data() const { return DV::h_view.data(); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you update the Synopsys in the API reference accordingly

Copy link
Contributor

@nliber nliber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of questions on this:

Shouldn't data() return pointer, not iterator? I know they are the same type in this implementation, but not in general.

Why aren't there pairs of functions for this, with the following signatures:

iterator begin()
const_iterator begin() const
iterator end()
const_iterator end() const
pointer data()
const_pointer data() const
reference operator[](int)
const_reference operator[](int) const
reference operator()(int)
const_reference operator()(int) const

It is already that way for front() and back(), but not for the above functions.

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.

None yet

4 participants