bkietz commented on issue #45817:
URL: https://github.com/apache/arrow/issues/45817#issuecomment-2751512786

   > Well, I don't know if C++20 concepts could always replace uses of the 
`constexpr` functions
   
   `concept`s are directly usable as boolean expressions, for example:
   
   ```c++
   namespace concepts {
   
   template <typename ArrowType>
   concept FixedSizeBinary = std::decay_t<ArrowType>::type_id == 
Type::FIXED_SIZE_BINARY;
   
   }
   
   //...
       ::arrow::VisitType(*values.type(), [&](const auto& type) {
         if constexpr (::arrow::concepts::FixedSizeBinary<decltype(type)>) {
           // ...
         }
       });
   ```
   
   So I can confidently say we'd lose no expressiveness there. Furthermore, in 
the specific case of conditional compilation it's worth noting that `requires` 
clauses are also boolean expressions:
   
   ```c++
       ::arrow::VisitType(*values.type(), [&](const auto& type) {
         using ArrowType = std::decay_t<decltype(type)>;
         constexpr bool HAS_C_TYPE = requires() {
           typename ArrowType::c_type;
         };
         if constexpr (HAS_C_TYPE) {
           using c_type = typename ArrowType::c_type;
         } else {
           // no c_type in ArrowType
         }
       });
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to