segmentation string fault std
Java中的String、StringBuilder和StringBuffer
### String #### String为什么不可变?有什么好处?  在Java中的String源码中 ......
C++ 计时方法 std::chrono
计时的作用:测试某一段代码的运行时间,时间越短,则性能相对越高。 C++11 标准的”最佳计时方法“的代码: 1 #include <chrono> 2 using namespace std; 3 using namespace chrono; 4 5 auto start = system_cl ......
C++ std::move 的一些问题
看 SO 上有一个比较奇怪的问题, When does an rvalue reference result in a move vs copy constructor and why? 问题代码: ClassX c = std::move(object_c); // Invokes move co ......
C++ std::chrono的时钟Clock
std::chrono是C++11引入的日期时间处理库,其中包含3种时钟:system_clock,steady_clock,high_resolution_clock。近来需要使用高精度时间,很自然想到使用high_resolution_clock,然而使用后发现并非预期的得到自1970/1/1零 ......
1.redis常见数据类型-字符串String、列表List、集合Set、Hash哈希、Zset有序集合
背景: 这里说的数据类型是value的数据类型,key的类型都是字符串。 命令不区分大小写,而key的值是区分大小写的 help @+数据类型 会出现命令提示 比如 help@string,help@list 常见命令: keys * 查看当前库所有key (匹配:keys *1) exists k ......
关于ASP.NET.CORE中的Failed to read parameter "string param" from the request body as JSON的处理
先上报错信息 Microsoft.AspNetCore.Http.BadHttpRequestException: Failed to read parameter "string param" from the request body as JSON. > System.Text.Json.Js ......
std::thread 六:多线程&单例类
为了避免单例类在多线程中重复的创建,下面提供了两种解决方法: 1.互斥锁+双重检查 2.std::call_once() 方法一:互斥锁+双重检查 #include <iostream> #include <thread> #include <mutex> #include <list> using ......
std::thread 四:异步(async)
*:如果 std::async 中传递参数 std::lunnch::deferred ,就需要等待调用 get() 或者 wait() 才会执行,并且代码非子线程运行,而是在主线程中执行 #include <iostream> #include <thread> #include <mutex> ......
std::thread 五:打包任务(packaged_task)
#include <iostream> #include <thread> #include <mutex> #include <list> #include <future> using namespace std; int myThread(int num) { cout << "myThrea ......
std::thread 三:条件变量(condition_variable())
condition_variable 、 wait 、 notify_one 、 notify_all *:notify_one:通知(唤醒)一个线程 *:notify_all:通知(唤醒)多个线程 #include <iostream> #include <thread> #include <mu ......
std::thread 二:互斥量(带超时的互斥量 timed_mutex())
timed_mutex 、 try_lock_for 、 try_lock_until #include <iostream> #include <thread> #include <mutex> #include <list> using namespace std; class A { publ ......
std::thread 二:互斥量(多个互斥量的解决方法)
// *:这里的lock是函数模板,最少传两个互斥量 // 第一种,使用 lock 和 unlock std::mutex m_mutex1; std::mutex m_mutex2; std::lock(m_mutex1, m_mutex2); m_mutex1.unlock(); m_mutex ......
std::thread 二:互斥量(lock() & unlock())
mutex 互斥量的作用是保护共享数据 *:有 lock() 就一定要有 unlock() #include <iostream> #include <thread> #include <mutex> #include <list> using namespace std; class A { pu ......
std::thread 二:互斥量(lock_guard())
*:使用 lock_guard 后,就不可以使用 lock() 和 unlock() *:lock_guard 和智能指针一样,会自动解锁 #include <iostream> #include <thread> #include <mutex> #include <list> using nam ......
std::thread 一:创建线程的三种方式
前言: #include <thread> thread.join() // 阻塞 thread.detach() // 非阻塞 thread.joinable() // bool,判断线程是否支持join或者detach 正文: 创建线程有三种方式,分别是:使用函数来创建线程、使用自定义的类来创建 ......
std::string 拼接字符串
#include <iostream> #include <string> #include <sstream> using namespace std; int main() { string a = "123"; stringstream b; b << 123 << "456" << 789 ......
CF1778C - Flexible String 二进制枚举、状态压缩
参考splay佬的题解写个记录[https://zhuanlan.zhihu.com/p/602721281](原题解链接) 题意:给定两个字符串a, b,可以选择α里面的字符进行替换,但是替换的字符种类最多为k个。其中字符串α字符出现的种类不超过10种。求将替换后,两个字符的相同部分的数量。(相同 ......
C++面试八股文:std::string是如何实现的?
某日二师兄参加XXX科技公司的C++工程师开发岗位第18面: > 面试官:`std::string`用过吧? > > 二师兄:当然用过(废话,C++程序员就没有没用过`std::string`的)。 > > 面试官:`std::string("hello")+"world"`、`"hello"+st ......
mysql:报错Incorrect string value:’\xF0\x9F\x94\xA6\xF0\x9F…’
一,报错信息: 1,报错: Incorrect string value: '\xF0\x9F\x94\xA6\xF0\x9F...' for column 'content' at row 1 报错的原因: 字符串中包含了emoji表情: 如: 🔦💡🕯️ 💡🕯️🔦 2,运行环境: my ......
题解 CF1830C【Hyperregular Bracket Strings】
给定一个长度 $n$ 和 $k$ 个子区间 $\{[l1,r1],[l2,r2],…,[lk,rk]\}$。
问有多少个长度为 $n$ 的合法括号序列,使得每一个子区间也是合法的括号序列。
$n,k\leq 2^{18}$。 ......
Day08-异常机制、包装类、String-StringBuffer-StringBuilder比较
异常机制 异常处理5个关键字:try、catch、finally、throw、throws 注意点 假设要捕获多个异常,异常类型从小到大 try监控区域,catch(想要捕获的异常类型!)捕获异常 finally处理善后工作,可以不要finally throw 主动抛出异常 throws在方法上捕获 ......
c++多线程 std::async std::future
c++标准库中对线程操作有完善的封装,其中最常用到的如std::thread, std::async。 EffectiveModernCpp中指出,应尽量使用std::async即基于任务的编程而非基于线程的编程。std::thread在前面的文章有提到过,此处仅对std::async作以记录。 正 ......
CString和string互转
CString转string CString strMfc = "test"; std::string strStr = strMfc.GetBuffer(0); string转CString CString strMfc; string strStr = "test"; strMfc = strS ......
string和char[]互转
string转char数组 char buf[10]; string str("ABCDEFG"); length = str.copy(buf, 9); buf[length] = '\0'; 或者 strcpy(buf, str.c_str()); strncpy(buf, str.c_str( ......
Qt error: C7525: 内联变量至少需要 “/std:c++17“
碰到这种错误,只需要在Qt中配置C++17即可解决 打开该项目中的xxx.pro文件,然后如下图中红色方框中配置:CONFIG += c++17 ......
Java中String类型能够存放多大的数据量?编译器只支持String只能存放65535个字符,运行时可用是int长度远比65535个多
Java中String类型能够存放多大的数据量? https://blog.csdn.net/weixin_52707625/article/details/125583678 最近在编写博客系统时,在文章上传遇到了个问题: 到底使用什么来接收文章呢?String类型能接收多大的数据量? 随后,我去 ......
【最常用】两种java中的占位符的使用 第一种:使用%s占位,使用String.format转换 第二种:使用{1}占位,使用MessageFormat.format转换
【最常用】两种java中的占位符的使用 第一种:使用%s占位,使用String.format转换 第二种:使用{1}占位,使用MessageFormat.format转换 https://blog.csdn.net/weixin_43899069/article/details/121164107 ......
js把string转化为json
// 声明变量名为a的对象var a = {a:1,b:2,c:"wangwei"};// 将JSON对象转化为JSON字符,赋值给变量let strResult =JSON.stringify(a)// 查看变量strResult是什么类型typeof strResult // 'string' ......
std::package_task bind.lambda,thread,future
#include <atomic> #include <chrono> #include <cmath> #include <condition_variable> #include <cstddef> #include <forward_list> #include <fstream> #incl ......