什么时候boost :: asio :: ip :: address :: from_string(remoteHost)抛出异常

时间:2016-05-17 06:22:27

标签: c++ boost boost-asio

当且仅当我的remoteHost变量不是十进制点格式的字符串时,以下语句是否会抛出异常?

boost::asio::ip::address::from_string(remoteHost)

我真的想在我的方案中检查remoteHost变量的有效性,而不是运行时。

感谢。

1 个答案:

答案 0 :(得分:0)

如果您使用address.ipp中的两个参数版本跟address_v6.ippaddress_v4.ipp中的版本,您会看到他们都调用了boost::asio::detail::socket_ops::inet_pton中定义的def auc(y_true, y_val, plot=False): #check input if len(y_true) != len(y_val): raise ValueError('Label vector (y_true) and corresponding value vector (y_val) must have the same length.\n') #empty arrays, true positive and false positive numbers tp = [] fp = [] #count 1's and -1's in y_true cond_positive = list(y_true).count(1) cond_negative = list(y_true).count(-1) #all possibly relevant bias parameters stored in a list bias_set = sorted(list(set(y_val)), key=float, reverse=True) bias_set.append(min(bias_set)*0.9) #initialize y_pred array full of negative predictions (-1) y_pred = np.ones(len(y_true))*(-1) #the computation time is mainly influenced by this for loop #for a contamination rate of 1% it already takes ~8s to terminate for bias in bias_set: #"lower values tend to correspond to label −1" #indices of values which exceed the bias posIdx = np.where(y_val > bias) #set predicted values to 1 y_pred[posIdx] = 1 #the following function simply calculates results which enable a distinction #between the cases of true positive and false positive results = np.asarray(y_true) + 2*np.asarray(y_pred) #append the amount of tp's and fp's tp.append(float(list(results).count(3))) fp.append(float(list(results).count(1))) #calculate false positive/negative rate tpr = np.asarray(tp)/cond_positive fpr = np.asarray(fp)/cond_negative #optional scatterplot if plot == True: plt.scatter(fpr,tpr) plt.show() #calculate AUC AUC = np.trapz(tpr,fpr) return AUC 3}}从第2029行开始。

这是一个很长的功能,所以我会把它留给你看看它究竟需要什么。