xrngdev.cpp

来自「C语言库函数的原型,有用的拿去」· C++ 代码 · 共 28 行

CPP
28
字号
// xrngdev: random device for TR1 random number generators
#define _CRT_RAND_S
#include <stdexcept>

 #if _HAS_TR1
//  #include <random>
_STD_BEGIN
	namespace tr1 {	// TR1 additions

_CRTIMP2_PURE unsigned int __CLRCALL_PURE_OR_CDECL _Random_device();

unsigned int __CLRCALL_PURE_OR_CDECL _Random_device()
	{	// return a random value
	unsigned int ans;
	if (::rand_s(&ans) != 0)
		_THROW_NCEE(out_of_range, "invalid random_device value");
	return (ans);
	}

	}	// namespace tr1
_STD_END
 #endif /* _HAS_TR1 */

/*
 * Copyright (c) 1992-2008 by P.J. Plauger.  ALL RIGHTS RESERVED.
 * Consult your license regarding permissions and restrictions.
V5.05:0009 */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?