andishgar commented on issue #47101:
URL: https://github.com/apache/arrow/issues/47101#issuecomment-3104803603

   @kou Could we use inside arrow?
   The resason why we need boost I try to depict to below code.
   
   ```c++
   #include <iostream>
   #include <variant>
   #include <string>
   #include <boost/variant2/variant.hpp>
   
   namespace {
       using ValueType = std::variant<int64_t, double, std::string>;
       using ValueTypeSubset = std::variant<int64_t, double>;
       // The api of ArrayStatistics will be like this
       // Which I think it's not appropriate
       ValueType ConvertToSuperSet(ValueTypeSubset value) {
           return std::visit([&](auto v) {
               return ValueType(v);
           }, value);
       }
   }
   
   int main() {
       ValueType v;
       ValueTypeSubset v1 = int64_t{1};
       // Compile-time error
       /* v = v1; */
   
       // This is what the ArrayStatistics API might look like,
       // though I don't think it's ideal.
       v = ConvertToSuperSet(v1);
       std::cout << std::get<int64_t>(v) << '\n';
   
       boost::variant2::variant<int64_t, double, std::string> v2;
       boost::variant2::variant<int64_t, double> v3 = int64_t{1};
       // Using Boost enables this kind of API, which seems cleaner.
       v2 = v3;
       std::cout << boost::variant2::get<int64_t>(v2) << '\n';
   }
   
   ``` 


-- 
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