C++のパッケージマネージャ「poac」を開発した話 / Poac is a package manager for C++

C62fe8f90cf120dcc0a894461990e3e2?s=47 Ken Matsui
February 20, 2019

C++のパッケージマネージャ「poac」を開発した話 / Poac is a package manager for C++

C62fe8f90cf120dcc0a894461990e3e2?s=128

Ken Matsui

February 20, 2019
Tweet

Transcript

  1. 6.
  2. 15.
  3. 16.

    ▸ JOTUBMM   ύοέʔδΛΠϯετʔϧ ▸ VOJOTUBMM  ύοέʔδΛΞϯΠϯετʔϧ ▸

    TFBSDI  ύοέʔδΛݕࡧ ▸ JOJU    QPBDZNMϑΝΠϧΛੜ੒ ▸ OFX    ϓϩδΣΫτςϯϓϨʔτΛੜ੒ ▸ QVCMJTI  ࣗ࡞ύοέʔδΛެ։ ▸ UFTU   ςετΛߦ͏ ▸ VQEBUF  ύοέʔδΛΞοϓσʔτ ▸ CVJME   Ϗϧυ͢Δ ▸ SVO   Ϗϧυͱ࣮ߦΛߦ͏ αϒίϚϯυ Ұ෦
  4. 17.
  5. 18.
  6. 19.
  7. 20.
  8. 22.

    *OGFSFODF template <typename S, typename OpTypeE, typename VS, typename=std::enable_if_t<std::is_rvalue_reference_v<VS&&>>> auto

    _apply(S&& func, const OpTypeE& cmd, VS&& arg) { return branch(std::move(func), cmd, std::move(arg)); } template <typename S, typename VS, typename=std::enable_if_t<std::is_rvalue_reference_v<VS&&>>> std::string apply(S&& func, const S& cmd, VS&& arg) { namespace except = core::exception; if (auto itr = subcmd_map.find(cmd); itr != subcmd_map.end()) return _apply(std::move(func), itr->second, std::move(arg)); else if (itr = option_map.find(cmd); itr != option_map.end()) return _apply(std::move(func), itr->second, std::move(arg)); else throw except::invalid_first_arg("Invalid argument"); }
  9. 23.

    *OGFSFODF // Create function pointer table: { &func<0>, &func<1>, ...

    } // Execute function: &func<idx>[idx]() template <size_t... Is, typename VS, typename = std::enable_if_t<std::is_rvalue_reference_v<VS&&>>> static auto execute(std::index_sequence<Is...>, int idx, VS&& vs) { // Return ""(empty string) because match the type to the other two functions. return make_array({ +[](VS&& vs){ return (op_type_list_t::at_t<Is>()(std::move(vs)), ""); }... })[idx](std::move(vs)); } template <size_t... Is> static auto summary(std::index_sequence<Is...>, int idx) { return make_array({ +[]{ return op_type_list_t::at_t<Is>::summary(); }... })[idx](); } template <size_t... Is> static auto options(std::index_sequence<Is...>, int idx) { return make_array({ +[]{ return op_type_list_t::at_t<Is>::options(); }... })[idx](); }
  10. 24.

    ($$ͷόά #if BOOST_COMP_GNUC template <typename T, typename VS, typename =

    std::enable_if_t<std::is_rvalue_reference_v<VS&&>>> static auto execute2(VS&& vs) { return (T()(std::move(vs)), ""); } template <typename T> static auto summary2() { return T::summary(); } template <typename T> static auto options2() { return T::options(); } template <size_t... Is, typename VS, typename = std::enable_if_t<std::is_rvalue_reference_v<VS&&>>> static auto execute(std::index_sequence<Is...>, int idx, VS&& vs) { using func_t = decltype(&execute2<op_type_list_t::at_t<0>, VS>); static func_t func_table[] = { &execute2<op_type_list_t::at_t<Is>>... }; return func_table[idx](std::move(vs)); } template <size_t... Is> static auto summary(std::index_sequence<Is...>, int idx) { using func_t = decltype(&summary2<op_type_list_t::at_t<0>>); static func_t func_table[] = { &summary2<op_type_list_t::at_t<Is>>... }; return func_table[idx](); } template <size_t... Is> static auto options(std::index_sequence<Is...>, int idx) { using func_t = decltype(&options2<op_type_list_t::at_t<0>>); static func_t func_table[] = { &options2<op_type_list_t::at_t<Is>>... }; return func_table[idx](); } #else
  11. 33.
  12. 34.

    ࠓޙ΍͍ͬͯ͘͜ͱ ▸ ύοέʔδͷ௥Ճɾ੔උ ▸ υΩϡϝϯτͷ֦ॆ ▸ ϏϧυγεςϜվળ ▸ ଎౓ͷվળ ▸

    ιʔείʔυͷվળ ▸ ΤσΟλͷ֦ுػೳ։ൃ ▸ ϏϧυࡁΈύοέʔδͷΠϯετʔϧ ▸ άϩʔόϧΠϯετʔϧ ▸ EFW%FQFOEFODZɾUFTU%FQFOEFODZ ▸ EPDίϚϯυɾGNUίϚϯυ