Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-12816

[C++] C++14 laundry list

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • None
    • C++
    • None

    Description

      Improvements to make/be aware of once C++14 is available:

      • Ensure that lambda closure members are moved into where ever possible/appropriate. We have a lot of local variables whose only function is getting copied into a closure, including some demotions to shared_ptr since move only types can't be closed over in c++11
      • visitor pattern can be used more fluidly with template lambdas, for example we could have a utility like
        VisitInts(offset_width, offset_bytes, [&](auto* offsets) { /*mutate offsets*/ })
        

        to replace a switch statement like

        switch (offset_width) {
        case 8:
          /* mutate offsets<int8_t> */
          break;
        case 16:
          /* mutate offsets<int16_t> */
          break;
        // ...
        }
        
      • deduced return type with auto:
        template <typename Container>
        auto GetBeginAndEnd(const Container& cont) {
          return std::make_pair(cont.begin(), cont.end());
        }
        
      • constexpr switch, for use in type traits functions
      • std::enable_if_t
      • std::quoted is available for escaping strings
      • std::make_unique
      • standard [[deprecated]] attribute
      • temporal literals such as ""s, ""ns, ...
      • binary literals with place markers such as 0b1100_1111

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              bkietz Ben Kietzman
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: