Closed fnrizzi closed 1 year ago
@fnrizzi Based on the following observations:
std::is_pointer
is redundant as it's covered by std::is_class
(pointers and refs are not classes)pressio::mpl::is_std_shared_ptr
is redundant as it's covered by pressio::Traits::<basis_matrix_type>::rank == 2
, because std::shared_ptr
won't normally have pressio::Traits
defined (i.e. unless someone is hacking the API...)we can reduce the constraints to the conjunction of:
std::is_class<basis_matrix_type>::value == true
std::is_copy_constructible<basis_matrix_type>::value == true
::pressio::Traits<basis_matrix_type>::rank == 2
Not sure if it makes sense, but theoretically things could be even simpler if we skipped std::remove_cv
altogether, used BasisMatrixType
directly in the constraints and maybe restricted it with !std::is_const_v<BasisMatrixType> && !std::is_volatile_v<BasisMatrixType>
:
BasisMatrixType
with const
shouldn't really hurt in any case, but I'm not 100% sure.BasisMatrixType
with volatile
fails std::is_copy_constructible
- unless it defines BasisMatrixType(const volatile BasisMatrixType&)
constructor (see [here](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:65,endLineNumber:10,positionColumn:65,positionLineNumber:10,selectionStartColumn:65,selectionStartLineNumber:10,startColumn:65,startLineNumber:10),source:'%23include+%3Ctype_traits%3E%0A%0Astruct+A+%7B%0A++++A()+%3D+default%3B%0A++++//+A(const+volatile+A%26)+%7B%7D%3B%0A%7D%3B%0A%0Aint+main()+%7B%0A++++using+T+%3D+volatile+A%3B%0A++++//+static_assert(std::is_copy_constructible_v%3CT%3E,+%22%22)%3B++++++//+fails%0A++++//+static_assert(std::is_constructible_v%3CT,+const+T%26%3E,+%22%22)%3B+//+fails%0A++++T+x%3B%0A++++T+y%7Bx%7D%3B+//+error:+no+matching+function+for+call+to+!'A(const+volatile+T%26)!'%0A%0A++++return+0%3B%0A%7D'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:51.730894839973864,l:'4',m:100,n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:g122,deviceViewOpen:'1',filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'-O2',selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+gcc+12.2+(Editor+%231)',t:'0')),header:(),k:33.88240082531392,l:'4',m:35.827338129496404,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+gcc+12.2',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+gcc+12.2+(Compiler+%231)',t:'0')),header:(),l:'4',m:64.17266187050359,n:'0',o:'',s:0,t:'0')),k:48.26910516002612,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)) - so normally it's not allowed anyway (e.g. no such volatile
constructors in Eigen, Kokkos and Trilinos).we can reduce the constraints to the conjunction of:
std::is_class<basis_matrix_type>::value == true
std::is_copy_constructible<basis_matrix_type>::value == true
::pressio::Traits<basis_matrix_type>::rank == 2
yes that makes sense, can you please make a PR for this?
Not sure if it makes sense, but theoretically things could be even simpler if we skipped
std::remove_cv
altogether, usedBasisMatrixType
directly in the constraints and maybe restricted it with!std::is_const_v<BasisMatrixType> && !std::is_volatile_v<BasisMatrixType>
:
BasisMatrixType
withconst
shouldn't really hurt in any case, but I'm not 100% sure.BasisMatrixType
withvolatile
failsstd::is_copy_constructible
- unless it definesBasisMatrixType(const volatile BasisMatrixType&)
constructor (see [here](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:65,endLineNumber:10,positionColumn:65,positionLineNumber:10,selectionStartColumn:65,selectionStartLineNumber:10,startColumn:65,startLineNumber:10),source:'%23include+%3Ctype_traits%3E%0A%0Astruct+A+%7B%0A++++A()+%3D+default%3B%0A++++//+A(const+volatile+A%26)+%7B%7D%3B%0A%7D%3B%0A%0Aint+main()+%7B%0A++++using+T+%3D+volatile+A%3B%0A++++//+static_assert(std::is_copy_constructible_v%3CT%3E,+%22%22)%3B++++++//+fails%0A++++//+static_assert(std::is_constructible_v%3CT,+const+T%26%3E,+%22%22)%3B+//+fails%0A++++T+x%3B%0A++++T+y%7Bx%7D%3B+//+error:+no+matching+function+for+call+to+!'A(const+volatile+T%26)!'%0A%0A++++return+0%3B%0A%7D'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:51.730894839973864,l:'4',m:100,n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:g122,deviceViewOpen:'1',filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'-O2',selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+gcc+12.2+(Editor+%231)',t:'0')),header:(),k:33.88240082531392,l:'4',m:35.827338129496404,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+gcc+12.2',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+gcc+12.2+(Compiler+%231)',t:'0')),header:(),l:'4',m:64.17266187050359,n:'0',o:'',s:0,t:'0')),k:48.26910516002612,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)) - so normally it's not allowed anyway (e.g. no suchvolatile
constructors in Eigen, Kokkos and Trilinos).
I think for the constraints we can skipp the remove_cv but i think that would break the is_copy_constuctibel
.
But inside the class we have to use the "raw" type because the private member must be const inside the class.
In some sense, i am not too concerned how we check the constraints but mostly how we present them. At some point it will be good to define a concept of a "basis matrix/container" so that will take care of all this but for now this is not high priority
for the matrix type of the linear subspace class we currently say:
Because we want the type to be just the matrix class type, for example Eigen::MatrixXd, or Tpetra::MultiVector so without any const qualification and cannot be a pointer or what not
Q: is there a way to formulate this better?