相关疑难解决方法(0)

MS Visual Studio 2013中没有<optional> - 怎么办?

我想使用std::experimental::optional,但MSVS 2013告诉我它找不到标题.

  • 为什么不在那里?
  • 我可以根据其他地方的代码滚动自己吗?C++ 14提案可能吗?

optional c++-standard-library visual-studio-2013 c++14 c++17

11
推荐指数
1
解决办法
4781
查看次数

我可以为 vector&lt;double&gt; 函数返回 NULL 吗?

我有以下功能:

/* Calculate if there is an intersection with given intial position and 
  direction */
vector<double> intersection(vector<double> startPos, vector<double> direction)
{
   if(there is intersection)
      return (intersection coordinates);
   else {
      return NULL;
   }
} 
Run Code Online (Sandbox Code Playgroud)

我可以这样做并检查NULL是否存在交叉点:

vector<double> v = intersection(pos, dir);
if(v == NULL)
   /* Do something */
else
   /* Do something else */
Run Code Online (Sandbox Code Playgroud)

如果这是不允许的/糟糕的编码实践,我可以采取的另一种方法是什么?

c++ null vector

4
推荐指数
1
解决办法
6750
查看次数