
C/C++
文章平均质量分 80
EverNoob
simply bumping around
展开
-
Why no #if+Enum? C++ Compile Procedure
【代码】Why no #if+Enum?原创 2025-01-17 16:51:43 · 760 阅读 · 0 评论 -
C vs. Python Operator Precedence: Beware of (Bitwise) Logical Op.
comparison operators in python and C have different precedence compared to bitwise and logical operators, beware.转载 2022-10-13 10:16:12 · 203 阅读 · 0 评论 -
“context“ in C and Python
if”)..转载 2022-09-14 14:52:05 · 169 阅读 · 0 评论 -
C/Cpp: dynamic vs. static constructor calls
Calling constructors in c++ without new - Stack OverflowQ:I've often seen that people create objects in C++ usingThing myThing("asdf");Instead of this:Thing myThing = Thing("asdf");This seems to work (using gcc), at least as long as there a转载 2022-01-25 16:58:54 · 124 阅读 · 0 评论 -
Impressive OpenCV Optimization Tricks (Evolving Collection)
1. alignSize()+ n - 1 ensures the >= sz condition, while(n) & (-1 * n) get rid of the sign, andas n = 1 << N,sz + n - 1 ensures a sz' divisible by n is included in the range and & n will get rid of remainder bits.2. sobel/原创 2022-01-25 16:07:45 · 1987 阅读 · 0 评论 -
de/interleave with ARM
ARM DocumentNEON structure loads read data from memory into 64-bit NEON registers, with optional de-interleaving. Stores work similarly, interleaving data from registers before writing it to memory asFigure 6.4shows. For more information seeVLDn and V...转载 2022-01-25 14:51:07 · 269 阅读 · 0 评论 -
C and Cpp overloading
Cpp Overload ResolutionOverload resolution - cppreference.comIn order to compile a function call, the compiler must first performname lookup, which, for functions, may involveargument-dependent lookup, and for function templates may be followed byt...转载 2021-12-30 10:04:16 · 107 阅读 · 0 评论 -
warpAffine and Affine Transformation
InterfacefromOpenCV: Geometric Image Transformations◆warpAffine()void cv::warpAffine ( InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int...转载 2021-11-24 12:24:15 · 164 阅读 · 0 评论 -
C/CPP: integral_constant
std::integral_constantfromstd::integral_constant - cppreference.comC++Utilities libraryType support Defined in header<type_traits> template<classT, T v> structintegral_constant; (since C++11)...转载 2021-11-15 18:06:00 · 231 阅读 · 0 评论 -
C/CPP: Enum Class vs. Enum Type
from:Enum Classes in C++ and Their Advantage over Enum DataType - GeeksforGeekshttps://www.geeksforgeeks.org/enum-classes-in-c-and-their-advantage-over-enum-datatype/Enums or Enumerated type (enumeration)is a user-defined data type that can be assigned..转载 2021-11-15 17:54:24 · 371 阅读 · 0 评论 -
C/CPP __restrict__ (Implementation Specific) Keyword
from : What does the restrict keyword mean in C++? - Stack OverflowI was always unsure, what does the restrict keyword mean in C++?Does it mean the two or more pointer given to the function does not overlap? What else does it mean?c++restrict-qualifi转载 2021-11-15 15:45:49 · 176 阅读 · 0 评论 -
C Void Pointer
fromc - What does void* mean and how to use it? - Stack OverflowA pointer tovoidis a "generic" pointer type. Avoid *can be converted to any other pointer type without an explicit cast. You cannot dereference avoid *or do pointer arithmetic with it...转载 2021-11-11 20:43:41 · 123 阅读 · 0 评论 -
C/CPP Order of Evaluation
1. C/CPP does not specifiy any orderof evaluation of any PART of any expression==> includingfunction arguments==> but the sequential order of execution for the expressions is kept strictlysee:Order of evaluation - cppreference.comalso:c...原创 2021-10-27 10:09:14 · 200 阅读 · 0 评论 -
C __attribute__
fromhttps://blog.twitter.com/engineering/en_us/a/2014/attribute-directives-in-objective-c#:~:text=attribute__%20resources-,What%20are%20__attribute__%20directives%3F,the%20consumer%20of%20that%20code.What are __attribute__ directives?The __attribute_.转载 2021-10-25 14:15:07 · 120 阅读 · 0 评论 -
C/CPP type_t and suffix
fromc++ - Definition of int64_t - Stack Overflowa) Can you explain to me the difference betweenint64_tandlong(long int)? In my understanding, both are 64 bit integers. Is there any reason to choose one over the other?The former is a signed integ...原创 2021-10-21 16:45:26 · 137 阅读 · 0 评论 -
Default Arguments in C++ (shared)
Default Arguments in C++ - GeeksforGeeksA default argument is a value provided in a function declaration that is automatically assigned by the compiler if the caller of the function doesn’t provide a value for the argument with a default value.Followin转载 2021-10-18 09:55:18 · 174 阅读 · 0 评论 -
C++中iostream.clear()的用法
from:https://www.cnblogs.com/tonglingliangyong/p/3908463.html我们谈谈cin.clear的作用,第一次看到这东西,很多人以为就是清空cin里面的数据流,而实际上却与此相差很远,首先我们看看以下代码:#include<iostream>usingnamespacestd;intmain(){inta;cin>>a;...转载 2021-07-01 17:58:11 · 1554 阅读 · 0 评论 -
Python与C/C++相互调用(转+注)
一、问题 Python模块和C/C++的动态库间相互调用在实际的应用中会有所涉及,在此作一总结。二、Python调用C/C++1、Python调用C动态链接库 Python调用C库比较简单,不经过任何封装打包成so,再使用python的ctypes调用即可。(1)C语言文件:pycall.c/***gcc -o libpycall.so -shared -fPIC pycall.c*/ #include <stdio.h> ...转载 2021-06-16 10:06:00 · 638 阅读 · 0 评论 -
C/CPP Dreadful Typos
Here are some typos I made that cannot be detected by the compiler and there seems to be little原创 2021-06-15 16:21:03 · 197 阅读 · 2 评论 -
c++指针运算
指针运算指针变量有以下运算: 1)两个同类型的指针变量,可以比较大小 2)两个同类型的指针变量,可以相减 3)指针变量可以和 整数类型变量或常量 相加 4)指针变量可以 减去一个整数类型变量或常量 5)指针变量可以 自增,自减1)两个同类型的指针变量,可以比较大小 比较大小的意思是:p1,p2是两个同类型的指针,那么,如果地址p1<地址2,则表达式“p1<p2”的值就为真,反之亦然。p1>p2,p1==p2的意义同样好理解2...转载 2021-06-11 16:38:26 · 1224 阅读 · 1 评论 -
typedef int a[10];怎么解释?
typedefinta[10];ab[10];为什么分配400个字节的空间?inta[10];为什么分配了40个字节的空间?问题:应该怎么解释typedef的这种行为呢?而如果换成是#defineaint[10];以上定义则报错?typedef int a[10];说明a就等同于int[10]类型。。所以a b[10];//等同与int b[10][10];而inta[10];这里的a代表的不是类型。。而是数组名。。而#defi...转载 2021-06-01 15:36:07 · 561 阅读 · 0 评论 -
C++: string to double
C++ Convert String to Double Speed(There is also astring-to-int performance test.)A performance benchmark of which method is faster of converting an std::string to a double. The goal is ending up with a double of the value represented in an std::strin.转载 2021-05-31 11:40:04 · 16070 阅读 · 0 评论 -
No “Continue“ for “Switch“, but Its Outer Loop
循环内的switch中break和continue使用区别 首先看下break和continue的使用方法。break语句在循环和switch语句中使用,用于终止最近的封闭代码块,如果在嵌套循环中,则只终止最近的循环。continue语句在循环中使用,不能单独在switch中使用,可以在循环内的switch中使用,用于跳过当次循环,直接进入下一次循环。 再看下两者在循环内的switch中使用的区别。1、看一个循环内的switch中使用break的例子: 1 p.转载 2021-05-27 20:53:12 · 126 阅读 · 0 评论 -
c++: 移动构造/赋值 和 拷贝构造/赋值
Copy Constructor vs. Assignmenthttps://blog.youkuaiyun.com/u013904227/article/details/107441848Move Constructorhttp://c.biancheng.net/view/7847.htmlMove Assignmenthttps://www.cnblogs.com/Joezzz/p/9707512.html转载 2021-05-20 22:23:25 · 3031 阅读 · 0 评论 -
Cpp: STL Container::size() Return Type is Unsigned Int
(screenshot from http://www.cplusplus.com/reference/vector/vector/size/)thereforeassert (vec.size() > -1);will always fail, since -1 is upgraded to unsigned int type in implicit conversion during comparisionand becomes the largest unsigned in...原创 2021-05-19 10:12:14 · 116 阅读 · 1 评论 -
c++: comma operator
So, one day I forgot to put "max" before "()" in practice and got something like:int a;int arr[10] = {1,2,3,4,5,6,7,8,9,10};for (int i=1; i<10; i++){a = arr[i-1], arr[i]; //vs. a = (arr[i-1], arr[i]); 本地测试(gcc 8.1) //前者取ar...原创 2021-05-01 16:52:20 · 255 阅读 · 0 评论 -
Cpp Char Type-checking Functions
isdigitCStrings libraryNull-terminated byte strings Defined in header<ctype.h> intisdigit(intch); Checks if the given character is a numeric character (0123456789).The behavior...转载 2021-04-29 11:32:09 · 90 阅读 · 0 评论 -
Malloc in Linux
linux环境内存分配原理 mallocinfoLinux的虚拟内存管理有几个关键概念:Linux 虚拟地址空间如何分布?malloc和free是如何分配和释放内存?如何查看堆内内存的碎片情况?既然堆内内存brk和sbrk不能直接释放,为什么不全部使用 mmap 来分配,munmap直接释放呢 ?Linux的虚拟内存管理有几个关键概念:1、每个进程都有独立的虚拟地址空间,进程访问的虚拟地址并不是真正的物理地址;2、虚拟地址可通过每个进程上的页表(在每个进程的内核虚拟地址空间)与物理地址进行映.转载 2021-04-26 13:05:09 · 102 阅读 · 0 评论 -
lib/dll 动静链接(转)
fromhttps://segmentfault.com/a/1190000022690350链接库无欲则刚发布于2020-05-20链接库为什么需要链接库?我们在编写程序时,会包含大量的库,如标准C库、标准数学库。这些我们不需要从头编写,因为从头编写可能要和API打交道,甚至像正弦函数这些函数自己写很难优化到最好。这就要求我们使用许多第三方程序代码第三方程序代码如何通过链接和程序建立关系?我们可以把常用的函数放到一个.c文件里,然后生成一个可重定位目标文件.o,再链接生..转载 2021-03-15 11:57:00 · 168 阅读 · 0 评论 -
Short Notes: Cpp (Unordered)Map erase(by key)
fromhttps://en.cppreference.com/w/cpp/container/map/erase===> overload type(3) ==> erase element by key supported.转载 2021-03-21 22:06:06 · 104 阅读 · 0 评论 -
Short Notes: Cpp STL begin/end, rend/rbegin
!!!!reverse_iterator and iterator are two different members ==> they cannot be compared to each other转载 2021-03-21 22:10:39 · 179 阅读 · 0 评论 -
Extern 作用及使用(合转)
1.extern作用详解extern 作用1:声明外部变量现代编译器一般采用按文件编译的方式,因此在编译时,各个文件中定义的全局变量是互相透明的,也就是说,在编译时,全局变量的可见域限制在文件内部。例1:创建一个工程,里面含有A.cpp和B.cpp两个简单的C++源文件://A.cpp:int iRI;int main(){//.....}//B.cppint iRI;gcc A.cpp -cgcc B.cpp -c编译出A.o, B.o都没有问题。但当gcc A.转载 2021-04-19 22:54:31 · 1628 阅读 · 0 评论 -
C++ 头文件和源文件
from:https://www.cnblogs.com/fenghuan/p/4794514.htmlC++中头文件(.h)和源文件(.cpp)都应该写些什么头文件(.h):写类的声明(包括类里面的成员和方法的声明)、函数原型、#define常数等,但一般来说不写出具体的实现。在写头文件时需要注意,在开头和结尾处必须按照如下样式加上预编译语句(如下):#ifndefCIRCLE_H#defineCIRCLE_H//你的代码写在这里#endif...转载 2021-04-18 22:50:57 · 2423 阅读 · 0 评论 -
C++ 20 Features and Issues
Issue: "Modern" C++ Lamentations"Modern" C++ LamentationsPosted onDec 28, 2018#code#compilers#rantThis will be a long wall of text, and kinda random! My main points are:C++ compile times are important, Non-optimized build performance is impo...转载 2021-04-15 16:36:53 · 16369 阅读 · 0 评论 -
C++ Chain Operations
example for chain-assignment:https://blog.youkuaiyun.com/qq_38213586/article/details/84639595from:https://www.cnblogs.com/yutingliuyl/p/7214564.htmlC++中的链式操作代码编译环境:Windows7 32bits+VS2012。1.什么是链式操作链式操作是利用运算符进行的连续运算(操作)。它的特点是在一条语句中出现两个或者两个以上相同的...转载 2021-04-14 18:00:08 · 161 阅读 · 0 评论 -
C++: Const vs. Constexpr 合并转
constexpr can be checked in compiling stage and used in conditionals with auto and templatesexample for constexpr in condtionals:#include <iostream>#include <vector>using namespace std;//auto + constexprtemplate <int div, typename.转载 2021-04-11 12:39:17 · 158 阅读 · 0 评论 -
Notes on c_str (char*, char [], const char*) vs. string
Related Content:sizeof和strlen的区别及使用详解highlighted comments:c/c++中sizeof()、strlen()、length()、size()详解和区别==> string::length() == string::size(); the former is for c_str compatiability, latter is for STLC语言 char *、char []、const char *、stri..原创 2021-04-04 21:35:35 · 116 阅读 · 0 评论 -
Cpp: template (basics, dependency, parameter pack and fold-expression)
details on the basics of template:https://www.runoob.com/w3cnote/c-templates-detail.htmlfold-expression:https://blog.youkuaiyun.com/ding_yingzi/article/details/79973809#comments_14938298dependency:https://blog.youkuaiyun.com/maxzcl/article/details/115428968...转载 2021-04-04 18:07:33 · 271 阅读 · 0 评论 -
Template, Typename and Dependency
from:https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords(Seehere also for my C++11 answer)In order to parse a C++ program, the compiler needs to know whether certain names are types or not. The..转载 2021-04-04 15:43:17 · 250 阅读 · 0 评论 -
Cpp STL Memory and Growth Management 转
from:https://blog.youkuaiyun.com/sinat_24520925/article/details/44487689Vector是STL中最常见的容器,它占用的是一块连续分配的内存,从数据存储角度来讲,和数组极其相似,不同的是:数组是静态分配空间,一旦分配了空间的大小就不可以再改变了,而VECTOR是动态分配空间,随着元素的不断增加,它会按照自身的一套增长机制不断扩充自身的容量。扩容机制:按照容器现有容量的一倍进行增长。由于vector容器分配的是一块连续的内存空间,...转载 2021-03-28 16:56:31 · 82 阅读 · 0 评论