本文整理汇总了C++中std类的典型用法代码示例。如果您正苦于以下问题:C++ std类的具体用法?C++ std怎么用?C++ std使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了std类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: swap
stacktrace& operator=(stacktrace other)
{
using std::swap;
swap(call_stack_, other.call_stack_);
return *this;
}
开发者ID:jarmond,项目名称:prime-cpp,代码行数:6,代码来源:stacktrace.hpp
示例2: swap
void Callback::swap( Callback& rhs ) {
using std::swap;
swap( m_id, rhs.m_id );
swap( m_callback, rhs.m_callback );
}
开发者ID:xeroskiller,项目名称:nodepp,代码行数:5,代码来源:base_callback.cpp
示例3: swap
friend void swap(ResourceHandle<Handle>& a, ResourceHandle<Handle>& b) noexcept
{
using std::swap;
swap(static_cast<Resource&>(a), static_cast<Resource&>(b));
swap(a.handle_, b.handle_);
}
开发者ID:nyorain,项目名称:vpp,代码行数:6,代码来源:resource.hpp
示例4: main
int main ()
{
std::cout << "Nonfinite_num_facet very simple example." << std::endl;
if((std::numeric_limits<double>::has_infinity == 0) || (std::numeric_limits<double>::infinity() == 0))
{
std::cout << "Infinity not supported on this platform." << std::endl;
return 0;
}
if((std::numeric_limits<double>::has_quiet_NaN == 0) || (std::numeric_limits<double>::quiet_NaN() == 0))
{
std::cout << "NaN not supported on this platform." << std::endl;
return 0;
}
std::locale default_locale (std::locale::classic ()); // Note the currrent (default C) locale.
// Create plus and minus infinity.
double plus_infinity = +std::numeric_limits<double>::infinity();
double minus_infinity = -std::numeric_limits<double>::infinity();
// and create a NaN (NotANumber)
double NaN = +std::numeric_limits<double>::quiet_NaN ();
double negated_NaN = (boost::math::changesign)(std::numeric_limits<double>::quiet_NaN ());
// Output the nonfinite values using the current (default C) locale.
// The default representations differ from system to system,
// for example, using Microsoft compilers, 1.#INF, -1.#INF, and 1.#QNAN.
cout << "Using C locale" << endl;
cout << "+std::numeric_limits<double>::infinity() = " << plus_infinity << endl;
cout << "-std::numeric_limits<double>::infinity() = " << minus_infinity << endl;
cout << "+std::numeric_limits<double>::quiet_NaN () = " << NaN << endl;
// Display negated NaN.
cout << "negated NaN " << negated_NaN << endl; // "-1.IND"
// Create a new output locale, and add the nonfinite_num_put facet
std::locale C99_out_locale (default_locale, new boost::math::nonfinite_num_put<char>);
// and imbue the cout stream with the new locale.
cout.imbue (C99_out_locale);
// Or for the same effect more concisely:
cout.imbue (locale(locale(), new boost::math::nonfinite_num_put<char>));
// Output using the new locale
cout << "Using C99_out_locale " << endl;
cout << "+std::numeric_limits<double>::infinity() = " << plus_infinity << endl;
cout << "-std::numeric_limits<double>::infinity() = " << minus_infinity << endl;
cout << "+std::numeric_limits<double>::quiet_NaN () = " << NaN << endl;
// Display negated NaN.
cout << "negated NaN " << negated_NaN << endl; // -nan
// Create a string with the expected C99 representation of plus infinity.
std::string inf = "inf";
{ // Try to read an infinity value using the default C locale.
// Create an input stream which will provide "inf"
std::istringstream iss (inf);
// Create a double ready to take the input,
double infinity;
// and read "inf" from the stringstream:
iss >> infinity;
// This will not work on all platforms!
if (! iss)
{ // Reading infinity went wrong!
std::cerr << "C locale input format error!" << std::endl;
}
} // Using default C locale.
{ // Now retry using C99 facets.
// Create a new input locale and add the nonfinite_num_get facet.
std::locale C99_in_locale (default_locale, new boost::math::nonfinite_num_get<char>);
// Create an input stream which will provide "inf".
std::istringstream iss (inf);
// Imbue the stream with the C99 input locale.
iss.imbue (C99_in_locale);
// Create a double ready to take the input,
double infinity;
// and read from the stringstream:
iss >> infinity;
if (! iss)
{ // Reading infinity went wrong!
std::cout << "C99 input format error!" << std::endl;
}
// Expect to get an infinity, which will display still using the C99 locale as "inf"
cout << "infinity in C99 representation is " << infinity << endl;
// To check, we can switch back to the default C locale.
cout.imbue (default_locale);
cout << "infinity in default C representation is " << infinity << endl;
} // using C99 locale.
//.........这里部分代码省略.........
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:101,代码来源:nonfinite_facet_simple.cpp
示例5: handle_scheduler_reply
// Handle the reply from a scheduler
//
int CLIENT_STATE::handle_scheduler_reply(
PROJECT* project, char* scheduler_url
) {
SCHEDULER_REPLY sr;
FILE* f;
int retval;
unsigned int i;
bool signature_valid, update_global_prefs=false, update_project_prefs=false;
char buf[1024], filename[256];
std::string old_gui_urls = project->gui_urls;
PROJECT* p2;
vector<RESULT*>new_results;
project->last_rpc_time = now;
if (work_fetch.requested_work()) {
had_or_requested_work = true;
}
get_sched_reply_filename(*project, filename, sizeof(filename));
f = fopen(filename, "rb");
if (!f) return ERR_FOPEN;
retval = sr.parse(f, project);
fclose(f);
if (retval) return retval;
if (log_flags.sched_ops) {
if (work_fetch.requested_work()) {
snprintf(buf, sizeof(buf), ": got %d new tasks", (int)sr.results.size());
} else {
safe_strcpy(buf, "");
}
msg_printf(project, MSG_INFO, "Scheduler request completed%s", buf);
}
if (log_flags.sched_op_debug) {
if (sr.scheduler_version) {
msg_printf(project, MSG_INFO,
"[sched_op] Server version %d",
sr.scheduler_version
);
}
}
// check that master URL is correct
//
if (strlen(sr.master_url)) {
canonicalize_master_url(sr.master_url, sizeof(sr.master_url));
string url1 = sr.master_url;
string url2 = project->master_url;
downcase_string(url1);
downcase_string(url2);
if (url1 != url2) {
p2 = lookup_project(sr.master_url);
if (p2) {
msg_printf(project, MSG_USER_ALERT,
"You are attached to this project twice. Please remove projects named %s, then add %s",
project->project_name,
sr.master_url
);
} else {
msg_printf(project, MSG_USER_ALERT,
_("This project is using an old URL. When convenient, remove the project, then add %s"),
sr.master_url
);
}
}
}
// make sure we don't already have a project of same name
//
bool dup_name = false;
for (i=0; i<projects.size(); i++) {
p2 = projects[i];
if (project == p2) continue;
if (!strcmp(p2->project_name, project->project_name)) {
dup_name = true;
break;
}
}
if (dup_name) {
msg_printf(project, MSG_INFO,
"Already attached to a project named %s (possibly with wrong URL)",
project->project_name
);
msg_printf(project, MSG_INFO,
"Consider detaching this project, then trying again"
);
}
// show messages from server
//
bool got_notice = false;
for (i=0; i<sr.messages.size(); i++) {
USER_MESSAGE& um = sr.messages[i];
int prio = MSG_INFO;
if (!strcmp(um.priority.c_str(), "notice")) {
prio = MSG_SCHEDULER_ALERT;
//.........这里部分代码省略.........
开发者ID:DanAurea,项目名称:boinc,代码行数:101,代码来源:cs_scheduler.cpp
示例6: string
void SMPState::recordProbEduChlg() const {
size_t basePos = -1;
size_t digCount = 0;
size_t nextCommaPos = string::npos;
auto nextActor = [&basePos, &nextCommaPos](string &actors) {
basePos = nextCommaPos + 1;
nextCommaPos = actors.find_first_of(",", basePos);
size_t digCount = nextCommaPos - basePos;
return actors.substr(basePos, digCount);
};
QSqlQuery query = model->getQuery();
string qsql;
qsql = string("INSERT INTO TPProbVictLoss "
"(ScenarioId, Turn_t, Est_h, Init_i, ThrdP_k, Rcvr_j, Prob, Util_V, Util_L) "
"VALUES ("
"'") + model->getScenarioID() + "',"
" :t, :h, :i, :thrdp_k, :j, :prob, :util_v, :util_l )";
query.prepare(QString::fromStdString(qsql));
//model->beginDBTransaction();
for (auto &tpv : tpvData) {
auto thij = tpv.first;
auto tpvArray = tpv.second;
basePos = -1;
digCount = 0;
nextCommaPos = string::npos;
auto t = std::stoi(nextActor(thij));
auto h = std::stoi(nextActor(thij));
auto i = std::stoi(nextActor(thij));
auto j = std::stoi(nextActor(thij));
query.bindValue(":t", t);
query.bindValue(":h", h);
query.bindValue(":i", i);
query.bindValue(":j", j);
const unsigned int na = model->numAct;
for (int tpk = 0; tpk < na; tpk++) { // third party voter, tpk
query.bindValue(":thrdp_k", tpk);
// bind the data
query.bindValue(":prob", tpvArray(tpk, 0));
query.bindValue(":util_v", tpvArray(tpk, 1));
query.bindValue(":util_l", tpvArray(tpk, 2));
// actually record it
if (!query.exec()) {
LOG(INFO) << query.lastError().text().toStdString();
assert(false);
}
}
}
qsql = string("INSERT INTO ProbVict "
"(ScenarioId, Turn_t, Est_h,Init_i,Rcvr_j,Prob) VALUES ('")
+ model->getScenarioID() + "', :t, :h, :i, :j, :phij)";
query.prepare(QString::fromStdString(qsql));
for (auto &phijVal : phijData) {
auto thij = phijVal.first;
auto phij = phijVal.second;
basePos = -1;
digCount = 0;
nextCommaPos = string::npos;
auto t = std::stoi(nextActor(thij));
auto h = std::stoi(nextActor(thij));
auto i = std::stoi(nextActor(thij));
auto j = std::stoi(nextActor(thij));
query.bindValue(":t", t);
query.bindValue(":h", h);
query.bindValue(":i", i);
query.bindValue(":j", j);
query.bindValue(":phij", phij);
// actually record it
if (!query.exec()) {
LOG(INFO) << query.lastError().text().toStdString();
assert(false);
}
}
qsql = string("INSERT INTO UtilChlg "
"(ScenarioId, Turn_t, Est_h,Aff_k,Init_i,Rcvr_j,Util_SQ,Util_Vict,Util_Cntst,Util_Chlg) VALUES ('")
+ model->getScenarioID() + "', :t, :h, :k, :i, :j, :euSQ, :euVict, :euCntst, :euChlg)";
query.prepare(QString::fromStdString(qsql));
for (auto &euVal : euData) {
auto thkij = euVal.first;
basePos = -1;
//.........这里部分代码省略.........
开发者ID:ambah,项目名称:KTAB,代码行数:101,代码来源:smpsql.cpp
示例7: inv_cloglog
inline typename boost::math::tools::promote_args<T>::type
inv_cloglog(T x) {
using std::exp;
return exp(-exp(x));
}
开发者ID:bgoodri,项目名称:stan,代码行数:5,代码来源:inv_cloglog.hpp
示例8: func11
double func11(double x) {
++iteration_count;
return sin(0.01 / x) - 0.01;
};
开发者ID:ahmadyan,项目名称:ReaK,代码行数:4,代码来源:test_root_finders_perf.cpp
示例9: initBox2DTypeBindings
void initBox2DTypeBindings(GameManager& game) {
LuaContext& lua = *game.getLuaContext();
lua.writeVariable("Box2D", LuaEmptyArray);
{
lua.writeVariable("Box2D", "Vector", LuaEmptyArray);
{
lua.writeFunction("Box2D", "Vector", "new",
[](const optional<float>& arg1, const optional<float>& arg2) {
if (arg1 && arg2) {
// If the scripter passed in two arguments...
return b2Vec2(*arg1, *arg2);
}
else if (!(arg1 || arg2)) {
// Else if the scripter passed in *no* arguments...
return b2Vec2(0, 0);
}
else {
throw invalid_argument(
"Must pass in two numbers or nothing at all"
);
}
});
lua.registerMember("x", &b2Vec2::x);
lua.registerMember("y", &b2Vec2::y);
}
lua.writeVariable("Box2D", "BodyType", LuaEmptyArray);
{
lua.writeVariable("Box2D", "BodyType", "Static", b2_staticBody);
lua.writeVariable("Box2D", "BodyType", "Dynamic", b2_dynamicBody);
lua.writeVariable("Box2D", "BodyType", "Kinematic", b2_kinematicBody);
}
lua.writeVariable("Box2D", "BodyDef", LuaEmptyArray);
{
lua.writeFunction("Box2D", "BodyDef", "new", getDefaultConstructorLambda<b2BodyDef>());
lua.registerMember("active", &b2BodyDef::active);
lua.registerMember("allowSleep", &b2BodyDef::allowSleep);
lua.registerMember("angle", &b2BodyDef::angle);
lua.registerMember("angularDamping", &b2BodyDef::angularDamping);
lua.registerMember("angularVelocity", &b2BodyDef::angularVelocity);
lua.registerMember("awake", &b2BodyDef::awake);
lua.registerMember("bullet", &b2BodyDef::bullet);
lua.registerMember("fixedRotation", &b2BodyDef::fixedRotation);
lua.registerMember("gravityScale", &b2BodyDef::gravityScale);
lua.registerMember("linearDamping", &b2BodyDef::linearDamping);
lua.registerMember("linearVelocity", &b2BodyDef::linearVelocity);
lua.registerMember("position", &b2BodyDef::position);
lua.registerMember("type", &b2BodyDef::type);
}
lua.writeVariable("Box2D", "Body", LuaEmptyArray);
{
lua.writeFunction("Box2D", "Body", "new", [&game](const b2BodyDef& def) {
return game.getPhysicsWorld()->CreateBody(&def);
});
lua.registerMember<b2Body, bool>("awake",
[](const b2Body& object) {
return object.IsAwake();
},
[](b2Body& object, const bool val) {
object.SetAwake(val);
});
lua.registerMember<b2Body, bool>("fixedRotation",
[](const b2Body& object) {
return object.IsFixedRotation();
},
[](b2Body& object, const bool val) {
object.SetFixedRotation(val);
});
lua.registerMember<b2Body, b2Vec2>("position",
[](const b2Body& body) {
return body.GetPosition();
},
[](b2Body& body, const b2Vec2& pos) {
body.SetTransform(pos, body.GetAngle());
});
lua.registerFunction<b2Body, b2Fixture*(b2FixtureDef&)>("CreateFixture",
[](b2Body& body, b2FixtureDef& def) {
return body.CreateFixture(&def);
});
}
lua.writeVariable("Box2D", "Filter", LuaEmptyArray);
{
lua.writeFunction("Box2D", "Filter", "new", getDefaultConstructorLambda<b2Filter>());
lua.registerMember("categoryBits", &b2Filter::categoryBits);
lua.registerMember("maskBits", &b2Filter::maskBits);
lua.registerMember("groupIndex", &b2Filter::groupIndex);
}
lua.writeVariable("Box2D", "FixtureDef", LuaEmptyArray);
{
lua.writeFunction("Box2D", "FixtureDef", "new", getDefaultConstructorLambda<b2FixtureDef>());
lua.registerMember("friction", &b2FixtureDef::friction);
lua.registerMember("restitution", &b2FixtureDef::restitution);
lua.registerMember("density", &b2FixtureDef::density);
//.........这里部分代码省略.........
开发者ID:JesseTG,项目名称:RAY,代码行数:101,代码来源:box2d_type_bindings.cpp
示例10: HasPtr
HasPtr(const string &s = string()):
ps(new string(s)), i(0) { }
开发者ID:qinf,项目名称:cpp_primer,代码行数:2,代码来源:13.11.cpp
示例11: chomp_carriage_return
void chomp_carriage_return(char* str) {
int len = strlen(str);
if ( str[len-1] == '\r' )
str[len-1] = '\0';
}
开发者ID:glycerine,项目名称:shore-mt,代码行数:5,代码来源:chomp.cpp
示例12: func8
double func8(double x) {
++iteration_count;
return exp(21000.0 / x) / (1.11e11 * x * x) - 1.0;
};
开发者ID:ahmadyan,项目名称:ReaK,代码行数:4,代码来源:test_root_finders_perf.cpp
示例13: func9
double func9(double x) {
++iteration_count;
return 1.0 / x + log(x) - 100.0;
};
开发者ID:ahmadyan,项目名称:ReaK,代码行数:4,代码来源:test_root_finders_perf.cpp
示例14: func6
double func6(double x) {
++iteration_count;
return 1e10 * pow(x, 1.0 / x) - 1.0;
};
开发者ID:ahmadyan,项目名称:ReaK,代码行数:4,代码来源:test_root_finders_perf.cpp
示例15: func7
double func7(double x) {
++iteration_count;
return pow(x, 20.0) - 1.0;
};
开发者ID:ahmadyan,项目名称:ReaK,代码行数:4,代码来源:test_root_finders_perf.cpp
示例16: func4
double func4(double x) {
++iteration_count;
return exp(1.0 / x - 25.0) - 1.0;
};
开发者ID:ahmadyan,项目名称:ReaK,代码行数:4,代码来源:test_root_finders_perf.cpp
示例17: func3
double func3(double x) {
++iteration_count;
return 2.0 * x * exp(-20.0) + 1.0 - 2.0 * exp(-20.0 * x);
};
开发者ID:ahmadyan,项目名称:ReaK,代码行数:4,代码来源:test_root_finders_perf.cpp
示例18: func1
double func1(double x) {
++iteration_count;
return 4.0 * cos(x) - exp(x);
};
开发者ID:ahmadyan,项目名称:ReaK,代码行数:4,代码来源:test_root_finders_perf.cpp
示例19: main
void main(int argc, char *argv[])
{ ofstream outf;
bool do_cmp;
string name, dir1(dir_path), dir2(aes_path);
if(argc == 1)
{
cout << endl << "usage: aes_gkat [/t] [/h] [/k] [/e] [/c] where:";
cout << endl << " /t: compare output and reference test file(s)";
cout << endl << " /h: author's byte order (frog, safer+ & serpent)";
cout << endl << " /k: generate ECB Known Answer Test files";
cout << endl << " /e: generate ECB Monte Carlo Test files";
cout << endl << " /c: generate CBC Monte Carlo Test files";
cout << endl << endl; exit(0);
}
cout << endl << "Generate and verify tests for the " << cipher_name()[0] << " algorithm: ("
<< cipher_name()[1] << ")" << endl;
do_fss_hack = test_args(argc, argv, 'h');
do_cmp = test_args(argc, argv, 't');
if(test_args(argc, argv, 'k'))
{
name = dir1 + string(cipher_name()[0]) + string("\\ecb_vk.txt");
outf.open(name.c_str(), ios_base::out);
if(outf)
{
header(outf, 0); ecb_vk(outf); outf << endl; outf.close();
if(do_cmp)
comp_vecs(dir2 + cipher_name()[2] + "\\ecb_vk.txt", name);
}
name = dir1 + string(cipher_name()[0]) + string("\\ecb_vt.txt");
outf.open(name.c_str(), ios_base::out);
if(outf)
{
header(outf, 1); ecb_vt(outf); outf << endl; outf.close();
if(do_cmp)
comp_vecs(dir2 + cipher_name()[2] + "\\ecb_vt.txt", name);
}
}
if(test_args(argc, argv, 'e'))
{
name = dir1 + string(cipher_name()[0]) + string("\\ecb_me.txt");
outf.open(name.c_str(), ios_base::out);
if(outf)
{
header(outf, 2); ecb_me(outf); outf << endl; outf.close();
if(do_cmp)
comp_vecs(dir2 + cipher_name()[2] + "\\ecb_e_m.txt", name);
}
name = dir1 + string(cipher_name()[0]) + string("\\ecb_md.txt");
outf.open(name.c_str(), ios_base::out);
if(outf)
{
header(outf, 3); ecb_md(outf); outf << endl; outf.close();
if(do_cmp)
comp_vecs(dir2 + cipher_name()[2] + "\\ecb_d_m.txt", name);
}
}
if(test_args(argc, argv, 'c'))
{
name = dir1 + string(cipher_name()[0]) + string("\\cbc_me.txt");
outf.open(name.c_str(), ios_base::out);
if(outf)
{
header(outf, 4); cbc_me(outf); outf << endl; outf.close();
if(do_cmp)
comp_vecs(dir2 + cipher_name()[2] + "\\cbc_e_m.txt", name);
}
name = dir1 + string(cipher_name()[0]) + string("\\cbc_md.txt");
outf.open(name.c_str(), ios_base::out);
//.........这里部分代码省略.........
开发者ID:Cristo-Conklin,项目名称:LibreCrypt,代码行数:101,代码来源:aes_gtst.cpp
示例20: func10
double func10(double x) {
++iteration_count;
return exp(exp(x)) - exp(exp(1.0));
};
开发者ID:ahmadyan,项目名称:ReaK,代码行数:4,代码来源:test_root_finders_perf.cpp
注:本文中的std类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论