CUDA identifier min is undefined in Visual Studio

  c++, compiler-errors, nvcc, visual-studio
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

void mykernel(int n, int* a)
    int x = 100, y = 200;
    a[0] = min(x, y);

int main()
   return 0;

For some reason, this code can’t compile on Visual Studio because function "min" inside the kernel can’t be found. However, if I use nvcc -o main, the code compiles normally.

What’s the reason and how can I fix this?

Edit: I’m talking about the __device__ function min, not std::min

Source: Windows Questions C++