当前位置: 首页>>代码示例>>C++>>正文


C++ detail类代码示例

本文整理汇总了C++中detail的典型用法代码示例。如果您正苦于以下问题:C++ detail类的具体用法?C++ detail怎么用?C++ detail使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了detail类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: __create_directories

bool __create_directories(const path& p, std::error_code *ec)
{
    std::error_code m_ec;
    auto const st = detail::posix_stat(p, &m_ec);
    if (!status_known(st)) {
        set_or_throw(m_ec, ec, "create_directories", p);
        return false;
    }
    else if (is_directory(st)) {
        if (ec) ec->clear();
        return false;
    }
    else if (exists(st)) {
        set_or_throw(make_error_code(errc::file_exists),
                     ec, "create_directories", p);
        return false;
    }

    const path parent = p.parent_path();
    if (!parent.empty()) {
        const file_status parent_st = status(parent, m_ec);
        if (not status_known(parent_st)) {
            set_or_throw(m_ec, ec, "create_directories", p);
            return false;
        }
        if (not exists(parent_st)) {
            __create_directories(parent, ec);
            if (ec && *ec) { return false; }
        }
    }
    return __create_directory(p, ec);
}
开发者ID:AstroVPK,项目名称:LLVM-4.0.0,代码行数:32,代码来源:operations.cpp

示例2: __fs_is_empty

bool __fs_is_empty(const path& p, std::error_code *ec)
{
    if (ec) ec->clear();
    std::error_code m_ec;
    struct ::stat pst;
    auto st = detail::posix_stat(p, pst, &m_ec);
    if (m_ec) {
        set_or_throw(m_ec, ec, "is_empty", p);
        return false;
    }
    else if (!is_directory(st) && !is_regular_file(st)) {
        m_ec = make_error_code(errc::not_supported);
        set_or_throw(m_ec, ec, "is_empty");
        return false;
    }
    else if (is_directory(st)) {
        auto it = ec ? directory_iterator(p, *ec) : directory_iterator(p);
        if (ec && *ec)
            return false;
        return it == directory_iterator{};
    }
    else if (is_regular_file(st))
        return static_cast<std::uintmax_t>(pst.st_size) == 0;

    _LIBCPP_UNREACHABLE();
}
开发者ID:AstroVPK,项目名称:LLVM-4.0.0,代码行数:26,代码来源:operations.cpp

示例3: __copy_file

bool __copy_file(const path& from, const path& to, copy_options options,
                 std::error_code *ec)
{
    using StatT = struct ::stat;
    if (ec)
      ec->clear();

    std::error_code m_ec;
    StatT from_stat;
    auto from_st = detail::posix_stat(from, from_stat, &m_ec);
    if (not is_regular_file(from_st)) {
        if (not m_ec)
            m_ec = make_error_code(errc::not_supported);
        set_or_throw(m_ec, ec, "copy_file", from, to);
        return false;
    }

    StatT to_stat;
    auto to_st = detail::posix_stat(to, to_stat, &m_ec);
    if (!status_known(to_st)) {
        set_or_throw(m_ec, ec, "copy_file", from, to);
        return false;
    }

    const bool to_exists = exists(to_st);
    if (to_exists && !is_regular_file(to_st)) {
        set_or_throw(make_error_code(errc::not_supported), ec, "copy_file", from, to);
        return false;
    }
    if (to_exists && detail::stat_equivalent(from_stat, to_stat)) {
      set_or_throw(make_error_code(errc::file_exists), ec, "copy_file", from,
                   to);
      return false;
    }
    if (to_exists && bool(copy_options::skip_existing & options)) {
        return false;
    }
    else if (to_exists && bool(copy_options::update_existing & options)) {
        auto from_time = __last_write_time(from, ec);
        if (ec && *ec) { return false; }
        auto to_time = __last_write_time(to, ec);
        if (ec && *ec) { return false; }
        if (from_time <= to_time) {
            return false;
        }
        return detail::copy_file_impl(from, to, from_st.permissions(), ec);
    }
    else if (!to_exists || bool(copy_options::overwrite_existing & options)) {
        return detail::copy_file_impl(from, to, from_st.permissions(), ec);
    }
    else {
      set_or_throw(make_error_code(errc::file_exists), ec, "copy_file", from,
                   to);
        return false;
    }

    _LIBCPP_UNREACHABLE();
}
开发者ID:Xiaodingdangguaiguai,项目名称:catboost,代码行数:58,代码来源:operations.cpp

示例4: scatterv

void
scatterv(const communicator& comm, const T* in_values,
         const std::vector<int>& sizes, const std::vector<int>& displs,
         T* out_values, int out_size, int root)
{
  using detail::c_data;
  scatterv_impl(comm, in_values, out_values, out_size, c_data(sizes), c_data(displs), 
                root, is_mpi_datatype<T>());
}
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:9,代码来源:scatterv.hpp

示例5: is_prime

constexpr bool is_prime(std::size_t n)
{
  using detail::find_factor;
  using detail::ceilsqrt;

  return n > 1
    && (n == 2
        || (n % 2 == 1
            && (n == 3
                || !find_factor(n, 1, (ceilsqrt(n) + 1) / 2))));
}
开发者ID:WhiZTiM,项目名称:coliru,代码行数:11,代码来源:main.cpp

示例6: __last_write_time

void __last_write_time(const path& p, file_time_type new_time,
                       std::error_code *ec)
{
    using namespace std::chrono;
    std::error_code m_ec;

    // We can use the presence of UTIME_OMIT to detect platforms that do not
    // provide utimensat.
#if !defined(UTIME_OMIT)
    // This implementation has a race condition between determining the
    // last access time and attempting to set it to the same value using
    // ::utimes
    struct ::stat st;
    file_status fst = detail::posix_stat(p, st, &m_ec);
    if (m_ec && !status_known(fst)) {
        set_or_throw(m_ec, ec, "last_write_time", p);
        return;
    }
    struct ::timeval tbuf[2];
    tbuf[0].tv_sec = st.st_atime;
    tbuf[0].tv_usec = 0;
    const bool overflowed = !detail::set_times_checked<microseconds>(
        &tbuf[1].tv_sec, &tbuf[1].tv_usec, new_time);

    if (overflowed) {
        set_or_throw(make_error_code(errc::invalid_argument), ec,
                     "last_write_time", p);
        return;
    }
    if (::utimes(p.c_str(), tbuf) == -1) {
        m_ec = detail::capture_errno();
    }
#else
    struct ::timespec tbuf[2];
    tbuf[0].tv_sec = 0;
    tbuf[0].tv_nsec = UTIME_OMIT;

    const bool overflowed = !detail::set_times_checked<nanoseconds>(
        &tbuf[1].tv_sec, &tbuf[1].tv_nsec, new_time);
    if (overflowed) {
        set_or_throw(make_error_code(errc::invalid_argument),
            ec, "last_write_time", p);
        return;
    }
    if (::utimensat(AT_FDCWD, p.c_str(), tbuf, 0) == -1) {
        m_ec = detail::capture_errno();
    }
#endif
    if (m_ec)
        set_or_throw(m_ec, ec, "last_write_time", p);
    else if (ec)
        ec->clear();
}
开发者ID:01org,项目名称:linux-sgx,代码行数:53,代码来源:operations.cpp

示例7: __last_write_time

void __last_write_time(const path& p, file_time_type new_time,
                       std::error_code *ec)
{
    using namespace std::chrono;
    std::error_code m_ec;

#if !defined(_LIBCXX_USE_UTIMENSAT)
    // This implementation has a race condition between determining the
    // last access time and attempting to set it to the same value using
    // ::utimes
    struct ::stat st;
    file_status fst = detail::posix_stat(p, st, &m_ec);
    if (m_ec && !status_known(fst)) {
        set_or_throw(m_ec, ec, "last_write_time", p);
        return;
    }
    auto atime = detail::extract_atime(st);
    struct ::timeval tbuf[2];
    tbuf[0].tv_sec = atime.tv_sec;
    tbuf[0].tv_usec = duration_cast<microseconds>(nanoseconds(atime.tv_nsec)).count();
    const bool overflowed = !FSTime::set_times_checked<microseconds>(
        &tbuf[1].tv_sec, &tbuf[1].tv_usec, new_time);

    if (overflowed) {
        set_or_throw(make_error_code(errc::invalid_argument), ec,
                     "last_write_time", p);
        return;
    }
    if (::utimes(p.c_str(), tbuf) == -1) {
        m_ec = detail::capture_errno();
    }
#else
    struct ::timespec tbuf[2];
    tbuf[0].tv_sec = 0;
    tbuf[0].tv_nsec = UTIME_OMIT;

    const bool overflowed = !FSTime::set_times_checked<nanoseconds>(
        &tbuf[1].tv_sec, &tbuf[1].tv_nsec, new_time);
    if (overflowed) {
        set_or_throw(make_error_code(errc::invalid_argument),
            ec, "last_write_time", p);
        return;
    }
    if (::utimensat(AT_FDCWD, p.c_str(), tbuf, 0) == -1) {
        m_ec = detail::capture_errno();
    }
#endif
    if (m_ec)
        set_or_throw(m_ec, ec, "last_write_time", p);
    else if (ec)
        ec->clear();
}
开发者ID:Xiaodingdangguaiguai,项目名称:catboost,代码行数:52,代码来源:operations.cpp

示例8: main

int main() {
    using detail::memo;
    auto g = memo(f);
    cout << g(2) << endl;
    cout << g(2) << endl;
    cout << g(2) << endl;
    cout << g(3) << endl;
    cout << g(3) << endl;
    cout << g(3) << endl;
    auto h = memo(g);
    cout << h(10) << endl;
    return 0;
}
开发者ID:cosminBoaca,项目名称:CppLearning,代码行数:13,代码来源:memo14.cpp

示例9: write_ini

    void write_ini(std::basic_ostream<
                       typename Ptree::key_type::value_type
                   > &stream,
                   const Ptree &pt,
                   int flags = 0)
    {
        using detail::check_dupes;

        typedef typename Ptree::key_type::value_type Ch;
        typedef std::basic_string<Ch> Str;

        BOOST_ASSERT(validate_flags(flags));
        (void)flags;

        if (!pt.data().empty())
            BOOST_PROPERTY_TREE_THROW(ini_parser_error(
                "ptree has data on root", "", 0));
        check_dupes(pt);

        for (typename Ptree::const_iterator it = pt.begin(), end = pt.end();
             it != end; ++it)
        {
            check_dupes(it->second);
            if (it->second.empty()) {
                stream << it->first << Ch('=')
                    << it->second.template get_value<
                        std::basic_string<Ch> >()
                    << Ch('\n');
            } else {
                if (!it->second.data().empty())
                    BOOST_PROPERTY_TREE_THROW(ini_parser_error(
                        "mixed data and children", "", 0));
                stream << Ch('[') << it->first << Ch(']') << Ch('\n');
                for (typename Ptree::const_iterator it2 = it->second.begin(),
                         end2 = it->second.end(); it2 != end2; ++it2)
                {
                    if (!it2->second.empty())
                        BOOST_PROPERTY_TREE_THROW(ini_parser_error(
                            "ptree is too deep", "", 0));
                    stream << it2->first << Ch('=')
                        << it2->second.template get_value<
                            std::basic_string<Ch> >()
                        << Ch('\n');
                }
            }
        }

    }
开发者ID:00liujj,项目名称:dealii,代码行数:48,代码来源:ini_parser.hpp

示例10: __create_directory

bool __create_directory(path const & p, path const & attributes,
                        std::error_code *ec)
{
    struct ::stat attr_stat;
    std::error_code mec;
    auto st = detail::posix_stat(attributes, attr_stat, &mec);
    if (!status_known(st)) {
        set_or_throw(mec, ec, "create_directory", p, attributes);
        return false;
    }
    if (ec) ec->clear();
    if (::mkdir(p.c_str(), attr_stat.st_mode) == 0)
        return true;
    if (errno != EEXIST || !is_directory(p))
        set_or_throw(ec, "create_directory", p, attributes);
    return false;
}
开发者ID:AstroVPK,项目名称:LLVM-4.0.0,代码行数:17,代码来源:operations.cpp

示例11: read_write_property_map

 read_write_property_map(boost::python::class_<T, Basis, HeldType, NonCopyable>& pm)
 {
   pm.def("__getitem__", &getitem)
     .def("__setitem__", &setitem)
     ;
   
   using detail::property_map_extras;
   property_map_extras(pm, type<PropertyMap>(), 0);
 }
开发者ID:jiva-technology,项目名称:bgl-python,代码行数:9,代码来源:property_map.hpp

示例12: DefWindowProc

LRESULT SongsTable::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & /*bHandled*/)
{
    auto lRes = DefWindowProc(uMsg, wParam, lParam);

    AddColumn(_T("Title"), 0);
    AddColumn(_T("Artist"), 1);
    AddColumn(_T("Album"), 2);
    
    m_songs = m_gmusic.songs();
    for (size_t i = 0; i < m_songs.size(); ++i)
    {
        using detail::toTChar;
        AddItem(i, 0, toTChar(m_songs[i].m_title).data());
        AddItem(i, 1, toTChar(m_songs[i].m_artist).data());
        AddItem(i, 2, toTChar(m_songs[i].m_album).data());
    }

    return lRes;
}
开发者ID:dvirtz,项目名称:googlemusic-foobar,代码行数:19,代码来源:SongsTable.cpp

示例13: __permissions

void __permissions(const path& p, perms prms, std::error_code *ec)
{

    const bool resolve_symlinks = !bool(perms::symlink_nofollow & prms);
    const bool add_perms = bool(perms::add_perms & prms);
    const bool remove_perms = bool(perms::remove_perms & prms);
    _LIBCPP_ASSERT(!(add_perms && remove_perms),
                   "Both add_perms and remove_perms are set");

    bool set_sym_perms = false;
    prms &= perms::mask;
    if (!resolve_symlinks || (add_perms || remove_perms)) {
        std::error_code m_ec;
        file_status st = resolve_symlinks ? detail::posix_stat(p, &m_ec)
                                          : detail::posix_lstat(p, &m_ec);
        set_sym_perms = is_symlink(st);
        if (m_ec) return set_or_throw(m_ec, ec, "permissions", p);
        _LIBCPP_ASSERT(st.permissions() != perms::unknown,
                       "Permissions unexpectedly unknown");
        if (add_perms)
            prms |= st.permissions();
        else if (remove_perms)
           prms = st.permissions() & ~prms;
    }
    const auto real_perms = detail::posix_convert_perms(prms);

# if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_FDCWD)
    const int flags = set_sym_perms ? AT_SYMLINK_NOFOLLOW : 0;
    if (::fchmodat(AT_FDCWD, p.c_str(), real_perms, flags) == -1) {
        return set_or_throw(ec, "permissions", p);
    }
# else
    if (set_sym_perms)
        return set_or_throw(make_error_code(errc::operation_not_supported),
                            ec, "permissions", p);
    if (::chmod(p.c_str(), real_perms) == -1) {
        return set_or_throw(ec, "permissions", p);
    }
# endif
    if (ec) ec->clear();
}
开发者ID:01org,项目名称:linux-sgx,代码行数:41,代码来源:operations.cpp

示例14: __hard_link_count

std::uintmax_t __hard_link_count(const path& p, std::error_code *ec)
{
    std::error_code m_ec;
    struct ::stat st;
    detail::posix_stat(p, st, &m_ec);
    if (m_ec) {
        set_or_throw(m_ec, ec, "hard_link_count", p);
        return static_cast<std::uintmax_t>(-1);
    }
    if (ec) ec->clear();
    return static_cast<std::uintmax_t>(st.st_nlink);
}
开发者ID:AstroVPK,项目名称:LLVM-4.0.0,代码行数:12,代码来源:operations.cpp

示例15: main

int main() {
#define DUMP(container) do { std::cout << #container ": "; dump(container); } while(0)

    std::array<int,5> arr = { 4, 3, 2, 1, 0 };
    DUMP(arr);
    sort(arr);
    DUMP(arr);

    std::list<int> list = { 4, 3, 2, 1, 0 };
    DUMP(list);
    sort(list);
    DUMP(list);

    std::vector<int> vec = { 4, 3, 2, 1, 0 };
    DUMP(vec);
    sort(vec);
    DUMP(vec);

    int raw_array[] = { 4, 3, 2, 1, 0 };
    DUMP(raw_array);
    sort(raw_array);
    DUMP(raw_array);
    
#undef DUMP
}
开发者ID:CCJY,项目名称:coliru,代码行数:25,代码来源:main.cpp


注:本文中的detail类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。