小编jos*_*ray的帖子

从GetAdapterAddresses()获取子网掩码

我正在使用该GetAdapterAddresses()方法获取系统上所有接口的IP地址.

我需要找到每个接口的广播地址.我可以使用IP地址和子网掩码来计算,但我无法在IP_ADAPTER_ADDRESSES结构中看到子网掩码.

有没有办法检索子网掩码使用GetAdapterAddresses()

c c++ winapi iphelper

9
推荐指数
1
解决办法
5291
查看次数

SFINAE模板参数推断失败

当我编译这段代码时:

#include <type_traits>

template <typename T>
void do_stuff(std::enable_if_t<std::is_integral<T>::value, T> &t) {}

template <typename T>
void do_stuff(std::enable_if_t<std::is_class<T>::value, T> &t) {}

int main() {
    int i = 1;
    do_stuff(i);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

GCC说:

37325975.cpp: In function ‘int main()’:
37325975.cpp:11:15: error: no matching function for call to ‘do_stuff(int&)’
     do_stuff(i);
               ^
37325975.cpp:4:6: note: candidate: template<class T> void do_stuff(std::enable_if_t<std::is_integral<_Tp>::value, T>&)
 void do_stuff(std::enable_if_t<std::is_integral<T>::value, T> &t) {}
      ^
37325975.cpp:4:6: note:   template argument deduction/substitution failed:
37325975.cpp:11:15: note:   couldn't deduce template parameter ‘T’
     do_stuff(i);
               ^
37325975.cpp:7:6: note: candidate: template<class …
Run Code Online (Sandbox Code Playgroud)

c++ templates sfinae

2
推荐指数
1
解决办法
327
查看次数

Python - 将字符串拆分为配对字符列表

可能重复:
如何在Python中将列表拆分为大小均匀的块?
按字符数分割字符串

我有一个字符串(十六进制),如:

717765717777716571a7202020
Run Code Online (Sandbox Code Playgroud)

我需要把它变成格式:

0x71,0x77,0x65,0x71,0x77,0x77...
Run Code Online (Sandbox Code Playgroud)

我不确定最好的方法是什么

python string hex list

0
推荐指数
1
解决办法
234
查看次数

标签 统计

c++ ×2

c ×1

hex ×1

iphelper ×1

list ×1

python ×1

sfinae ×1

string ×1

templates ×1

winapi ×1