string_view string view std
C++17之std::any
一般来说,c++是一种具有类型绑定和类型安全性的语言。值对象声明为具有特定类型,该类型定义哪些操作是可能的以及它们的行为方式。值对象不能改变它们的类型。 std: any是一种值类型,它能够更改其类型,同时仍然具有类型安全性。也就是说,对象可以保存任意类型的值,但是它们知道当前保存的值是哪种类型。在 ......
Java中的String、StringBuilder和StringBuffer
### String #### String为什么不可变?有什么好处? ![image](https://img2023.cnblogs.com/blog/1950787/202306/1950787-20230620175305920-629279762.png) 在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零 ......
uniapp企业微信web-view父子通信问题
**项目背景**:开发工具为HBuilderX,框架为uniapp,开发移动端的Web应用,在企业微信中使用(自建应用),Web开发的应用,不是小程序。 **需求**:页面中用到``组件,加载其他系统的页面(有跨域),需要在父子页面之间相互通信。这里通信的东西其实就是获取定位,通过uniapp获取用 ......
1.redis常见数据类型-字符串String、列表List、集合Set、Hash哈希、Zset有序集合
背景: 这里说的数据类型是value的数据类型,key的类型都是字符串。 命令不区分大小写,而key的值是区分大小写的 help @+数据类型 会出现命令提示 比如 help@string,help@list 常见命令: keys * 查看当前库所有key (匹配:keys *1) exists k ......
利用react-json-view最JSON数据进行渲染
##1.安装 ```js npm install --save react-json-view ``` ##2.使用 ```js import ReactJson from "react-json-view"; const A = () => { let src = { "content-lengt ......
关于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 ......
微信小程序使用scroll-view,实现顶部下滑与页面融为一体
在需要下滑的页面放置scroll-view html <scroll-view class="refresh" scroll-y="{{true}}" refresher-enabled="{{true}}" refresher-triggered="{{showTriggered}}" refre ......
app直播源代码,scroll-view下拉刷新与上拉加载更多
app直播源代码,scroll-view下拉刷新与上拉加载更多 1、wxml代码 <!-- 数据列表 --><scroll-view class="box-scroll" scroll-y='true' refresher-enabled="true" refresher-threshold="{{ ......