首页 \ 问答 \ 将boost范围适配器与目录迭代器范围一起使用(Using boost range adaptors with a directory iterator range)

将boost范围适配器与目录迭代器范围一起使用(Using boost range adaptors with a directory iterator range)

编辑:我根据乔纳森的回答在我的问题下面添加了一些解决方案

我想在给定的目录中有一个具有特定名称模式的常规文件列表。 我从boost.filesystem (boost 1.53)中提取了一个例子并对其进行了修改。 这是我基本想要的工作版本:

#include <iostream>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>

using namespace std;
using namespace boost::filesystem;

int main(int argc, char* argv[])
{
  path p ("."); // search directory

  try
  {
    if (exists(p))
    {
      if (is_directory(p))
      {
        cout << "logfiles in " << absolute(p) << '\n';
      // I want to replace this part:
        std::list<directory_entry> datFiles;
        for(directory_iterator it(p); it != directory_iterator(); ++it)
        {
          if (is_regular_file(*it) && (extension(*it) == ".dat"))
          {
            datFiles.push_back(*it);
          }
        }
      // part to be replaced ends here
        BOOST_FOREACH(const directory_entry& de, datFiles)
        {
          cout << de << '\n';
        }
      }
    }
  }

  catch (const filesystem_error& ex)
  {
    cout << ex.what() << '\n';
  }

  return 0;
}

这会将所有以.dat结尾的文件的条目附加到目录条目列表中。 我稍后需要更多模式匹配。 然后我尝试用范围做同样的事情,但都失败了。 我现在将任务简化为只复制也不能编译的所有目录条目:

    // replacement starts here
        std::list<directory_entry> datFiles;
        boost::iterator_range<directory_iterator> rng(directory_iterator(p), directory_iterator());should be
        boost::copy(rng, datFiles.begin());
    // replacement ends here

我这样写,因为(来自boost.filesystem的tut3.cpp)

directory_iterator :: value_type是directory_entry

因此,该副本可以遍历该范围,获取条目并将它们存储在我的列表中。 但是,我收到了很多来自gcc的错误消息:

In file included from boost_1_53_0/boost/type_traits/decay.hpp:18:0,
                 from boost_1_53_0/boost/filesystem/path_traits.hpp:22,
                 from boost_1_53_0/boost/filesystem/path.hpp:25,
                 from boost_1_53_0/boost/filesystem.hpp:16,
                 from ~/20130519_searchDatFiles/main.cpp:3:
boost_1_53_0/boost/mpl/eval_if.hpp: In instantiation of ‘boost::mpl::eval_if_c<false, boost::range_const_iterator<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())>, boost::range_mutable_iterator<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())> >’:
boost_1_53_0/boost/range/iterator.hpp:63:63:   instantiated from ‘boost::range_iterator<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())>’
boost_1_53_0/boost/range/concepts.hpp:256:72:   instantiated from ‘boost::SinglePassRangeConcept<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())>’
boost_1_53_0/boost/concept/detail/has_constraints.hpp:42:5:   instantiated from ‘const bool boost::concepts::not_satisfied<boost::SinglePassRangeConcept<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())> >::value’
boost_1_53_0/boost/concept/detail/has_constraints.hpp:45:31:   instantiated from ‘boost::concepts::not_satisfied<boost::SinglePassRangeConcept<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())> >’
boost_1_53_0/boost/mpl/if.hpp:67:11:   instantiated from ‘boost::mpl::if_<boost::concepts::not_satisfied<boost::SinglePassRangeConcept<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())> >, boost::concepts::constraint<boost::SinglePassRangeConcept<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())> >, boost::concepts::requirement<boost::concepts::failed************ boost::SinglePassRangeConcept<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())>::************> >’
boost_1_53_0/boost/concept/detail/general.hpp:50:8:   instantiated from ‘boost::concepts::requirement_<void (*)(boost::SinglePassRangeConcept<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())>)>’
boost_1_53_0/boost/range/algorithm/copy.hpp:33:1:   instantiated from ‘OutputIterator boost::range::copy(const SinglePassRange&, OutputIterator) [with SinglePassRange = boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)()), OutputIterator = std::_List_iterator<boost::filesystem::directory_entry>]’
~/20130519_searchDatFiles/main.cpp:45:42:   instantiated from here
boost_1_53_0/boost/mpl/eval_if.hpp:60:31: error: no type named ‘type’ in ‘boost::mpl::eval_if_c<false, boost::range_const_iterator<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())>, boost::range_mutable_iterator<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())> >::f_ {aka struct boost::range_mutable_iterator<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())>}’
In file included from boost_1_53_0/boost/range/algorithm.hpp:53:0,
                 from ~/20130519_searchDatFiles/main.cpp:7:
boost_1_53_0/boost/range/algorithm/copy.hpp: In function ‘OutputIterator boost::range::copy(const SinglePassRange&, OutputIterator) [with SinglePassRange = boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)()), OutputIterator = std::_List_iterator<boost::filesystem::directory_entry>]’:
~/20130519_searchDatFiles/main.cpp:45:42:   instantiated from here
boost_1_53_0/boost/range/algorithm/copy.hpp:34:59: error: no matching function for call to ‘begin(boost::iterator_range<boost::filesystem::directory_iterator> (&)(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)()))’
boost_1_53_0/boost/range/algorithm/copy.hpp:34:59: note: candidates are:
boost_1_53_0/boost/range/begin.hpp:101:55: note: template<class T> typename boost::range_iterator::type boost::range_adl_barrier::begin(T&)
boost_1_53_0/boost/range/begin.hpp:112:61: note: template<class T> typename boost::range_iterator<const T>::type boost::range_adl_barrier::begin(const T&)
boost_1_53_0/boost/range/algorithm/copy.hpp:34:59: error: no matching function for call to ‘end(boost::iterator_range<boost::filesystem::directory_iterator> (&)(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)()))’
boost_1_53_0/boost/range/algorithm/copy.hpp:34:59: note: candidates are:
boost_1_53_0/boost/range/end.hpp:95:55: note: template<class T> typename boost::range_iterator::type boost::range_adl_barrier::end(T&)
boost_1_53_0/boost/range/end.hpp:106:61: note: template<class T> typename boost::range_iterator<const T>::type boost::range_adl_barrier::end(const T&)
boost_1_53_0/boost/range/algorithm/copy.hpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]

我真的不能过滤出相关的行,但我认为可以使用范围适配器来过滤文件(毕竟,我不只是想复制范围)。 我的印象是,在某种程度上datFiles.begin()不符合复制算法所需的概念。


我的一些解决方案

基于乔纳森的回答,下面是我提出的一些解决方案(包括过滤)。

使用全局谓词函数bool isDatFile(const path& p)

std::list<directory_entry> datFiles;
boost::copy(rng | boost::adaptors::filtered(isDatFile), std::back_inserter(datFiles));

尽管如此,我更喜欢本地功能,所以我尝试过。 这一个只是检查目录条目是否是一个常规文件,因为is_regular_file过载而需要静态is_regular_file

std::list<directory_entry> datFiles;
boost::copy(rng
            | boost::adaptors::filtered(static_cast<bool (*)(const path&)>(&is_regular_file)),
            std::back_inserter(datFiles));

检查范围适配器中的右侧扩展也有点困难,所以我添加了一个本地函数:

std::list<directory_entry> datFiles;
bool BOOST_LOCAL_FUNCTION(const path& p)
{
  return (is_regular_file(p) && (extension(p) == string(".dat")));
} BOOST_LOCAL_FUNCTION_NAME(isDatFile_l)
boost::copy(rng
            | boost::adaptors::filtered(isDatFile_l),
            std::back_inserter(datFiles));

最后,使用绑定的“单线程”:

std::list<directory_entry> datFiles;
boost::copy(rng
            | boost::adaptors::filtered(static_cast<bool (*)(const path&)>(&is_regular_file))
            | boost::adaptors::filtered(boost::bind(std::equal_to<path>(), boost::bind(extension, _1), path(".dat"))),
            std::back_inserter(datFiles));

Edit: I added some solutions below my question, based on Jonathan's answer

I want to have a list of regular files with a certain name pattern in a given directory. I took one of the examples from boost.filesystem (boost 1.53) and modified it. Here is a working version of what I basically want:

#include <iostream>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>

using namespace std;
using namespace boost::filesystem;

int main(int argc, char* argv[])
{
  path p ("."); // search directory

  try
  {
    if (exists(p))
    {
      if (is_directory(p))
      {
        cout << "logfiles in " << absolute(p) << '\n';
      // I want to replace this part:
        std::list<directory_entry> datFiles;
        for(directory_iterator it(p); it != directory_iterator(); ++it)
        {
          if (is_regular_file(*it) && (extension(*it) == ".dat"))
          {
            datFiles.push_back(*it);
          }
        }
      // part to be replaced ends here
        BOOST_FOREACH(const directory_entry& de, datFiles)
        {
          cout << de << '\n';
        }
      }
    }
  }

  catch (const filesystem_error& ex)
  {
    cout << ex.what() << '\n';
  }

  return 0;
}

This appends the entry of all files ending with .dat to the list of directory entries. I need more pattern matching later. I then tried to do the same thing with ranges, and failed. I now reduced the task to simply copying all directory entries which also doesn't compile:

    // replacement starts here
        std::list<directory_entry> datFiles;
        boost::iterator_range<directory_iterator> rng(directory_iterator(p), directory_iterator());should be
        boost::copy(rng, datFiles.begin());
    // replacement ends here

I wrote it this way because (tut3.cpp from boost.filesystem)

directory_iterator::value_type is directory_entry

So that copy can iterate over the range, get entries and store them in my list. However, I'm getting lots of error messages from gcc:

In file included from boost_1_53_0/boost/type_traits/decay.hpp:18:0,
                 from boost_1_53_0/boost/filesystem/path_traits.hpp:22,
                 from boost_1_53_0/boost/filesystem/path.hpp:25,
                 from boost_1_53_0/boost/filesystem.hpp:16,
                 from ~/20130519_searchDatFiles/main.cpp:3:
boost_1_53_0/boost/mpl/eval_if.hpp: In instantiation of ‘boost::mpl::eval_if_c<false, boost::range_const_iterator<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())>, boost::range_mutable_iterator<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())> >’:
boost_1_53_0/boost/range/iterator.hpp:63:63:   instantiated from ‘boost::range_iterator<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())>’
boost_1_53_0/boost/range/concepts.hpp:256:72:   instantiated from ‘boost::SinglePassRangeConcept<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())>’
boost_1_53_0/boost/concept/detail/has_constraints.hpp:42:5:   instantiated from ‘const bool boost::concepts::not_satisfied<boost::SinglePassRangeConcept<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())> >::value’
boost_1_53_0/boost/concept/detail/has_constraints.hpp:45:31:   instantiated from ‘boost::concepts::not_satisfied<boost::SinglePassRangeConcept<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())> >’
boost_1_53_0/boost/mpl/if.hpp:67:11:   instantiated from ‘boost::mpl::if_<boost::concepts::not_satisfied<boost::SinglePassRangeConcept<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())> >, boost::concepts::constraint<boost::SinglePassRangeConcept<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())> >, boost::concepts::requirement<boost::concepts::failed************ boost::SinglePassRangeConcept<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())>::************> >’
boost_1_53_0/boost/concept/detail/general.hpp:50:8:   instantiated from ‘boost::concepts::requirement_<void (*)(boost::SinglePassRangeConcept<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())>)>’
boost_1_53_0/boost/range/algorithm/copy.hpp:33:1:   instantiated from ‘OutputIterator boost::range::copy(const SinglePassRange&, OutputIterator) [with SinglePassRange = boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)()), OutputIterator = std::_List_iterator<boost::filesystem::directory_entry>]’
~/20130519_searchDatFiles/main.cpp:45:42:   instantiated from here
boost_1_53_0/boost/mpl/eval_if.hpp:60:31: error: no type named ‘type’ in ‘boost::mpl::eval_if_c<false, boost::range_const_iterator<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())>, boost::range_mutable_iterator<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())> >::f_ {aka struct boost::range_mutable_iterator<boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)())>}’
In file included from boost_1_53_0/boost/range/algorithm.hpp:53:0,
                 from ~/20130519_searchDatFiles/main.cpp:7:
boost_1_53_0/boost/range/algorithm/copy.hpp: In function ‘OutputIterator boost::range::copy(const SinglePassRange&, OutputIterator) [with SinglePassRange = boost::iterator_range<boost::filesystem::directory_iterator>(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)()), OutputIterator = std::_List_iterator<boost::filesystem::directory_entry>]’:
~/20130519_searchDatFiles/main.cpp:45:42:   instantiated from here
boost_1_53_0/boost/range/algorithm/copy.hpp:34:59: error: no matching function for call to ‘begin(boost::iterator_range<boost::filesystem::directory_iterator> (&)(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)()))’
boost_1_53_0/boost/range/algorithm/copy.hpp:34:59: note: candidates are:
boost_1_53_0/boost/range/begin.hpp:101:55: note: template<class T> typename boost::range_iterator::type boost::range_adl_barrier::begin(T&)
boost_1_53_0/boost/range/begin.hpp:112:61: note: template<class T> typename boost::range_iterator<const T>::type boost::range_adl_barrier::begin(const T&)
boost_1_53_0/boost/range/algorithm/copy.hpp:34:59: error: no matching function for call to ‘end(boost::iterator_range<boost::filesystem::directory_iterator> (&)(boost::filesystem::directory_iterator, boost::filesystem::directory_iterator (*)()))’
boost_1_53_0/boost/range/algorithm/copy.hpp:34:59: note: candidates are:
boost_1_53_0/boost/range/end.hpp:95:55: note: template<class T> typename boost::range_iterator::type boost::range_adl_barrier::end(T&)
boost_1_53_0/boost/range/end.hpp:106:61: note: template<class T> typename boost::range_iterator<const T>::type boost::range_adl_barrier::end(const T&)
boost_1_53_0/boost/range/algorithm/copy.hpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]

I wasn't really able to filter out the relevant lines, but I think that it is possible to filter files using range adaptors (I don't just want to copy the range, after all). My impression is that somewhere along the way datFiles.begin() doesn't satisfy a concept needed by the copy algorithm.


Some of my solutions

Here are some of the solutions (including filtering) I came up with, based on Jonathan's answer.

Using a global predicate function bool isDatFile(const path& p):

std::list<directory_entry> datFiles;
boost::copy(rng | boost::adaptors::filtered(isDatFile), std::back_inserter(datFiles));

I preferred a local function, though, so I tried that. This one is just checking if the directory entry is a regular file, the static cast was needed because is_regular_file is overloaded:

std::list<directory_entry> datFiles;
boost::copy(rng
            | boost::adaptors::filtered(static_cast<bool (*)(const path&)>(&is_regular_file)),
            std::back_inserter(datFiles));

Checking for the right extension in the range adaptor as well was a bit hard, so I added a local function:

std::list<directory_entry> datFiles;
bool BOOST_LOCAL_FUNCTION(const path& p)
{
  return (is_regular_file(p) && (extension(p) == string(".dat")));
} BOOST_LOCAL_FUNCTION_NAME(isDatFile_l)
boost::copy(rng
            | boost::adaptors::filtered(isDatFile_l),
            std::back_inserter(datFiles));

And finally the "one-liner" using bind:

std::list<directory_entry> datFiles;
boost::copy(rng
            | boost::adaptors::filtered(static_cast<bool (*)(const path&)>(&is_regular_file))
            | boost::adaptors::filtered(boost::bind(std::equal_to<path>(), boost::bind(extension, _1), path(".dat"))),
            std::back_inserter(datFiles));

原文:https://stackoverflow.com/questions/16639666
更新时间:2023-12-26 18:12

最满意答案

如果您获得IPv6地址,则使用IPv6。 IPv4和IPv6是不同的协议,客户端选择在两者都可用时使用哪个协议。

如果您需要客户端的IPv4地址,则可以通过不在DNS中通告IPv6地址来强制它们使用它。 随着IPv6的部署越来越多,这将是个坏主意。 支持两者都很好,因此最好使用IPv6处理客户端。


If you get an IPv6 address then IPv6 is being used. IPv4 and IPv6 are different protocols, and the client chooses which one to use when both are available.

If you want the client's IPv4 address then you can force them to use it by not advertising the IPv6 address in DNS. That would be a bad idea though with the increasing deployment of IPv6. Supporting both is good, so it is better to deal with clients using IPv6.

相关问答

更多
  • 使用1个TCP套接字无法侦听2个不同的IP地址,但是如果您使用in6addr_any地址侦听所有接口,那么也会包含所有IPv4地址(尽管我相信,例如,linux有一个内核选项可禁用该映射)。 (更新版本的)套接字API对于使用IPv4还是IPv6来说是相当透明的,但必须非常小心如何对IPv4应用程序进行编码。 例如接受连接并打印出远程主机地址的IPv4代码: struct sockaddr_in client_addr; socklen_t addr_len = sizeof(client_addr); ...
  • string strHostName = System.Net.Dns.GetHostName();; IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName); IPAddress[] addr = ipEntry.AddressList; Console.WriteLine(addr[addr.Length-1].ToString()); if (addr[0].AddressFamily == System.Net.Sockets.A ...
  • 好像 0x00000000000000000000FFFF位于十六进制编码的IP地址之前。 以下IP是C0A8623E,每个网络有两位数字。 您可以在Ipv6字符串的开头创建一个字符串匹配。 例: IPString LIKE '0x00000000000000000000FFFF%' 这应该告诉你它是v6还是v4地址。 希望这可以帮助。 最好的祝福, 乔治· Looks like 0x00000000000000000000FFFF is before your hex encoded IP-Adres ...
  • 如果您获得IPv6地址,则使用IPv6。 IPv4和IPv6是不同的协议,客户端选择在两者都可用时使用哪个协议。 如果您需要客户端的IPv4地址,则可以通过不在DNS中通告IPv6地址来强制它们使用它。 随着IPv6的部署越来越多,这将是个坏主意。 支持两者都很好,因此最好使用IPv6处理客户端。 If you get an IPv6 address then IPv6 is being used. IPv4 and IPv6 are different protocols, and the client ...
  • 将您的IP地址立即作为System.Net.IPAddress实例。 看看以下方法: IPAddress.Equals() IPAddress.MapToIPv4() IPAddress.MapToIPv6() 您可能希望为特殊地址添加特殊处理(例如TCP / IP环回适配器:这是单个IPv6地址, ::1 ,而对于IPv4,即使最常用的地址为127.0.0.1 ,IETF为此目的保留了整个 127/8块( 127.0.0.0 - 127.255.255.255包括端点)。如何确定相等性(甚至等价性)是值得 ...
  • 没有任何问题:IPv4和IPv6可以共享传输层,如以太网而不会造成问题。 此外,还有很多系统可以同时支持v4和v6协议栈。 当然,要获得IPv4和IPv6节点之间的任何通信,必须通过网关(例如4to6)。 Without any problems: IPv4 and IPv6 can share a transport layer such as Ethernet without causing problems. Furthermore, there are many systems that can s ...
  • 只需使用inet_pton()将它们转换为二进制表示形式,然后使用inet_pton()将其转换回字符串。 另一种解决方案是存储IP字符串而不在DB中进行任何转换。 VARCHAR(39)字段将完成工作,因为最高/最长的IPv6是ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff Simply convert them to a binary representation using inet_pton() and later back to a string using ine ...
  • 查找使用inet_aton , inet_ntoa , gethostbyname , gethostbyaddr , htonl , htons , ntohl , ntohs和任何直接sockaddr_in操作的所有代码,并将其替换为对getaddrinfo或getnameinfo简单调用。 这将使您的代码更简单,更易于维护,IPv6将自动运行,无需额外工作。 Find all code that uses inet_aton, inet_ntoa, gethostbyname, gethostbyad ...
  • 不,这不可能。 它们是完全独立的网络协议,不必彼此有任何关系。 另外,我建议按IP地址禁止应该只与其他方法一起使用,因为很容易使用代理或其他方法从不同的IP地址命中服务器。 No, it isn't really possible. They are entirely separate network protocols that don't have to have anything to do with each other. In addition, I would suggest that bann ...
  • 好吧,我找到了一种方法来使用ipaddr.js模块 ,我通过这个答案找到了。 该模块可用于检查IPv6地址是否为IPv4地址,然后进行转换。 例如: var ip = require('ipaddr.js') function cleanupAddress (str) { // if it's a valid ipv6 address, and if its a mapped ipv4 address, // then clean it up. otherwise return the o ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)