<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8995455167205656082</id><updated>2026-08-29T15:20:35.362-07:00</updated><category term="Total"/><category term="Python"/><category term="OpenCV"/><category term="C++"/><category term="C/MFC"/><category term="aws"/><category term="CUDA"/><category term="Deep learning"/><category term="GPU"/><category term="C"/><category term="Math"/><category term="docker"/><category term="pytorch"/><category term="MFC"/><category term="ubuntu"/><category term="Arduino"/><category term="numpy"/><category term="s3"/><category term="Histogram"/><category term="Matlab"/><category term="Tip"/><category term="pandas"/><category term="ANPR"/><category term="Background subtraction"/><category term="cv2"/><category term="lambda"/><category term="linux"/><category term="opencv 3.0"/><category term="Opencv Build"/><category term="PIL"/><category term="Sensor"/><category term="Visual Studio"/><category term="string"/><category term="tensor flow"/><category term="Geometry"/><category term="OpenGL"/><category term="git"/><category term="list"/><category term="tensorflow"/><category term="Data"/><category term="Distributed Training"/><category term="Equipment"/><category term="HOG feature"/><category term="Mat"/><category term="NLP"/><category term="TBB"/><category term="jupyter"/><category term="pillow"/><category term="torch"/><category term="Logic"/><category term="Optical flow"/><category term="STL"/><category term="Stitching"/><category term="Tracking"/><category term="amd"/><category term="argparse"/><category term="build"/><category term="ec2"/><category term="s3 bucket"/><category term="surf"/><category term="AdaBoost"/><category term="ComputerVision"/><category term="HIP"/><category term="Image Processing"/><category term="Pedestrian detection"/><category term="SVM"/><category term="YouTube"/><category term="calcHist"/><category term="dense optical flow"/><category term="findContours"/><category term="google object detection api"/><category term="json"/><category term="lpr"/><category term="matching"/><category term="notebook"/><category term="sklearn"/><category term="tensor"/><category term="threshold"/><category term="Canny Edge"/><category term="MOG2"/><category term="Machine Lerning"/><category term="MachineLearning"/><category term="Pedestrian tracking"/><category term="Shuffle"/><category term="Tools"/><category term="Tutorial"/><category term="VideoCapture"/><category term="c++ 20"/><category term="constexpr"/><category term="db"/><category term="fsdp"/><category term="iOS"/><category term="image data"/><category term="onnx"/><category term="pymupdf"/><category term="random"/><category term="setMouseCallback"/><category term="split"/><category term="token"/><category term="transformers"/><category term="vector"/><category term="ComfyUI"/><category term="Directory"/><category term="Django"/><category term="Dynamodb"/><category term="Keras"/><category term="Mac"/><category term="Projects"/><category term="ROCm"/><category term="SIFT"/><category term="Serial Communication"/><category term="Unsolved Algorithm ( I need your thought )"/><category term="VTK"/><category term="auc"/><category term="autotokenizer"/><category term="consteval"/><category term="csv"/><category term="cudnn"/><category term="cvtColor"/><category term="dict"/><category term="download YouTube"/><category term="drawContours"/><category term="glob"/><category term="hugging face"/><category term="llm"/><category term="metrics"/><category term="mouse event"/><category term="os"/><category term="panorama"/><category term="pdf"/><category term="python opencv"/><category term="python3"/><category term="pytorch lightning"/><category term="string functions"/><category term="template"/><category term="tensor flow install"/><category term="terminal"/><category term="time"/><category term="tokenizer"/><category term="vs code"/><category term="yaml"/><category term="Amazon Linux"/><category term="Binary"/><category term="CString"/><category term="Calibration"/><category term="CrossEntropyLoss"/><category term="FarnebackOpticalFlow"/><category term="File exist"/><category term="GEMM"/><category term="IREE"/><category term="K-means"/><category term="LicensePlateRecognition"/><category term="OpenCV300"/><category term="Parallel"/><category term="PyCharm"/><category term="SVD"/><category term="Sort"/><category term="adaptive threshold"/><category term="ai"/><category term="base64image"/><category term="bert"/><category term="bitwise_not"/><category term="blockDim"/><category term="blur"/><category term="csr_matrix"/><category term="curl"/><category term="cvlecture"/><category term="dataset"/><category term="download video from YouTube"/><category term="error"/><category term="fashion attribute recognition"/><category term="fashion for ai"/><category term="fitz"/><category term="github"/><category term="gpu memory"/><category term="gridDim"/><category term="homography"/><category term="loss"/><category term="mlir"/><category term="nvcc"/><category term="object detection"/><category term="onnxruntime"/><category term="opencv python"/><category term="path"/><category term="pickle"/><category term="pil image"/><category term="processing time"/><category term="python lightning"/><category term="pytube"/><category term="qt"/><category term="randn"/><category term="rect"/><category term="rectangle"/><category term="scipy.sparse"/><category term="solution"/><category term="trackbar"/><category term="tuple"/><category term="virtualenv"/><category term="xml"/><category term="yaml to dict"/><category term="zip"/><category term="3dm-gx3"/><category term="Android"/><category term="ArgumentParser"/><category term="Azure"/><category term="BERT Tokenizer"/><category term="C Module"/><category term="Camera moving check"/><category term="Clustering"/><category term="Color Channels"/><category term="DeepLearning"/><category term="Diffusion Model"/><category term="Django db"/><category term="EMD"/><category term="Encode"/><category term="GPU programming"/><category term="Get pixel"/><category term="GpuMat"/><category term="HMM"/><category term="Hough Transform"/><category term="LED controll"/><category term="LSTM"/><category term="LUT"/><category term="Led on/off"/><category term="MSER"/><category term="Matlab coder"/><category term="MongoDB"/><category term="Morphology"/><category term="Moving Average"/><category term="OTZU"/><category term="OpenCV Lecture"/><category term="Optimization"/><category term="Overlap ratio"/><category term="PCA"/><category term="Performance"/><category term="ROI"/><category term="RTSP"/><category term="ReSize"/><category term="Ruff"/><category term="String and char*"/><category term="Thread"/><category term="VideoWriter"/><category term="Window"/><category term="Window 2008"/><category term="YUV"/><category term="YUV422"/><category term="ai model"/><category term="anaconda"/><category term="and"/><category term="ascii"/><category term="augmentation"/><category term="barcode"/><category term="base64"/><category term="bitwise_and"/><category term="bitwise_or"/><category term="bitwise_xor"/><category term="blockIdx"/><category term="boto3"/><category term="boundingRect"/><category term="bucket"/><category term="camera calibration"/><category term="canny"/><category term="centos"/><category term="circle"/><category term="clear"/><category term="compare"/><category term="concept"/><category term="conda"/><category term="condensation"/><category term="copyTo"/><category term="create folder"/><category term="crop"/><category term="custom node"/><category term="cvFindContours"/><category term="data access"/><category term="datetime"/><category term="deep learnining"/><category term="default arguments"/><category term="dict shuffle"/><category term="docker stop"/><category term="docker swarm"/><category term="draw line"/><category term="face data"/><category term="face detection"/><category term="file"/><category term="filter-branch"/><category term="font"/><category term="fp32"/><category term="fp8"/><category term="g++"/><category term="grep"/><category term="grid"/><category term="handwritten"/><category term="hipBLASlt"/><category term="histogram stretch"/><category term="iOS development"/><category term="int to string"/><category term="integral"/><category term="iou"/><category term="ipython"/><category term="ipywidgets"/><category term="json.load"/><category term="label"/><category term="labelme"/><category term="lightning"/><category term="line equation"/><category term="link"/><category term="llama 3.1 8b"/><category term="llvm"/><category term="lsof"/><category term="makedirs"/><category term="matplotlib"/><category term="meanshift"/><category term="merge"/><category term="minmax"/><category term="mkdir"/><category term="model evaluation"/><category term="mosaic"/><category term="next"/><category term="normalize"/><category term="not"/><category term="nvidia"/><category term="ocr"/><category term="opencv control"/><category term="or"/><category term="os.path"/><category term="paginate"/><category term="paginator"/><category term="pandas_datareader"/><category term="particle filter"/><category term="pathlib"/><category term="pdf2img"/><category term="pedestrian"/><category term="perspective"/><category term="potentiometer"/><category term="print"/><category term="putText"/><category term="pycocotools"/><category term="regular"/><category term="requires"/><category term="roc"/><category term="roc curve"/><category term="screen"/><category term="set"/><category term="shell script"/><category term="shutil"/><category term="signature"/><category term="ssh"/><category term="string compare"/><category term="string split"/><category term="swift"/><category term="tensor core"/><category term="tensorflow gpu"/><category term="threadIdx"/><category term="tp"/><category term="transformer"/><category term="update print"/><category term="utuntu"/><category term="vlc"/><category term="vscode"/><category term="vstack"/><category term="warp"/><category term="xor"/><category term="xz"/><category term="yolo"/><category term="youtube-dl"/><category term="yum"/><category term="*.flo"/><category term=".gitignore"/><category term=".screenrc"/><category term="2 box"/><category term="2D threads"/><category term="2d array"/><category term="3d asset"/><category term="4 points ordering"/><category term="8 points"/><category term="8K video"/><category term="ABI"/><category term="ACF"/><category term="ADAPTIVE_THRESH_GAUSSIAN_C"/><category term="ADAPTIVE_THRESH_MEAN_C"/><category term="ADASYN"/><category term="ALPR"/><category term="AMP"/><category term="API"/><category term="APM setup"/><category term="AWS SAM"/><category term="AdamOptimizer"/><category term="AdaptiveThreshold"/><category term="Add row to mat"/><category term="Advanced"/><category term="AfxExtractSubString"/><category term="Alps"/><category term="Armadillo"/><category term="Auto-generated summaries"/><category term="AutoImageProcessor"/><category term="AutoProcessor"/><category term="AutoQuantizationConfig"/><category term="Autoencoder"/><category term="Azure function"/><category term="BackgroundSubtractor"/><category term="BeautifulSoup"/><category term="Benchmarks"/><category term="Blob labeling"/><category term="Boosting Tracker"/><category term="BringWindowToTop"/><category term="Bumblebee"/><category term="ByteIO"/><category term="BytesIO"/><category term="C#"/><category term="CAD"/><category term="CERTIFICATE_VERIFY_FAILED"/><category term="CFileDialog"/><category term="CICD"/><category term="CIPAddressCtrl"/><category term="CK library"/><category term="CNN"/><category term="CString to char*"/><category term="CString to string"/><category term="CUBLAS_STATUS_INVALID_VALUE"/><category term="CUDA Video Codec"/><category term="CUDA by example"/><category term="CUDA error"/><category term="CUDA_ARCH_BIN"/><category term="CV_CAP_PROP_FRAME_HEIGHT"/><category term="CV_CAP_PROP_FRAME_WIDTH"/><category term="CV_HOUGH_GRADIENT"/><category term="CV_THRESH_BINARY"/><category term="CamShift"/><category term="CameraParams"/><category term="CascadeClassifier"/><category term="CascadeClassifier_GPU"/><category term="Ceiling division"/><category term="Claude"/><category term="Claude Code"/><category term="Clone"/><category term="CloudComputing"/><category term="Color Matching"/><category term="Color convert"/><category term="ComfyUI multi execute"/><category term="Computer Vision"/><category term="Container"/><category term="Containers"/><category term="Creating DLL"/><category term="Cstring to int"/><category term="DDPPlugin"/><category term="DDPStrategy"/><category term="DUN"/><category term="DUNS"/><category term="DXF"/><category term="DXVA"/><category term="Data Persistence"/><category term="Data Persistence. total"/><category term="Data Visualization"/><category term="DataReader"/><category term="Decimals"/><category term="Decimals format"/><category term="DecisionTreeRegressor"/><category term="Decode"/><category term="Deployment"/><category term="DevOps"/><category term="Distributed"/><category term="Docker command"/><category term="Download s3 object as opencv image in memory and upload too"/><category term="Driver"/><category term="ECR"/><category term="EEG"/><category term="EEG research"/><category term="EGG dataset"/><category term="EPYC"/><category term="Edge"/><category term="Elastic"/><category term="EnumWindows"/><category term="Extract File Name"/><category term="F.pad"/><category term="FREAK"/><category term="FastAPI"/><category term="FastFeatureDetector"/><category term="Feature extraction"/><category term="File Ext"/><category term="File I/O"/><category term="File Path"/><category term="File Uploads"/><category term="File delete"/><category term="FileNode"/><category term="FileNodeIterator"/><category term="FileStorage"/><category term="Filter"/><category term="Flask"/><category term="Floyd–Steinberg"/><category term="Free"/><category term="FreeAPI"/><category term="GCN"/><category term="GNN"/><category term="GPU_MAX_HW_QUEUES"/><category term="GaussianBlur"/><category term="Generative AI"/><category term="GetCurrentDirectory"/><category term="GetMacAddress"/><category term="GetProcessId"/><category term="GetTickCount"/><category term="Git hub"/><category term="Graph"/><category term="GroupShuffleSplit"/><category term="HSV to Conic"/><category term="HSV to Cylindric"/><category term="HSV to RGB"/><category term="HTTPServer"/><category term="Handwritten Digit Recognition"/><category term="Hip programming"/><category term="HoughCircles"/><category term="ICF"/><category term="IProgress"/><category term="IProgress not found"/><category term="IREE turbine"/><category term="Image Retrieval"/><category term="Image Tagging"/><category term="Image write"/><category term="ImageFont"/><category term="ImageOps"/><category term="Images"/><category term="Inhomogeneous linear system"/><category term="Integration"/><category term="Inteligent System"/><category term="Interpolation"/><category term="Kalman Filter"/><category term="KeyPoint"/><category term="LPCTSTR"/><category term="LSTM Autoencoder"/><category term="LSTMStateTuple"/><category term="Language models"/><category term="Laplacian"/><category term="Large language models"/><category term="LayoutLMv3ForTokenClassification"/><category term="LayoutLMv3Tokenizer"/><category term="Line fitting"/><category term="LinearRegression"/><category term="ListBox"/><category term="Look up table"/><category term="MAC address"/><category term="MBCS"/><category term="MIL tracker"/><category term="MLP"/><category term="MMC"/><category term="MNIST"/><category term="MSB8031"/><category term="MSELoss"/><category term="Mac util"/><category term="Mac window"/><category term="MacAddress"/><category term="MacBook"/><category term="Magic Keyboard"/><category term="Make"/><category term="Mat to UMat"/><category term="MatND"/><category term="Matrix operation"/><category term="MobileApp"/><category term="Models"/><category term="Mounting Remote Data for GPU Training"/><category term="Multi GPU"/><category term="Multi-Architecture"/><category term="MultiscaleDetector"/><category term="My Copyright"/><category term="NLP (Natural Language Processing)"/><category term="Nested List"/><category term="No module named &#39;pytorch3d&#39;"/><category term="ORB"/><category term="ORTModelForTokenClassification"/><category term="ORTQuantizer"/><category term="OnDevice"/><category term="OpenCL"/><category term="OpenMP"/><category term="Opencv python mat creation"/><category term="OrderDict"/><category term="OutputDebugString"/><category term="PEP-604"/><category term="PYTHONHASHSEED"/><category term="PYTHONPATH"/><category term="PaLM (Pathways Language Model)"/><category term="ParkingManagement"/><category term="Path Planning"/><category term="Privacy"/><category term="Python random"/><category term="Python36"/><category term="QString"/><category term="Quntenion"/><category term="RCCL"/><category term="RGB histogram"/><category term="RGB to HSV"/><category term="RNN"/><category term="RS232c"/><category term="RSA"/><category term="RT from 2 points"/><category term="RandomForestRegressor"/><category term="Real time Stitching"/><category term="Rect Bound"/><category term="Roberta"/><category term="Roberta-base"/><category term="RoratedRect"/><category term="Rotation Matrix"/><category term="SHELLEXECUTEINFO"/><category term="SLAM"/><category term="SMOTE"/><category term="SQlite3"/><category term="Search Algorithms total"/><category term="Security"/><category term="Sequence Parallel(SP)"/><category term="Series"/><category term="ServerlessFramework"/><category term="Shape"/><category term="Shape from Shading"/><category term="ShellExecuteEx"/><category term="Stabilizing"/><category term="Swap File"/><category term="Swizv2Model"/><category term="TCHAR"/><category term="TCHAR to string"/><category term="THRESH_OTSU"/><category term="Tensorboard"/><category term="Tensorflow object detection"/><category term="TerminateProcess"/><category term="Testing"/><category term="Text Features"/><category term="The AttributeError"/><category term="Thread build blocks"/><category term="ThreadPoolExecutor"/><category term="TimeDistributed"/><category term="TinyXML"/><category term="Tracker"/><category term="Transformer architecture"/><category term="Transformer engine"/><category term="Trash dumping detection"/><category term="Triton"/><category term="Troubleshooting"/><category term="UMat"/><category term="UMat to Mat"/><category term="USB to Serial"/><category term="VDPAU"/><category term="VO_MSE_FUNC_THROUGH_POINTERS"/><category term="VS 2013"/><category term="VideoProcessing"/><category term="Vision Odometry"/><category term="Visual Features"/><category term="VisualStudio"/><category term="WD14"/><category term="WMMA"/><category term="WYSIWYG"/><category term="WaldBoost"/><category term="WideCharToMultiByte"/><category term="WinCE"/><category term="Workflow"/><category term="WtoC"/><category term="X-macro"/><category term="Xcode"/><category term="YCbCr"/><category term="Yard Trailer"/><category term="YouTube cv2"/><category term="YouTube download"/><category term="YouTube playlist"/><category term="YouTube streaming"/><category term="_CRT_SECURE_NO_WARNINGS"/><category term="_Py_ZeroStruct"/><category term="_atoi"/><category term="_wtoi"/><category term="absdiff"/><category term="access pixel"/><category term="addWeighted"/><category term="adpativeThreshold"/><category term="albumentations"/><category term="all"/><category term="amd64"/><category term="and t3.medium"/><category term="annotation"/><category term="anpr sdk"/><category term="apple"/><category term="apple iPhone"/><category term="applyColorMap"/><category term="area under curve"/><category term="argparse.ArgumentParser"/><category term="arial"/><category term="arial bold"/><category term="arm64"/><category term="array"/><category term="at"/><category term="attrdict"/><category term="augment"/><category term="auto"/><category term="aws bedrock"/><category term="aws gpu ec2"/><category term="aws gpu mem comparison"/><category term="aws lambda"/><category term="aws linux"/><category term="aws rag"/><category term="awscli"/><category term="awscli python"/><category term="b64decode"/><category term="background image"/><category term="beam"/><category term="beam search"/><category term="beam searcher"/><category term="bedrock"/><category term="beginners"/><category term="bertsum"/><category term="bfg"/><category term="bfloat16"/><category term="bin/bash"/><category term="binary inverted"/><category term="binary string to image"/><category term="bits"/><category term="blas"/><category term="blkid"/><category term="box intersection"/><category term="box mosaic"/><category term="box pixelate"/><category term="bs4"/><category term="build a dataset for video classification"/><category term="byte 2 image"/><category term="byte to img"/><category term="byte to mat"/><category term="byte2img"/><category term="byte2mat"/><category term="c++/c"/><category term="c++20"/><category term="c5"/><category term="calculus"/><category term="calendar"/><category term="cam search"/><category term="camera"/><category term="camera model"/><category term="car number plate"/><category term="car number plate image"/><category term="ceemple"/><category term="ceiling"/><category term="center xy with height"/><category term="change dpi"/><category term="change file name"/><category term="char * to LPCTSTR"/><category term="char* to LPWSTR"/><category term="char* to tchar*"/><category term="check dependencies"/><category term="check file exist"/><category term="check gpu support"/><category term="check repo size"/><category term="check single color"/><category term="check sum"/><category term="check ubuntu version"/><category term="checkpoint"/><category term="ck"/><category term="ck tile"/><category term="ckeditor"/><category term="ckpt"/><category term="classification_report"/><category term="clean Mac"/><category term="clear output"/><category term="closures"/><category term="clothing parsing"/><category term="cluster"/><category term="cmake"/><category term="cmakelist.txt"/><category term="coco v2"/><category term="code detector"/><category term="code snippet"/><category term="collapse all"/><category term="color"/><category term="color segment"/><category term="comma operator"/><category term="compare string"/><category term="compare work"/><category term="compile-time constants"/><category term="composal kernel"/><category term="compute class weight"/><category term="compute loss"/><category term="concurrent"/><category term="configure"/><category term="configure_optimizers"/><category term="constant"/><category term="construal"/><category term="container ip"/><category term="container size"/><category term="contains"/><category term="contourArea"/><category term="convnext_base"/><category term="convolution"/><category term="coordinate"/><category term="coordinate convert"/><category term="copy"/><category term="copy file"/><category term="copy header"/><category term="copy_object"/><category term="coral"/><category term="coral edge tpu"/><category term="cost_sensitive_learning"/><category term="count zero"/><category term="create directory"/><category term="createBackgroundSubtractorGMG"/><category term="createBackgroundSubtractorKNN"/><category term="createBackgroundSubtractorMOG"/><category term="createBackgroundSubtractorMOG2"/><category term="csr matrix"/><category term="ctime"/><category term="ctime_s"/><category term="ctypes"/><category term="cublas"/><category term="cuda 11.2"/><category term="cuda 116"/><category term="cuda 117"/><category term="cuda available"/><category term="cuda check"/><category term="cuda setting"/><category term="cudaDeviceMapHost"/><category term="cudaHostAlloc"/><category term="cudaHostGetDevicePointer"/><category term="cudaSetDeviceFlags"/><category term="cudnn error"/><category term="curier"/><category term="current time"/><category term="custom checkpoint"/><category term="custom node for comfyui"/><category term="custom tokenizer"/><category term="cv2 to json"/><category term="cv2 to string"/><category term="cv2.findContours"/><category term="cv2.putText"/><category term="cv2.rectangle"/><category term="cvCalcBackProjectPatch"/><category term="cvCreateMemStorage"/><category term="cvCvtPixToPlane"/><category term="cvCvtPlaneToPix"/><category term="cvDrawContours"/><category term="cvIsNaN"/><category term="cvLoadImage"/><category term="cvSaveImage"/><category term="cvThreshold"/><category term="dash line"/><category term="data dump"/><category term="data validation"/><category term="data_preprocessing"/><category term="dataclasses"/><category term="dataset augment"/><category term="date"/><category term="dateutil"/><category term="deadlines"/><category term="decimal"/><category term="decrease node"/><category term="decryption"/><category term="deep_learning"/><category term="deformable part models"/><category term="delimiter"/><category term="dependencies"/><category term="desktop"/><category term="detach"/><category term="detectMultiScale"/><category term="detection"/><category term="detector"/><category term="dic to json"/><category term="dict item"/><category term="dict key to list"/><category term="dict next"/><category term="dict order"/><category term="dict order shuffle"/><category term="dict to yaml"/><category term="dirname"/><category term="dispatcher pattern"/><category term="display"/><category term="dithering"/><category term="dlib"/><category term="docker Build"/><category term="docker Commands"/><category term="docker Images"/><category term="docker List"/><category term="docker Log"/><category term="docker Prune"/><category term="docker Pull"/><category term="docker Push"/><category term="docker Remove"/><category term="docker deploy to azure function"/><category term="docker image size"/><category term="docker-machine"/><category term="dominant hz retrive"/><category term="download"/><category term="download models from hugging face"/><category term="dpi"/><category term="dpm"/><category term="draw"/><category term="draw image grid"/><category term="dump"/><category term="dumps"/><category term="duplicated"/><category term="duplicated string finder"/><category term="each character in string"/><category term="ean13"/><category term="easydict"/><category term="ec2 instance"/><category term="eclipse"/><category term="eda"/><category term="edge tpu"/><category term="eigen value"/><category term="eigen vector"/><category term="electroencephalogram"/><category term="element exist"/><category term="ellipse"/><category term="embedding"/><category term="empty DataFrame"/><category term="encryption"/><category term="end"/><category term="enum class"/><category term="equalizeHist"/><category term="example image"/><category term="exception"/><category term="exclude rsync"/><category term="exif"/><category term="expand all"/><category term="exponential"/><category term="exponential notation"/><category term="export onnx"/><category term="export transfomer to onnx"/><category term="extra information image"/><category term="ezdxf"/><category term="f1"/><category term="face mosaic"/><category term="face pixelate"/><category term="fallocate"/><category term="fashion dataset"/><category term="fc layer"/><category term="feature_extractor"/><category term="ffmpeg_cmd"/><category term="ffmpeg_proc"/><category term="fiilConvexPoly"/><category term="file_count"/><category term="find all extension"/><category term="find all file list"/><category term="find file"/><category term="find optimal clustering number"/><category term="findHomography"/><category term="find_unused_parameters"/><category term="finding file"/><category term="fixtures"/><category term="flatten"/><category term="float decimal"/><category term="float dtype"/><category term="floodFill"/><category term="fold expressions"/><category term="folder check in s3"/><category term="folder exist in s3"/><category term="font download"/><category term="fonts"/><category term="food forecast"/><category term="food order forecast"/><category term="for auto"/><category term="for each"/><category term="for loop"/><category term="for_each"/><category term="forward algorithm"/><category term="fp16"/><category term="frame difference"/><category term="free font"/><category term="frontal face images"/><category term="fsdp_config.activation_checkpointing"/><category term="fsdp_config.activation_checkpointing_reentrant"/><category term="fstab"/><category term="full-image information extraction"/><category term="fully connected"/><category term="fultter"/><category term="fuzzy"/><category term="fuzzy wuzzy"/><category term="gcc"/><category term="gen image"/><category term="generate barcode number"/><category term="get Mac address"/><category term="get YouTube list"/><category term="get YouTube video url"/><category term="get ext"/><category term="get file list"/><category term="get file name"/><category term="get first item in dict"/><category term="get list from dir"/><category term="get torch list"/><category term="getRotationMatrix2D"/><category term="get_object"/><category term="get_paginator"/><category term="getsitepackages"/><category term="ghost"/><category term="git 100mb"/><category term="git big file"/><category term="git delete 100mb"/><category term="git delete all commits history"/><category term="git delete history"/><category term="git large file"/><category term="glob.glob"/><category term="google"/><category term="google calendar"/><category term="google coral"/><category term="gpu delay"/><category term="gpu device"/><category term="gpu monitoring"/><category term="gpu shark"/><category term="gpustat"/><category term="gradient"/><category term="graph compare"/><category term="graph neural network"/><category term="graph similarity"/><category term="grid detector"/><category term="hangul"/><category term="heic"/><category term="heic to jpg"/><category term="hide directory"/><category term="hipblas"/><category term="hipdnn"/><category term="histo"/><category term="histogram equalization"/><category term="home"/><category term="home/end"/><category term="hook layer"/><category term="hough circle"/><category term="hpcc"/><category term="hstack"/><category term="hsv"/><category term="html 2 pdf"/><category term="html parsing"/><category term="html2pdf"/><category term="hue"/><category term="hue histogram"/><category term="hugging face model"/><category term="hugging face model download"/><category term="human attribute"/><category term="human dataset"/><category term="human detection dataset"/><category term="ico"/><category term="idx2label"/><category term="if constexpr"/><category term="ignore warning"/><category term="image augment"/><category term="image captionning"/><category term="image comparing"/><category term="image db"/><category term="image effect"/><category term="image exif"/><category term="image grid"/><category term="image iou"/><category term="image stretching"/><category term="image to text"/><category term="imbalanced_data"/><category term="img to ico"/><category term="imgaug"/><category term="imread"/><category term="imwrite"/><category term="in list"/><category term="in rect"/><category term="indentations"/><category term="indention"/><category term="infinite data load"/><category term="infinite data loader"/><category term="init.d"/><category term="install"/><category term="install dlib"/><category term="install docker"/><category term="install korean on Ubuntu"/><category term="install python"/><category term="instance segmentation"/><category term="interp1d"/><category term="interpolate"/><category term="intersect of union"/><category term="intersector by numpy"/><category term="intrinsic parameters"/><category term="invert_power_of_first_significant"/><category term="invoke"/><category term="ip2geometry"/><category term="ip2geotools"/><category term="iphone"/><category term="ir"/><category term="iris dataset"/><category term="item"/><category term="iter"/><category term="itoa"/><category term="ius-release.rpm"/><category term="json fail"/><category term="json float32 error"/><category term="json serializable"/><category term="json.dumps"/><category term="julia set"/><category term="jupyter draw image"/><category term="jupyter imshow"/><category term="jupyter show image"/><category term="kaggle"/><category term="kaggle authenticate"/><category term="keras layers"/><category term="keras model"/><category term="keras summary"/><category term="keycode"/><category term="kill"/><category term="kill process"/><category term="kmean"/><category term="kmeans"/><category term="knn"/><category term="kohya"/><category term="kohya-ss"/><category term="label2idx"/><category term="labelme2yolo"/><category term="lambda client"/><category term="lambda invoke"/><category term="lambda layer"/><category term="lambda pack"/><category term="large file"/><category term="largest file"/><category term="last_hidden_state"/><category term="late binding"/><category term="latent svm"/><category term="layoutlmv3"/><category term="layoutlmv3_model"/><category term="learning rate"/><category term="left top right bottom"/><category term="lib"/><category term="libGL.so"/><category term="libSM"/><category term="libcudnn"/><category term="libheif"/><category term="license plate"/><category term="lightgbm"/><category term="line"/><category term="line by line"/><category term="linear regression"/><category term="linking"/><category term="linspace"/><category term="list of list"/><category term="list reverse"/><category term="list string to list"/><category term="list to batch tensor"/><category term="list to tensor"/><category term="list to tuple"/><category term="list_object_v2"/><category term="list_objects_v2"/><category term="llama 70b"/><category term="llama model"/><category term="load json"/><category term="load text"/><category term="load_stated_dict"/><category term="loads"/><category term="loggers"/><category term="logits"/><category term="lora"/><category term="lr"/><category term="lxml"/><category term="machine_learning"/><category term="macos"/><category term="makdir"/><category term="make directory"/><category term="make folder"/><category term="make folder if not exist"/><category term="make folder python"/><category term="make grid"/><category term="make zip"/><category term="manual_seed"/><category term="manual_seed_all"/><category term="map_coordinates"/><category term="marearts"/><category term="marearts anpr"/><category term="mask"/><category term="masking"/><category term="matcher"/><category term="matrix"/><category term="mcafee"/><category term="mean"/><category term="meanshiftfiltering"/><category term="measuring processing time"/><category term="mel"/><category term="mel spectrogram"/><category term="memcpy double to byte"/><category term="memory"/><category term="memory share"/><category term="merge two csr matrix"/><category term="mesh"/><category term="mfcc"/><category term="microsoft"/><category term="minMaxIdxthreshold"/><category term="mini market"/><category term="miopen"/><category term="mkvirtualenv"/><category term="ml"/><category term="mlflow"/><category term="mlops"/><category term="mobile app"/><category term="model cfg"/><category term="module"/><category term="module list"/><category term="mog"/><category term="more read 1000"/><category term="morphologyEx"/><category term="mount"/><category term="mount remote data"/><category term="mouse tracking"/><category term="multi gpu training"/><category term="multipart/form-data"/><category term="multithread"/><category term="mutable defaults"/><category term="mypy"/><category term="namedWindow"/><category term="nan"/><category term="ndarray"/><category term="ner"/><category term="nerfstudio"/><category term="nerfstudio installation error"/><category term="networkX"/><category term="neural network"/><category term="nfc"/><category term="nginx"/><category term="nginx.conf"/><category term="nn.ModuleList"/><category term="no module named &#39;PIL&#39;"/><category term="node"/><category term="node js"/><category term="normalisation"/><category term="not in list"/><category term="notion"/><category term="notion embedding"/><category term="np.unique"/><category term="npm"/><category term="num_sanity_val_steps"/><category term="number list"/><category term="number text image"/><category term="numpy to pandas"/><category term="numpy.unique"/><category term="nvcuda"/><category term="nvidia docker"/><category term="nvidia-smi"/><category term="objdump"/><category term="object copy"/><category term="object detect"/><category term="object detection coordinate"/><category term="object dtype"/><category term="omp_get_max_threads"/><category term="omp_get_thread_num"/><category term="one color"/><category term="onecicle"/><category term="onecicle lr"/><category term="online annotation"/><category term="online labelme"/><category term="onnxruntime for rocm"/><category term="open"/><category term="open file list"/><category term="open3d"/><category term="openSFM"/><category term="opencv 249 install"/><category term="opencv 300"/><category term="opencv c++"/><category term="opencv install on ubuntu"/><category term="opencv version check"/><category term="opencv-python-hheadless"/><category term="opendir"/><category term="opsworkscm"/><category term="optimisers.Adam"/><category term="optimum-cli"/><category term="optimum.onnxruntime.configuration"/><category term="optional type"/><category term="orientation correction"/><category term="os functions"/><category term="os package"/><category term="os.getcwd()"/><category term="os.mkdir"/><category term="os.path.exists"/><category term="os.path.split"/><category term="os.walk"/><category term="osx"/><category term="otsu"/><category term="output exceed"/><category term="output_hidden_states"/><category term="overlap"/><category term="oversampling"/><category term="padding"/><category term="pafy"/><category term="page_iterator"/><category term="pagination"/><category term="palette"/><category term="panda"/><category term="pandas serarch"/><category term="pandas shuffle"/><category term="parallel_for"/><category term="parameter packs"/><category term="parameter store"/><category term="parametrize"/><category term="params"/><category term="parse_args"/><category term="parser"/><category term="parser.parse_args"/><category term="pathlib.PosixPath"/><category term="pbtxt"/><category term="pct_change"/><category term="pdf 2 images"/><category term="pdf to image"/><category term="pdf2image"/><category term="pedestrian data"/><category term="permanent mount"/><category term="person dataset"/><category term="person detection"/><category term="piezo speaker"/><category term="pil to string"/><category term="pil to tensor"/><category term="pip"/><category term="pip dependencies"/><category term="pip install"/><category term="pip-tools"/><category term="pipenv"/><category term="pixelate"/><category term="pkill"/><category term="pl_loggers"/><category term="ployline"/><category term="plt"/><category term="plt2cv2"/><category term="poetry"/><category term="point"/><category term="point in rect"/><category term="point processing"/><category term="polygon2rect"/><category term="pop front"/><category term="pop_back"/><category term="pop_back_n"/><category term="poppler"/><category term="port 80"/><category term="precision"/><category term="preprocessor"/><category term="print model structure"/><category term="print pdf"/><category term="printing"/><category term="process_time"/><category term="proxy"/><category term="pth"/><category term="put text"/><category term="put_object"/><category term="pyheif"/><category term="pyinstaller"/><category term="pymongo"/><category term="pynvml"/><category term="pytest"/><category term="python arguments"/><category term="python array"/><category term="python create mat"/><category term="python decimal"/><category term="python float variable Decimals format"/><category term="python ignore warning"/><category term="python list sort"/><category term="python mat create"/><category term="python number list duplication remove"/><category term="python opencv mat creation"/><category term="python opencv webcam"/><category term="python param"/><category term="python sdk"/><category term="python str"/><category term="python string"/><category term="python3.7"/><category term="python3.8"/><category term="pytorch3d"/><category term="pyzbar"/><category term="qr code"/><category term="qr code detector"/><category term="qrcode"/><category term="quantize"/><category term="queryset"/><category term="rag"/><category term="rand dict"/><category term="randu"/><category term="ratio"/><category term="re"/><category term="re split"/><category term="re.split"/><category term="read line by line"/><category term="read mail"/><category term="read text"/><category term="readOpticalFlow"/><category term="recall"/><category term="reduce node"/><category term="regression"/><category term="regular expression split string"/><category term="reivew"/><category term="remote"/><category term="remove"/><category term="remove duplicate tuple item"/><category term="remove duplicated dict item in list"/><category term="remove duplication"/><category term="remove empty string in list"/><category term="remove folder"/><category term="remove image from pdf"/><category term="remove mcafee"/><category term="remove node"/><category term="remove_cvref"/><category term="repeat"/><category term="replace zero"/><category term="requests"/><category term="resampling"/><category term="resizeWindow"/><category term="restapi"/><category term="return_tensors"/><category term="rgb to yuv"/><category term="rglob"/><category term="rm"/><category term="rmtree"/><category term="roboflow"/><category term="rolling"/><category term="rolling mean"/><category term="rotation"/><category term="round"/><category term="round_to_first_nonzero_decimal"/><category term="round_to_first_significant_decimal"/><category term="rpc failed"/><category term="rsync"/><category term="run script on startup"/><category term="s3 bucket folder check"/><category term="s3 copy"/><category term="s3. aws"/><category term="s3.put_object"/><category term="s3_client"/><category term="safe_load"/><category term="sam"/><category term="sam boroken"/><category term="sanity val check"/><category term="save"/><category term="save csv"/><category term="save image"/><category term="save json to s3 object"/><category term="save pth file"/><category term="save_pretrained"/><category term="scan"/><category term="scanned image"/><category term="scimitar-learn"/><category term="scipy"/><category term="scipy sparse csr matrix"/><category term="scipy.interpolate"/><category term="scoping"/><category term="script"/><category term="sd-scripts"/><category term="seed"/><category term="segmentation"/><category term="select best kernel"/><category term="semantic segmentation"/><category term="send mail"/><category term="sentence embedding"/><category term="sentence piece token"/><category term="sentence to vector"/><category term="separate"/><category term="separate dict"/><category term="separate train test"/><category term="sequence_loss"/><category term="serverless"/><category term="service stop"/><category term="service update move"/><category term="set -e"/><category term="set gpu"/><category term="setTo"/><category term="sftp"/><category term="shared memory"/><category term="shark"/><category term="shee"/><category term="shell in parallel"/><category term="shell run parallel"/><category term="side by side"/><category term="signal"/><category term="silhouette"/><category term="simple transformer ner"/><category term="simple transformer onnx"/><category term="simpletransformers"/><category term="single color"/><category term="site"/><category term="site.getsitepackages"/><category term="sklearn.model_selection"/><category term="slicing"/><category term="slidebar"/><category term="snap"/><category term="so"/><category term="solve"/><category term="sparse to tuple list to sparse"/><category term="spectrogram"/><category term="split dataset"/><category term="split dict"/><category term="split file name"/><category term="split string"/><category term="split test train dataset"/><category term="ssd is not defined"/><category term="ssh error"/><category term="ssh-keygen"/><category term="ssl cert verification error"/><category term="ssl error"/><category term="ssm"/><category term="stack"/><category term="start exe"/><category term="startup"/><category term="state_dict"/><category term="static typing"/><category term="std"/><category term="stippling"/><category term="stop docker"/><category term="stop sh error"/><category term="stream"/><category term="strides"/><category term="string to list"/><category term="string to token"/><category term="stringstream"/><category term="subfolder"/><category term="sublime"/><category term="subprocess"/><category term="subtract"/><category term="summarise"/><category term="superpixel"/><category term="suppress_errors"/><category term="surf gpu"/><category term="swap"/><category term="swapfile2"/><category term="swapon"/><category term="swarm move"/><category term="swift dictionary"/><category term="swin"/><category term="swin transformer v2"/><category term="sync"/><category term="sync local with s3"/><category term="sys"/><category term="sys.argv"/><category term="systemctl"/><category term="systemctl stop docker"/><category term="t-sne"/><category term="t2 instance"/><category term="t2.large"/><category term="t2.xlarge"/><category term="t3"/><category term="t3a.medium"/><category term="t4g.medium"/><category term="table detector"/><category term="tchar* to char*"/><category term="team"/><category term="teamviewer"/><category term="template&#xa;  specialization"/><category term="template metaprogramming"/><category term="tensor batch"/><category term="tensor.detach().numpy()"/><category term="tensorflow install"/><category term="tensorflow-gpu"/><category term="tensorflow_data_validation"/><category term="tesseract"/><category term="test split"/><category term="text"/><category term="text detection"/><category term="text image"/><category term="text summarise"/><category term="textsize"/><category term="tf.variable"/><category term="thread block configuration"/><category term="time add"/><category term="time distributed dense"/><category term="time subtract"/><category term="time-distributed dense"/><category term="time_t"/><category term="timm"/><category term="tm"/><category term="to_categorical"/><category term="to_list"/><category term="token grouping"/><category term="token to string"/><category term="tokeniser"/><category term="tokenizer.encode"/><category term="tokenizers"/><category term="tokens"/><category term="tokens to word"/><category term="torch cuda check"/><category term="torch load"/><category term="torch repeat"/><category term="torch save"/><category term="torch vision model"/><category term="torch-mlir"/><category term="torch.isnan"/><category term="torch.load"/><category term="torch.nan_to_num"/><category term="torch.save"/><category term="torchvision"/><category term="torchvision model download error"/><category term="torchvision.transforms"/><category term="total. marearts"/><category term="totla"/><category term="tp32"/><category term="tqdm"/><category term="train"/><category term="train_test_split"/><category term="transforms"/><category term="transforms.Compose"/><category term="transforms.PILToTensor"/><category term="trap"/><category term="truetype"/><category term="truncated"/><category term="tsne"/><category term="ttf"/><category term="tuple list"/><category term="tuple to list"/><category term="txt read"/><category term="type hints"/><category term="type-hints"/><category term="typing"/><category term="ubuntu 20.04"/><category term="ubuntu 22.04"/><category term="ubuntu version"/><category term="ubuntu wifi driver on mac"/><category term="undersampling"/><category term="unflatten"/><category term="unicode"/><category term="unique"/><category term="unix"/><category term="unreal engine"/><category term="unxz"/><category term="update"/><category term="update 1 line"/><category term="update-rc.d"/><category term="url check"/><category term="urllib"/><category term="usb edge tpu"/><category term="utf-8"/><category term="util"/><category term="val"/><category term="val_check_interval"/><category term="variadic"/><category term="variadic&#xa;  templates"/><category term="variadic template"/><category term="vconcat"/><category term="vcvars32.bat"/><category term="vector iterator"/><category term="vehicle identification"/><category term="verdana"/><category term="vertical stack"/><category term="video"/><category term="video concatenation"/><category term="video decoding"/><category term="video processing"/><category term="video rendering"/><category term="video subtraction"/><category term="video write"/><category term="virtualbox"/><category term="visualisation"/><category term="vit"/><category term="vit+transformer"/><category term="vote"/><category term="vpn"/><category term="vtkPolyDataMapper"/><category term="vtkStructuredGrid"/><category term="waitKey"/><category term="warning"/><category term="warpAffine"/><category term="warpPerspective"/><category term="warping"/><category term="water mark"/><category term="water mark embedding"/><category term="wauserv"/><category term="wchar_t"/><category term="weasyprint"/><category term="webcam"/><category term="webcam search"/><category term="website response"/><category term="wget"/><category term="widget"/><category term="widgetsnbextension"/><category term="window move"/><category term="window separate"/><category term="window split"/><category term="window update"/><category term="window update service stop"/><category term="wkhtmltopdf"/><category term="xcrun"/><category term="yaml.safe_load"/><category term="yolo v7 vs v8"/><category term="yolo2labelme"/><category term="yolov5"/><category term="yum install"/><category term="yuv to rgb"/><category term="zip test"/><category term="zipfile"/><title type='text'>MareArts Computer Vision Study.</title><subtitle type='html'>Computer Vision &amp;amp; Machine Learning Research Laboratory</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://study.marearts.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://study.marearts.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1017</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-8696619834403767024</id><published>2026-08-24T06:02:11.039-07:00</published><updated>2026-08-24T06:02:11.039-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PEP-604"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><category scheme="http://www.blogger.com/atom/ns#" term="tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="type-hints"/><title type='text'>A | B means either: reading union type hints in Python</title><content type='html'>&lt;style&gt;
/* ------------------------------------------------------------------
   study.marearts.com article body — PEP 604 union type hints.
   Every selector is scoped under #un-guide so nothing leaks onto the
   theme chrome (post title, date header, sidebar, comments).

   Palette is derived from the blog&#39;s own Awesome Inc. dark theme so
   the post reads as native rather than as an embedded card:
     page background #2d3037   body text #cccccc
     links #f1c232 (gold)      link hover / post titles #29aae1
     date headers #8ce1f5
   There is no light variant on purpose. Blogger has no theme-toggle
   attribute, so a light default would be the only thing that ever
   rendered — which is exactly how this post shipped white the first
   time. Panels are graded around #2d3037 instead of using an absolute
   background, so the article never fights the page it sits on.
   ------------------------------------------------------------------ */
#un-guide{
  --bg:transparent; --panel:#34383f; --panel2:#3b4048; --line:#454b54;
  --fg:#d4d7dc; --fg-strong:#eef0f3; --fg-dim:#a3a9b2; --fg-faint:#848b95;
  --accent:#f1c232; --accent-2:#29aae1; --warn:#ffb454; --danger:#ff7a84;
  --code-bg:#23262c; --code-fg:#d4d7dc;
  --kw:#c792ea; --str:#c3e88d; --com:#828a94; --num:#f78c6c;
  --dec:#ffcb6b; --fn:#82aaff; --inline-code:#e6d3ff;
  --pass:#4fd6b0; --fail:#ff7a84;
  --mono:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,&quot;JetBrains Mono&quot;,Menlo,Consolas,&quot;Liberation Mono&quot;,monospace;
  --sans:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif;
}
#un-guide, #un-guide *{box-sizing:border-box}
#un-guide{
  background:var(--bg); color:var(--fg);
  font-family:var(--sans); font-size:16px; line-height:1.7;
  -webkit-font-smoothing:antialiased;
  /* No frame: the theme already pads the post column, so a border plus
     its own background would read as a widget pasted onto the page. */
  padding:2px 0 44px; border:0; border-radius:0;
}
#un-guide .wrap{max-width:1000px;margin:0 auto;min-width:0}

/* headings */
#un-guide h1{font-size:38px;line-height:1.18;letter-spacing:-.8px;margin:0 0 12px;color:var(--fg)}
#un-guide .lede{font-size:18px;color:var(--fg-dim);max-width:70ch;margin:0 0 8px}
/* font-family is restated on h2/h4: the theme styles bare `h2` and `h4`
   with a `font:` shorthand, which sets Arial and beats plain inheritance
   from #un-guide. */
#un-guide h2{
  font-family:var(--sans);line-height:inherit;
  font-size:15px;text-transform:uppercase;letter-spacing:.1em;color:var(--accent-2);
  margin:64px 0 6px;padding-top:22px;border-top:1px solid var(--line);font-weight:700;
  scroll-margin-top:16px;
}
/* line-height is pinned to inherit rather than left undeclared: the
   site-wide tone CSS sets a heading line-height, and an undeclared
   property is the one thing an opt-out guard cannot protect if that
   guard ever fails to apply. `inherit` reproduces exactly what these
   headings render at today. */
#un-guide h3{font-size:25px;line-height:inherit;letter-spacing:-.4px;margin:38px 0 10px;color:var(--fg-strong);scroll-margin-top:20px}
#un-guide h4{font-family:var(--sans);font-size:16.5px;line-height:inherit;font-weight:600;margin:26px 0 8px;color:var(--fg-strong)}
#un-guide p{max-width:74ch;margin:12px 0}
#un-guide ul, #un-guide ol{max-width:74ch;padding-left:22px;margin:10px 0}
/* The theme&#39;s `.main-inner .widget ul{list-style:none}` strips markers from
   every list in the post body, so the markers are put back explicitly. */
#un-guide ul{list-style:disc}
#un-guide ol{list-style:decimal}
#un-guide li{margin:6px 0}
#un-guide a{color:var(--accent)}
#un-guide code{
  font-family:var(--mono);font-size:.875em;background:var(--panel2);
  padding:2px 6px;border-radius:4px;border:1px solid var(--line);color:var(--inline-code);
}
#un-guide strong{color:var(--fg-strong);font-weight:650}
#un-guide em{font-style:italic}

/* code blocks */
#un-guide .snippet{margin:18px 0;border:1px solid var(--line);border-radius:10px;overflow:hidden;background:var(--code-bg)}
#un-guide .snippet-head{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:7px 12px;background:var(--panel);border-bottom:1px solid var(--line);
}
#un-guide .snippet-name{font-family:var(--mono);font-size:12px;color:var(--fg-faint)}
#un-guide .snippet-name b{color:var(--fg-dim);font-weight:600}
#un-guide .copy{
  background:transparent;border:1px solid var(--line);color:var(--fg-faint);
  font-size:11px;padding:3px 9px;border-radius:5px;cursor:pointer;font-family:var(--sans);line-height:1.4;
}
#un-guide .copy:hover{color:var(--fg);border-color:var(--fg-faint)}
#un-guide .copy.ok{color:var(--accent-2);border-color:var(--accent-2)}
#un-guide pre{
  margin:0;padding:14px 16px;overflow-x:auto;background:var(--code-bg);
  font-family:var(--mono);font-size:13.5px;line-height:1.62;color:var(--code-fg);
  border:0;border-radius:0;
}
#un-guide pre code{background:none;border:0;padding:0;font-size:inherit;color:inherit}
#un-guide pre::-webkit-scrollbar{height:9px}
#un-guide pre::-webkit-scrollbar-thumb{background:var(--line);border-radius:5px}
#un-guide .out pre{color:var(--fg-dim)}
#un-guide .out .snippet-name b{color:var(--warn)}

/* syntax colors */
#un-guide .t-kw{color:var(--kw)}
#un-guide .t-str{color:var(--str)}
#un-guide .t-com{color:var(--com);font-style:italic}
#un-guide .t-num{color:var(--num)}
#un-guide .t-dec{color:var(--dec)}
#un-guide .t-fn{color:var(--fn)}
#un-guide .t-pass{color:var(--pass)}
#un-guide .t-fail{color:var(--fail)}

/* callouts */
/* Info reads cyan, not gold: gold is the theme&#39;s link colour and would
   collide with .warn&#39;s amber at these low alphas. */
#un-guide .note{
  border-left:3px solid var(--accent-2);background:rgba(41,170,225,.09);
  padding:12px 16px;margin:18px 0;border-radius:0 8px 8px 0;max-width:74ch;
}
#un-guide .note.warn{border-color:var(--warn);background:rgba(255,180,84,.08)}
#un-guide .note.trap{border-color:var(--danger);background:rgba(255,122,132,.08)}
#un-guide .note .tag{
  display:block;font-size:10.5px;text-transform:uppercase;letter-spacing:.1em;
  font-weight:700;color:var(--accent-2);margin-bottom:3px;
}
#un-guide .note.warn .tag{color:var(--warn)}
#un-guide .note.trap .tag{color:var(--danger)}
#un-guide .note p{margin:5px 0}
#un-guide .note .tag code{
  background:none !important;border:0 !important;padding:0 !important;
  color:inherit !important;font-size:1em !important;
}

/* tables */
#un-guide .table-wrap{overflow-x:auto;margin:18px 0}
#un-guide table{border-collapse:collapse;width:100%;margin:0;font-size:14.5px;background:none}
#un-guide th, #un-guide td{text-align:left;padding:9px 13px;border:0;border-bottom:1px solid var(--line);vertical-align:top}
#un-guide th{color:var(--fg-faint);font-size:11.5px;text-transform:uppercase;letter-spacing:.07em;font-weight:700}
#un-guide td code{font-size:.9em}
#un-guide tbody tr:hover{background:var(--panel)}

/* furniture */
#un-guide .kicker{
  font-size:12px;font-weight:700;letter-spacing:.13em;text-transform:uppercase;
  color:var(--accent-2);margin-bottom:14px;
}
#un-guide .rule{height:1px;background:var(--line);margin:30px 0 4px;max-width:74ch}

#un-guide .toc{
  border:1px solid var(--line);border-radius:12px;background:var(--panel);
  padding:20px 24px;margin:34px 0 10px;max-width:74ch;
}
#un-guide .toc h4{margin:0 0 14px;font-size:13px;text-transform:uppercase;letter-spacing:.1em;color:var(--fg-faint)}
#un-guide .toc ol{margin:0;padding-left:20px;max-width:none}
#un-guide .toc &gt; ol &gt; li{margin:14px 0}
#un-guide .toc &gt; ol &gt; li &gt; a{text-decoration:none;font-weight:650;font-size:16.5px}
#un-guide .toc a{text-decoration:none;color:var(--accent)}
#un-guide .toc a:hover{text-decoration:underline}
#un-guide .toc span{color:var(--fg-faint);font-weight:400;font-size:14px}
#un-guide .toc ul{
  list-style:none;margin:7px 0 0;padding-left:0;max-width:none;
  display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:1px 18px;
}
#un-guide .toc ul li{margin:0}
#un-guide .toc ul a{font-size:14px;color:var(--fg-dim)}
#un-guide .toc ul a:hover{color:var(--accent)}

#un-guide .takeaway{
  border:1px solid var(--line);border-left:3px solid var(--accent-2);
  border-radius:0 12px 12px 0;background:var(--panel);
  padding:18px 22px;margin:26px 0;max-width:74ch;
}
#un-guide .takeaway h4{margin:0 0 10px;font-size:14px;text-transform:uppercase;letter-spacing:.08em;color:var(--accent-2)}
#un-guide .takeaway ul{margin:0;padding-left:20px}

/* Always stacked, never side by side: the theme&#39;s centre column is ~545px
   of content, so two code panes would each get ~265px and clip mid-token
   regardless of viewport width (the 900px media query never fires). */
#un-guide .grid2{display:grid;grid-template-columns:1fr;gap:16px}
#un-guide .grid2 .snippet{margin:0;min-width:0}

#un-guide .diagram{
  margin:22px 0;padding:20px 22px;border:1px dashed var(--line);border-radius:10px;
  background:var(--code-bg);overflow-x:auto;
}
#un-guide .diagram pre{
  padding:0;background:none;font-size:13.5px;line-height:1.75;color:var(--fg-dim);
}
#un-guide .diagram .hl-a{color:var(--accent)}
#un-guide .diagram .hl-b{color:var(--dec)}
#un-guide .diagram .hl-c{color:var(--accent-2)}
#un-guide .diagram .hl-d{color:var(--danger)}

#un-guide .badge{
  display:inline-block;font-size:11px;padding:2px 8px;border-radius:20px;
  border:1px solid var(--line);color:var(--fg-faint);margin-left:8px;vertical-align:middle;
  letter-spacing:normal;line-height:1.4;text-align:left;background:none;
}
#un-guide .kbd{
  font-family:var(--mono);font-size:12px;background:var(--panel2);border:1px solid var(--line);
  border-bottom-width:2px;border-radius:4px;padding:1px 6px;
}
#un-guide .foot{
  margin-top:70px;padding-top:20px;border-top:1px solid var(--line);
  color:var(--fg-faint);font-size:13px;
}
/* ------------------------------------------------------------------
   The Blogger theme re-colours bare descendants of the post container:
   body{color:#cccccc}, .post-body ul li{color:#cccccc},
   .main-inner .widget ul li{color:#ffffff}, a:link{color:#f1c232},
   h2{color:#8ce1f5}, h4{color:#29aae1}. Re-assert the article palette
   here — #un-guide carries an id, so it wins on specificity, and the
   !important guards cover the handful of host rules that use it too.
   Kept deliberately narrow: anything with a per-component colour of its
   own (.toc h4, .takeaway h4, .note .tag) must not be caught by these.
   ------------------------------------------------------------------ */
#un-guide h1, #un-guide h3{color:var(--fg-strong) !important}
#un-guide h2{color:var(--accent-2) !important}
#un-guide p{color:var(--fg) !important}
#un-guide li{color:var(--fg) !important;padding:0;border:0}
#un-guide .lede{color:var(--fg-dim) !important}
#un-guide strong{color:var(--fg-strong) !important}
#un-guide a, #un-guide .toc a{color:var(--accent) !important}
#un-guide .toc ul a{color:var(--fg-dim) !important}
#un-guide a:hover, #un-guide .toc ul a:hover{color:var(--accent) !important}
#un-guide code{background:var(--panel2) !important;color:var(--inline-code) !important}
#un-guide pre code{background:none !important;color:var(--code-fg) !important}
#un-guide table{background:none !important;table-layout:auto !important}
#un-guide th{background:var(--panel2) !important;color:var(--fg-faint) !important}
#un-guide td{color:var(--fg) !important}
#un-guide th, #un-guide td{border-color:var(--line) !important}
#un-guide tbody tr:hover{background:var(--panel) !important}

@media screen and (max-width:900px){
  #un-guide{padding:2px 0 36px}
  #un-guide table{font-size:13.5px}
}
@media screen and (max-width:640px){
  #un-guide .toc ul{grid-template-columns:1fr}
}

#un-guide .yes{color:var(--accent-2);font-weight:650}
#un-guide .no{color:var(--danger);font-weight:650}
#un-guide .fg-faint{color:var(--fg-faint)}
&lt;/style&gt;

&lt;div id=&quot;un-guide&quot; data-tone=&quot;self&quot;&gt;
&lt;div class=&quot;wrap&quot;&gt;

&lt;div class=&quot;kicker&quot;&gt;Python · Type hints&lt;/div&gt;
&lt;p class=&quot;lede&quot;&gt;
  &lt;code&gt;def sensor_id(sensor: Sensor | int | None) -&amp;gt; int&lt;/code&gt; has three bars in one signature and
  looks like bit arithmetic. It is not arithmetic and it is not new syntax to memorise: each bar is the
  word &lt;em&gt;or&lt;/em&gt;, and the whole annotation is one sentence — &quot;a &lt;code&gt;Sensor&lt;/code&gt;, or an
  &lt;code&gt;int&lt;/code&gt;, or nothing&quot;.
&lt;/p&gt;

&lt;div class=&quot;rule&quot;&gt;&lt;/div&gt;

&lt;p&gt;
  Unions pile up in exactly one situation: a function that is polite about what callers hand it. A
  station can be identified by name or by number, a reading may be missing, an option may be left
  unset. Each politeness adds a member to the union, and the annotation grows to match. Reading one is
  a two-minute skill; the interesting part is what the notation does &lt;em&gt;not&lt;/em&gt; promise, and that is
  where most of this post goes.
&lt;/p&gt;
&lt;p&gt;
  Everything below runs on CPython 3.10, and every output block is copied from a real run.
&lt;/p&gt;

&lt;div class=&quot;toc&quot;&gt;
  &lt;h4&gt;Contents&lt;/h4&gt;
  &lt;ol&gt;
    &lt;li&gt;&lt;a href=&quot;#un-bar&quot;&gt;One bar, two types&lt;/a&gt; &lt;span&gt;— the whole of the notation&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#un-none&quot;&gt;The &lt;code&gt;| None&lt;/code&gt; case&lt;/a&gt; &lt;span&gt;— what used to be &lt;code&gt;Optional&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#un-runtime&quot;&gt;Nobody checks it at runtime&lt;/a&gt; &lt;span&gt;— annotations are documentation&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#un-narrow&quot;&gt;Narrowing a three-way union&lt;/a&gt; &lt;span&gt;— the funnel pattern&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#un-object&quot;&gt;The bar builds a real object&lt;/a&gt; &lt;span&gt;— &lt;code&gt;types.UnionType&lt;/code&gt;, and &lt;code&gt;isinstance&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#un-nesting&quot;&gt;Where you put the bar changes the meaning&lt;/a&gt; &lt;span&gt;— &lt;code&gt;list[int] | None&lt;/code&gt; vs &lt;code&gt;list[int | None]&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#un-old&quot;&gt;Older Python&lt;/a&gt; &lt;span&gt;— &lt;code&gt;from __future__ import annotations&lt;/code&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#un-traps&quot;&gt;Traps&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#un-cheatsheet&quot;&gt;Cheat sheet&lt;/a&gt;&lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;


&lt;!-- ==================== 1 ==================== --&gt;
&lt;h2&gt;1 · One bar, two types&lt;/h2&gt;

&lt;h3 id=&quot;un-bar&quot;&gt;The whole of the notation&lt;/h3&gt;
&lt;p&gt;
  &lt;code&gt;A | B&lt;/code&gt; in an annotation means &lt;strong&gt;a value of type &lt;code&gt;A&lt;/code&gt;, or a value of type
  &lt;code&gt;B&lt;/code&gt;&lt;/strong&gt;. That is the entire feature. It reads left to right, the order carries no
  meaning, and it chains: &lt;code&gt;A | B | C&lt;/code&gt; is &quot;any one of the three&quot;.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;brightness.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def brightness(level: int | float) -&amp;gt; str:
    return f&quot;{level:.1f} lux&quot;

print(brightness(3))
print(brightness(3.5))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python brightness.py&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;3.0 lux
3.5 lux&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  This spelling arrived in Python 3.10 (PEP 604). Before it, the same thing was written with a helper
  imported from &lt;code&gt;typing&lt;/code&gt;, and you will still meet that spelling in any code that supports
  older interpreters:
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Modern&lt;/th&gt;&lt;th&gt;Pre-3.10 equivalent&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;int | float&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;Union[int, float]&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;int | None&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;Optional[int]&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;str | int | None&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;Optional[Union[str, int]]&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;dict[str, float] | None&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;Optional[Dict[str, float]]&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;
  They are not merely similar, they compare equal — the bar is a different way to spell the same
  object:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;equivalence.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;from typing import Optional, Union

print(int | None == Optional[int])
print(int | str == Union[int, str])
print(str | None == None | str)      # order is not part of the meaning&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python equivalence.py&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;True
True
True&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Which explains why nobody writes the old form in new code, and why a linter will rewrite it for you.
  Ruff&#39;s &lt;code&gt;UP&lt;/code&gt; rules do it as a fix:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;old_style.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;from typing import Optional, Union


def humidity(sensor: Optional[int]) -&amp;gt; Union[float, str]:
    if sensor is None:
        return &quot;no sensor&quot;
    return 41.5&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; ruff check --select UP --target-version py310 --diff old_style.py&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;--- old_style.py
+++ old_style.py
@@ -1,7 +1,7 @@
 from typing import Optional, Union


-def humidity(sensor: Optional[int]) -&amp;gt; Union[float, str]:
+def humidity(sensor: int | None) -&amp;gt; float | str:
     if sensor is None:
         return &quot;no sensor&quot;
     return 41.5

Would fix 2 errors.&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  &lt;code&gt;UP045&lt;/code&gt; is the &lt;code&gt;Optional&lt;/code&gt; one, &lt;code&gt;UP007&lt;/code&gt; the &lt;code&gt;Union&lt;/code&gt; one.
  Both are auto-fixable, so a whole codebase converts in one command once every supported interpreter
  is 3.10 or newer.
&lt;/p&gt;


&lt;!-- ==================== 2 ==================== --&gt;
&lt;h2&gt;2 · The &lt;code&gt;| None&lt;/code&gt; case&lt;/h2&gt;

&lt;h3 id=&quot;un-none&quot;&gt;&quot;or nothing&quot; is the common member&lt;/h3&gt;
&lt;p&gt;
  By far the most frequent union is &lt;code&gt;X | None&lt;/code&gt;, because &quot;this may be absent&quot; is the most
  frequent extra case in any real signature. &lt;code&gt;None&lt;/code&gt; here is standing in for its type,
  &lt;code&gt;NoneType&lt;/code&gt;, which is why it can appear in a union at all:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;nonetype.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;print(type(None))
print(int | None == int | type(None))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python nonetype.py&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;&amp;lt;class &#39;NoneType&#39;&amp;gt;
True&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Convention&lt;/span&gt;
  &lt;p&gt;
    Put &lt;code&gt;None&lt;/code&gt; last. &lt;code&gt;int | None&lt;/code&gt; and &lt;code&gt;None | int&lt;/code&gt; are the same type,
    but the reader parses &quot;an int, possibly absent&quot; faster than &quot;absent, or an int&quot;, and every style
    guide and auto-fixer produces the former.
  &lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;
  A parameter with a &lt;code&gt;None&lt;/code&gt; default should say so in the annotation. The default does not
  add the member for you:
&lt;/p&gt;

&lt;div class=&quot;grid2&quot;&gt;
  &lt;div class=&quot;snippet&quot;&gt;
    &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;wrong&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def scale(factor: float = None):
    # claims float, accepts None
    ...&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
  &lt;div class=&quot;snippet&quot;&gt;
    &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;right&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def scale(factor: float | None = None):
    # the annotation matches the default
    ...&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;
  The wrong version runs perfectly. It is a documentation bug: the annotation says the argument is
  always a float while the default proves otherwise, so a reader who trusts it will skip the
  &lt;code&gt;None&lt;/code&gt; branch they needed to write. A type checker flags it; the interpreter never will.
&lt;/p&gt;


&lt;!-- ==================== 3 ==================== --&gt;
&lt;h2&gt;3 · Nobody checks it at runtime&lt;/h2&gt;

&lt;h3 id=&quot;un-runtime&quot;&gt;Annotations are documentation with syntax&lt;/h3&gt;
&lt;p&gt;
  This is the single most important fact about the notation, and the one that surprises people coming
  from a compiled language. Writing &lt;code&gt;int | str&lt;/code&gt; does not make the interpreter reject a
  list. Nothing is validated on the way in, and nothing is validated on the way out.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;unchecked.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def label(value: int | str) -&amp;gt; str:
    return value.upper()

print(label(&quot;dry&quot;))
print(label(7))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python unchecked.py&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;DRY
AttributeError: &#39;int&#39; object has no attribute &#39;upper&#39;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The annotation was honest — &lt;code&gt;7&lt;/code&gt; really is an allowed argument — and the body was not. It
  called a string method on a value the signature promised might be an integer. The union is a claim
  about the &lt;em&gt;caller&lt;/em&gt;; honouring it inside the body is the author&#39;s job, and that job is called
  narrowing.
&lt;/p&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Consequence&lt;/span&gt;
  &lt;p&gt;
    Every union member you add is a branch you owe the body. A three-member union with one code path
    through it is a bug waiting for the second-most-common input.
  &lt;/p&gt;
&lt;/div&gt;


&lt;!-- ==================== 4 ==================== --&gt;
&lt;h2&gt;4 · Narrowing a three-way union&lt;/h2&gt;

&lt;h3 id=&quot;un-narrow&quot;&gt;The funnel pattern&lt;/h3&gt;
&lt;p&gt;
  When a signature accepts several shapes, the usual body converts them to one shape as early as
  possible and then gets on with the actual work. The union is wide at the top of the function and
  narrow everywhere after.
&lt;/p&gt;

&lt;div class=&quot;diagram&quot;&gt;
&lt;pre&gt;  sensor: &lt;span class=&quot;hl-a&quot;&gt;Sensor&lt;/span&gt;  |  &lt;span class=&quot;hl-b&quot;&gt;int&lt;/span&gt;  |  &lt;span class=&quot;hl-d&quot;&gt;None&lt;/span&gt;     three shapes in, one int out
            │         │       │
            │         │       │       &lt;span class=&quot;hl-a&quot;&gt;isinstance(sensor, Sensor)&lt;/span&gt;
            ▼         │       │
       &lt;span class=&quot;hl-a&quot;&gt;sensor.index&lt;/span&gt;   │       │
       (&lt;span class=&quot;hl-b&quot;&gt;int&lt;/span&gt; | &lt;span class=&quot;hl-d&quot;&gt;None&lt;/span&gt;)   │       │
            │         │       │
            └────┬────┘       │
                 │            │
                 ▼            ▼
                &lt;span class=&quot;hl-b&quot;&gt;int&lt;/span&gt;          &lt;span class=&quot;hl-d&quot;&gt;None&lt;/span&gt;     &lt;span class=&quot;hl-d&quot;&gt;Sensor(None) lands here too&lt;/span&gt;
                 │            │
                 ▼            ▼
           &lt;span class=&quot;hl-c&quot;&gt;return sensor&lt;/span&gt;   &lt;span class=&quot;hl-c&quot;&gt;return 0&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;narrow.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;class Sensor:
    def __init__(self, index: int | None) -&amp;gt; None:
        self.index = index


def sensor_id(sensor: Sensor | int | None) -&amp;gt; int:
    if isinstance(sensor, Sensor):
        sensor = sensor.index      # Sensor | int | None  -&amp;gt;  int | None
    if sensor is None:
        return 0                   # int | None  -&amp;gt;  int
    return sensor


print(sensor_id(Sensor(4)))
print(sensor_id(9))
print(sensor_id(None))
print(sensor_id(Sensor(None)))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python narrow.py&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;4
9
0
0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Two lines removed two members. The first &lt;code&gt;if&lt;/code&gt; replaces a &lt;code&gt;Sensor&lt;/code&gt; with the
  integer inside it, so after that line the variable is &lt;code&gt;int | None&lt;/code&gt; even though the
  parameter was declared wider. The second turns the remaining &lt;code&gt;None&lt;/code&gt; into a value, so the
  &lt;code&gt;return sensor&lt;/code&gt; at the bottom is an &lt;code&gt;int&lt;/code&gt; and matches the return annotation. A
  type checker follows this reasoning statically and will complain if a branch is missing.
&lt;/p&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Read the fourth line of output&lt;/span&gt;
  &lt;p&gt;
    &lt;code&gt;sensor_id(Sensor(None))&lt;/code&gt; returns &lt;code&gt;0&lt;/code&gt;, the same as passing nothing at all.
    That is not a bug here, but it is a decision, and it is the kind of decision a wide union hides: an
    object whose interior field is empty collapses onto the same branch as a missing object. If those
    two cases should behave differently, the union has to be narrowed in a different order.
  &lt;/p&gt;
&lt;/div&gt;

&lt;h4&gt;Ordering the checks is not narrowing by itself&lt;/h4&gt;
&lt;p&gt;
  &lt;code&gt;isinstance&lt;/code&gt; and &lt;code&gt;is None&lt;/code&gt; narrow. Falling off the end of a chain of
  &lt;code&gt;if&lt;/code&gt;s also narrows, by elimination, and is idiomatic — but only if the members really are
  exhausted:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;elimination.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def to_text(value: int | str) -&amp;gt; str:
    if isinstance(value, int):
        return f&quot;#{value}&quot;
    return value.strip()          # nothing left but str

print(to_text(7), to_text(&quot;  wet  &quot;) + &quot;|&quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python elimination.py&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;#7 wet|&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;!-- ==================== 5 ==================== --&gt;
&lt;h2&gt;5 · The bar builds a real object&lt;/h2&gt;

&lt;h3 id=&quot;un-object&quot;&gt;Not a special form the parser swallows&lt;/h3&gt;
&lt;p&gt;
  &lt;code&gt;int | None&lt;/code&gt; is an ordinary expression evaluated at runtime. It produces an instance of
  &lt;code&gt;types.UnionType&lt;/code&gt;, it has a readable &lt;code&gt;repr&lt;/code&gt;, and it can be stored in a
  variable like any other value:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;runtime_object.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;print(type(int | None))
print(int | None)

Celsius = float | int                    # a reusable alias
Reading = dict[str, float] | None
print(Celsius)
print(Reading)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python runtime_object.py&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;&amp;lt;class &#39;types.UnionType&#39;&amp;gt;
int | None
float | int
dict[str, float] | None&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Because it is a real object, duplicates collapse and nesting flattens, which is why you never see a
  union of unions:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;flatten.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;print(int | str | int)
print((int | str) | float)
print(int | None | None)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python flatten.py&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;int | str
int | str | float
int | None&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h4&gt;It works in &lt;code&gt;isinstance&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;
  A genuine convenience of the new spelling: the resulting object is accepted as the second argument to
  &lt;code&gt;isinstance&lt;/code&gt; and &lt;code&gt;issubclass&lt;/code&gt;, which &lt;code&gt;Union[...]&lt;/code&gt; never was. It
  behaves like the tuple form.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;isinstance_union.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;print(isinstance(3, int | float))
print(isinstance(&quot;x&quot;, int | float))
print(isinstance([1], list | None))
print(isinstance([1], list[int] | None))    # parameterized -&amp;gt; rejected&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python isinstance_union.py&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;True
False
True
TypeError: isinstance() argument 2 cannot contain a parameterized generic&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The last line is the general rule about runtime checks, not a union quirk: nothing can test
  &lt;code&gt;list[int]&lt;/code&gt; at runtime, because that would mean walking the list. Check
  &lt;code&gt;list&lt;/code&gt; and trust the annotation for the element type.
&lt;/p&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Types only&lt;/span&gt;
  &lt;p&gt;
    The bar between two &lt;em&gt;instances&lt;/em&gt; is still plain &lt;code&gt;__or__&lt;/code&gt;, and most objects do not
    implement it. &lt;code&gt;3 | None&lt;/code&gt; raises
    &lt;code&gt;TypeError: unsupported operand type(s) for |: &#39;int&#39; and &#39;NoneType&#39;&lt;/code&gt;. Unions are built
    from types, and a value that happens to be a type — a variable holding &lt;code&gt;int&lt;/code&gt; — works
    exactly as well as the literal.
  &lt;/p&gt;
&lt;/div&gt;


&lt;!-- ==================== 6 ==================== --&gt;
&lt;h2&gt;6 · Where you put the bar changes the meaning&lt;/h2&gt;

&lt;h3 id=&quot;un-nesting&quot;&gt;Outside or inside the brackets&lt;/h3&gt;
&lt;p&gt;
  Two annotations one character apart in appearance, and entirely different in what they permit:
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Annotation&lt;/th&gt;&lt;th&gt;Reads as&lt;/th&gt;&lt;th&gt;Accepts&lt;/th&gt;&lt;th&gt;Rejects&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code&gt;list[int] | None&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;a list of ints, &lt;em&gt;or&lt;/em&gt; no list at all&lt;/td&gt;
      &lt;td&gt;&lt;code&gt;[1, 2]&lt;/code&gt;, &lt;code&gt;[]&lt;/code&gt;, &lt;code&gt;None&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;&lt;code&gt;[1, None]&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code&gt;list[int | None]&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;always a list, whose &lt;em&gt;items&lt;/em&gt; may be missing&lt;/td&gt;
      &lt;td&gt;&lt;code&gt;[1, None]&lt;/code&gt;, &lt;code&gt;[]&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;&lt;code&gt;None&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;
  The structure is visible at runtime — the outer construct is different in each case:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;nesting.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;from typing import get_args, get_origin

print(get_origin(list[int] | None), get_args(list[int] | None))
print(get_origin(list[int | None]), get_args(list[int | None]))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python nesting.py&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;&amp;lt;class &#39;types.UnionType&#39;&amp;gt; (list[int], &amp;lt;class &#39;NoneType&#39;&amp;gt;)
&amp;lt;class &#39;list&#39;&amp;gt; (int | None,)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  For the first, the outermost thing is the union and the list is a member. For the second, the
  outermost thing is a list and the union is its element type. When a signature needs both — an
  optional list of optional readings — say so: &lt;code&gt;list[float | None] | None&lt;/code&gt;. It is a
  mouthful, and that is a fair warning about the interface.
&lt;/p&gt;


&lt;!-- ==================== 7 ==================== --&gt;
&lt;h2&gt;7 · Older Python&lt;/h2&gt;

&lt;h3 id=&quot;un-old&quot;&gt;The &lt;code&gt;from __future__&lt;/code&gt; escape&lt;/h3&gt;
&lt;p&gt;
  On 3.7 through 3.9 the bar between two types raises &lt;code&gt;TypeError&lt;/code&gt; when evaluated. Since
  annotations are evaluated at function-definition time by default, that makes
  &lt;code&gt;def f(x: int | None)&lt;/code&gt; a runtime error on those versions — not a warning, a crash on
  import.
&lt;/p&gt;
&lt;p&gt;
  &lt;code&gt;from __future__ import annotations&lt;/code&gt;, at the top of the module, stops annotations from
  being evaluated at all. They are stored as strings and only ever inspected by tools:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;future_import.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;from __future__ import annotations


def calibrate(offset: int | None) -&amp;gt; float | None:
    return None if offset is None else offset * 0.5


print(calibrate.__annotations__)
print(calibrate(4), calibrate(None))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python future_import.py&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;{&#39;offset&#39;: &#39;int | None&#39;, &#39;return&#39;: &#39;float | None&#39;}
2.0 None&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The values are strings, quotes included. Nothing ever evaluated &lt;code&gt;int | None&lt;/code&gt;, so the
  syntax is free on any version that has the future import.
&lt;/p&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Only annotations&lt;/span&gt;
  &lt;p&gt;
    The future import covers annotation positions and nothing else. An alias assignment
    (&lt;code&gt;Celsius = float | int&lt;/code&gt;), a call to &lt;code&gt;isinstance(x, int | None)&lt;/code&gt;, or anything
    that resolves annotations at runtime — &lt;code&gt;typing.get_type_hints&lt;/code&gt;, and the validation
    libraries built on it — still evaluates the expression and still fails below 3.10. Those places
    need &lt;code&gt;Union&lt;/code&gt; and &lt;code&gt;Optional&lt;/code&gt; until the floor moves.
  &lt;/p&gt;
&lt;/div&gt;


&lt;!-- ==================== 8 ==================== --&gt;
&lt;h2&gt;8 · Traps&lt;/h2&gt;

&lt;h3 id=&quot;un-traps&quot;&gt;Four that survive the nicer syntax&lt;/h3&gt;

&lt;h4&gt;A wide union is a cost, not a courtesy&lt;/h4&gt;
&lt;p&gt;
  &lt;code&gt;str | int | Path | None&lt;/code&gt; is four branches for every caller &lt;em&gt;and&lt;/em&gt; for the body. If
  one of the members is only there because a single caller was lazy, converting at that call site is
  usually cheaper than teaching every reader of the signature about a case that occurs once.
&lt;/p&gt;

&lt;h4&gt;&lt;code&gt;or&lt;/code&gt; is not the same as &lt;code&gt;is None&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;
  The narrowing shortcut &lt;code&gt;value or default&lt;/code&gt; collapses every falsy value, not just
  &lt;code&gt;None&lt;/code&gt;, and an empty string is a legitimate member of &lt;code&gt;str | None&lt;/code&gt;:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;falsy.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def site_name(name: str | None) -&amp;gt; str:
    return name or &quot;unnamed&quot;

def site_name_strict(name: str | None) -&amp;gt; str:
    return &quot;unnamed&quot; if name is None else name

print(repr(site_name(&quot;&quot;)), repr(site_name_strict(&quot;&quot;)))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python falsy.py&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;&#39;unnamed&#39; &#39;&#39;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The first discarded a caller&#39;s deliberate empty name. Same for &lt;code&gt;0&lt;/code&gt; in
  &lt;code&gt;int | None&lt;/code&gt; and &lt;code&gt;[]&lt;/code&gt; in &lt;code&gt;list[str] | None&lt;/code&gt; — the values most likely
  to matter are the falsy ones.
&lt;/p&gt;

&lt;h4&gt;The return type is a union too&lt;/h4&gt;
&lt;p&gt;
  &lt;code&gt;-&amp;gt; float | None&lt;/code&gt; is a promise that every caller must unwrap. It is the right
  annotation when absence is a real outcome, and the wrong one when the function could simply raise;
  returning &lt;code&gt;None&lt;/code&gt; for failure pushes a branch onto everybody downstream, and the ones who
  forget it get an &lt;code&gt;AttributeError&lt;/code&gt; far from the cause.
&lt;/p&gt;

&lt;h4&gt;Mixing the spellings in one file&lt;/h4&gt;
&lt;p&gt;
  &lt;code&gt;Optional[int]&lt;/code&gt; on one line and &lt;code&gt;str | None&lt;/code&gt; on the next both work, and both
  mean what they say, but the reader now has to hold two vocabularies. Pick the modern one and let the
  auto-fixer convert the rest.
&lt;/p&gt;


&lt;!-- ==================== close ==================== --&gt;
&lt;h2&gt;Wrapping up&lt;/h2&gt;

&lt;h3 id=&quot;un-cheatsheet&quot;&gt;Cheat sheet&lt;/h3&gt;

&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;You want&lt;/th&gt;&lt;th&gt;Write&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;Either of two types&lt;/td&gt;&lt;td&gt;&lt;code&gt;int | str&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;May be absent&lt;/td&gt;&lt;td&gt;&lt;code&gt;int | None&lt;/code&gt;, with &lt;code&gt;None&lt;/code&gt; last&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Absent by default&lt;/td&gt;&lt;td&gt;&lt;code&gt;def f(x: int | None = None)&lt;/code&gt; — annotation and default agree&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;A list, or nothing&lt;/td&gt;&lt;td&gt;&lt;code&gt;list[int] | None&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;A list with gaps in it&lt;/td&gt;&lt;td&gt;&lt;code&gt;list[int | None]&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;A name for a recurring union&lt;/td&gt;&lt;td&gt;&lt;code&gt;SensorRef = Sensor | int | None&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;A runtime check against a union&lt;/td&gt;&lt;td&gt;&lt;code&gt;isinstance(x, int | float)&lt;/code&gt; — unparameterized members only&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;The syntax on 3.7–3.9&lt;/td&gt;&lt;td&gt;&lt;code&gt;from __future__ import annotations&lt;/code&gt;, annotation positions only&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;To convert an old codebase&lt;/td&gt;&lt;td&gt;&lt;code&gt;ruff check --select UP007,UP045 --fix&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;div class=&quot;takeaway&quot;&gt;
  &lt;h4&gt;The short list&lt;/h4&gt;
  &lt;ul&gt;
    &lt;li&gt;
      &lt;strong&gt;&lt;code&gt;A | B&lt;/code&gt; is the word &quot;or&quot;.&lt;/strong&gt; Order carries no meaning, chaining is just
      more members, and &lt;code&gt;X | None&lt;/code&gt; is what &lt;code&gt;Optional[X]&lt;/code&gt; used to spell.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Nothing is enforced at runtime.&lt;/strong&gt; The union constrains callers; the body still has
      to handle every member, and forgetting one fails later with an ordinary attribute error.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Narrow early.&lt;/strong&gt; One &lt;code&gt;isinstance&lt;/code&gt; and one &lt;code&gt;is None&lt;/code&gt; at the
      top turn a three-member parameter into a single concrete type for the rest of the function.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;It is a real object.&lt;/strong&gt; &lt;code&gt;types.UnionType&lt;/code&gt;, printable, assignable to an
      alias, and usable in &lt;code&gt;isinstance&lt;/code&gt; — unlike the &lt;code&gt;typing&lt;/code&gt; spelling.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Bracket placement is semantic.&lt;/strong&gt; &lt;code&gt;list[int] | None&lt;/code&gt; and
      &lt;code&gt;list[int | None]&lt;/code&gt; accept disjoint sets of values.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Every member is a branch someone maintains.&lt;/strong&gt; Three is usually a helpful
      interface; six is usually a missing conversion at one call site.
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;

&lt;h3 id=&quot;un-further&quot;&gt;Further reading&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0604/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;PEP 604&lt;/a&gt; — the proposal that introduced &lt;code&gt;X | Y&lt;/code&gt;, including why the bar was chosen&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#types-union-type&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Standard types — union type&lt;/a&gt;: &lt;code&gt;types.UnionType&lt;/code&gt;, flattening, and the &lt;code&gt;isinstance&lt;/code&gt; support&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0563/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;PEP 563&lt;/a&gt; — &lt;code&gt;from __future__ import annotations&lt;/code&gt; and what &quot;postponed evaluation&quot; does and does not cover&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://typing.python.org/en/latest/spec/narrowing.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Typing spec — narrowing&lt;/a&gt;: the checks a type checker recognises as narrowing a union&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.astral.sh/ruff/rules/non-pep604-annotation-union/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Ruff — UP007&lt;/a&gt; and &lt;a href=&quot;https://docs.astral.sh/ruff/rules/non-pep604-annotation-optional/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;UP045&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;/div&gt;

&lt;script&gt;
(function () {
  var root = document.getElementById(&#39;un-guide&#39;);
  if (!root || root.dataset.unInit) return;
  root.dataset.unInit = &#39;1&#39;;

  var PY_KW = (&quot;False|None|True|and|as|assert|async|await|break|class|continue|def|del|elif|&quot;
             + &quot;else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|&quot;
             + &quot;pass|raise|return|try|while|with|yield|self|match|case&quot;).split(&quot;|&quot;);

  var pyRe = new RegExp(
      &quot;(#[^\\n]*)&quot;
    + &quot;|(\&quot;\&quot;\&quot;[\\s\\S]*?\&quot;\&quot;\&quot;|&#39;&#39;&#39;[\\s\\S]*?&#39;&#39;&#39;&quot;
    +   &quot;|\&quot;(?:\\\\.|[^\&quot;\\\\\\n])*\&quot;|&#39;(?:\\\\.|[^&#39;\\\\\\n])*&#39;)&quot;
    + &quot;|(@[\\w.]+)&quot;
    + &quot;|\\b(&quot; + PY_KW.join(&quot;|&quot;) + &quot;)\\b&quot;
    + &quot;|\\b(\\d[\\w.]*)\\b&quot;
    + &quot;|\\b([a-zA-Z_]\\w*)(?=\\()&quot;
    , &quot;g&quot;);

  var shRe = /(#[^\n]*)|(&quot;(?:\\.|[^&quot;\\])*&quot;|&#39;(?:\\.|[^&#39;\\])*&#39;)|(^|\s)(--?[\w-]+)/g;

  function esc(s) {
    return s.replace(/&amp;/g, &quot;&amp;amp;&quot;).replace(/&lt;/g, &quot;&amp;lt;&quot;).replace(/&gt;/g, &quot;&amp;gt;&quot;);
  }

  function highlightPy(text) {
    return esc(text).replace(pyRe, function (m, com, str, dec, kw, num, fn) {
      if (com) return &#39;&lt;span class=&quot;t-com&quot;&gt;&#39; + com + &quot;&lt;/span&gt;&quot;;
      if (str) return &#39;&lt;span class=&quot;t-str&quot;&gt;&#39; + str + &quot;&lt;/span&gt;&quot;;
      if (dec) return &#39;&lt;span class=&quot;t-dec&quot;&gt;&#39; + dec + &quot;&lt;/span&gt;&quot;;
      if (kw)  return &#39;&lt;span class=&quot;t-kw&quot;&gt;&#39;  + kw  + &quot;&lt;/span&gt;&quot;;
      if (num) return &#39;&lt;span class=&quot;t-num&quot;&gt;&#39; + num + &quot;&lt;/span&gt;&quot;;
      if (fn)  return &#39;&lt;span class=&quot;t-fn&quot;&gt;&#39;  + fn  + &quot;&lt;/span&gt;&quot;;
      return m;
    });
  }

  function highlightSh(text) {
    return esc(text).replace(shRe, function (m, com, str, pre, flag) {
      if (com)  return &#39;&lt;span class=&quot;t-com&quot;&gt;&#39; + com + &quot;&lt;/span&gt;&quot;;
      if (str)  return &#39;&lt;span class=&quot;t-str&quot;&gt;&#39; + str + &quot;&lt;/span&gt;&quot;;
      if (flag) return pre + &#39;&lt;span class=&quot;t-dec&quot;&gt;&#39; + flag + &quot;&lt;/span&gt;&quot;;
      return m;
    });
  }

  function highlightOut(text) {
    return esc(text)
      .replace(/^(.*(AttributeError|TypeError):.*)$/gm, &#39;&lt;span class=&quot;t-fail&quot;&gt;$1&lt;/span&gt;&#39;);
  }

  root.querySelectorAll(&quot;pre code&quot;).forEach(function (el) {
    var raw = el.textContent;
    el.dataset.raw = raw;
    if (el.classList.contains(&quot;out&quot;))     el.innerHTML = highlightOut(raw);
    else if (el.classList.contains(&quot;py&quot;)) el.innerHTML = highlightPy(raw);
    else                                  el.innerHTML = highlightSh(raw);
  });

  root.querySelectorAll(&quot;.copy&quot;).forEach(function (btn) {
    btn.addEventListener(&quot;click&quot;, function (ev) {
      ev.preventDefault();
      var code = btn.closest(&quot;.snippet&quot;).querySelector(&quot;code&quot;);
      var text = code.dataset.raw || code.textContent;
      var done = function () {
        btn.textContent = &quot;copied&quot;;
        btn.classList.add(&quot;ok&quot;);
        setTimeout(function () { btn.textContent = &quot;copy&quot;; btn.classList.remove(&quot;ok&quot;); }, 1200);
      };
      if (navigator.clipboard &amp;&amp; navigator.clipboard.writeText) {
        navigator.clipboard.writeText(text).then(done, function () {});
      } else {
        var ta = document.createElement(&quot;textarea&quot;);
        ta.value = text; ta.style.position = &quot;fixed&quot;; ta.style.opacity = &quot;0&quot;;
        document.body.appendChild(ta); ta.select();
        try { document.execCommand(&quot;copy&quot;); done(); } catch (e) {}
        document.body.removeChild(ta);
      }
    });
  });
})();
&lt;/script&gt;
</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/8696619834403767024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2026/08/a-b-means-either-reading-union-type.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/8696619834403767024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/8696619834403767024'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2026/08/a-b-means-either-reading-union-type.html' title='A | B means either: reading union type hints in Python'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-7728461546476975813</id><published>2026-08-23T11:46:57.580-07:00</published><updated>2026-08-23T13:06:56.222-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ALPR"/><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="ANPR"/><category scheme="http://www.blogger.com/atom/ns#" term="desktop"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="license plate"/><category scheme="http://www.blogger.com/atom/ns#" term="MMC"/><category scheme="http://www.blogger.com/atom/ns#" term="team"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><category scheme="http://www.blogger.com/atom/ns#" term="vehicle identification"/><title type='text'>MareArts ANPR App: On-Device Plates, MMC Vehicle Info, Team Sync, Web and Desktop Viewers</title><content type='html'>&lt;style&gt;
/* study.marearts.com — MareArts ANPR mobile app (product).
   Scoped under #am-guide. Dark only; Blogger has no theme toggle. */
#am-guide{
  --bg:transparent; --panel:#34383f; --line:#454b54;
  --fg:#d4d7dc; --fg-strong:#eef0f3; --fg-dim:#a3a9b2;
  --accent:#f1c232; --accent-2:#29aae1;
  --sans:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif;
}
#am-guide,#am-guide *{box-sizing:border-box}
#am-guide{
  background:var(--bg); color:var(--fg);
  font-family:var(--sans); font-size:16px; line-height:1.7;
  -webkit-font-smoothing:antialiased;
  padding:2px 0 36px; border:0;
}
#am-guide .wrap{max-width:720px;margin:0 auto;min-width:0}
#am-guide .lede{font-size:18px;color:var(--fg-dim);max-width:70ch;margin:0 0 16px}
#am-guide h2{
  font-family:var(--sans); font-size:15px; text-transform:uppercase;
  letter-spacing:.1em; color:var(--accent-2); font-weight:700;
  margin:36px 0 8px; padding-top:18px; border-top:1px solid var(--line);
  scroll-margin-top:12px;
}
#am-guide h3{font-family:var(--sans); font-size:18px; color:var(--fg-strong); margin:22px 0 8px}
#am-guide p{max-width:70ch;margin:10px 0}
#am-guide ul,#am-guide ol{max-width:70ch;padding-left:22px;margin:8px 0}
#am-guide ul{list-style:disc}
#am-guide ol{list-style:decimal}
#am-guide li{margin:5px 0; color:var(--fg)}
#am-guide a{color:var(--accent)}
#am-guide strong{color:var(--fg-strong);font-weight:650}
#am-guide h2{color:var(--accent-2) !important}
#am-guide h3{color:var(--fg-strong) !important}
#am-guide p,#am-guide li{color:var(--fg) !important}
#am-guide a{color:var(--accent) !important}
#am-guide .cta{
  display:flex; flex-wrap:wrap; gap:10px; margin:18px 0 8px;
}
#am-guide .btn{
  display:inline-block; text-decoration:none !important;
  padding:10px 16px; border-radius:8px; font-weight:700; font-size:14px;
}
#am-guide .btn-buy{background:var(--accent); color:#1a1a1a !important}
#am-guide .btn-site{background:var(--panel); color:var(--accent-2) !important; border:1px solid var(--line)}
#am-guide .shots{
  display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:14px 0 6px;
}
#am-guide .shots figure{margin:0}
#am-guide .shots img{
  width:100%; height:auto; border-radius:10px; border:1px solid var(--line);
  display:block; background:#1c1f24;
}
#am-guide .shots figcaption{
  font-size:12px; color:var(--fg-dim); margin-top:6px; text-align:center;
}
#am-guide .land{grid-column:1 / -1}
#am-guide .land img{max-width:100%}
#am-guide .toc{columns:2; max-width:70ch; padding-left:18px; margin:8px 0 16px}
#am-guide .toc li{break-inside:avoid}
#am-guide .stores{display:flex; flex-wrap:wrap; gap:12px; align-items:center; margin:12px 0}
#am-guide .stores img{height:40px; width:auto}
#am-guide .note{
  border-left:3px solid var(--accent-2); padding:8px 12px; margin:14px 0;
  color:var(--fg-dim);
}
@media (max-width:480px){
  #am-guide .shots{grid-template-columns:1fr}
  #am-guide .toc{columns:1}
}
&lt;/style&gt;

&lt;div id=&quot;am-guide&quot; data-tone=&quot;self&quot;&gt;
&lt;div class=&quot;wrap&quot;&gt;

&lt;p class=&quot;lede&quot;&gt;
  &lt;strong&gt;MareArts ANPR&lt;/strong&gt; is a license-plate recognition app for iOS and Android,
  with a &lt;strong&gt;web viewer&lt;/strong&gt; and a &lt;strong&gt;desktop viewer&lt;/strong&gt; on the same account.
  Plates are read on the phone. Cloud &lt;strong&gt;MMC&lt;/strong&gt; (make, model, colour, type, side, nation),
  &lt;strong&gt;team sync&lt;/strong&gt;, rules, maps, and stats sit on
  &lt;a href=&quot;https://www.marearts.com/products/anpr&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;marearts.com&lt;/a&gt;.
&lt;/p&gt;

&lt;div class=&quot;cta&quot;&gt;
  &lt;a class=&quot;btn btn-buy&quot; href=&quot;https://www.marearts.com/products/anpr&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Get a license&lt;/a&gt;
  &lt;a class=&quot;btn btn-site&quot; href=&quot;https://www.marearts.com/pages/my-anpr-data&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Open the web viewer&lt;/a&gt;
&lt;/div&gt;

&lt;ul class=&quot;toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#am-scan&quot;&gt;Scan (on-device and cloud)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#am-mmc&quot;&gt;MMC vehicle info&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#am-data&quot;&gt;Detections, map, stats&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#am-rules&quot;&gt;Whitelist and blacklist&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#am-team&quot;&gt;Team project&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#am-web&quot;&gt;Web viewer&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#am-desk&quot;&gt;Desktop viewer&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#am-more&quot;&gt;Webhook, regions, SDK&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;shots&quot;&gt;
  &lt;figure&gt;
    &lt;img src=&quot;https://www.marearts.com/cdn/shop/files/image0.png?v=1764234712&amp;amp;width=600&quot;
         alt=&quot;MareArts ANPR app live scan with plate box, crop, and 99 percent confidence&quot;&gt;
    &lt;figcaption&gt;Scan — live box, crop, confidence&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;figure&gt;
    &lt;img src=&quot;https://raw.githubusercontent.com/MareArts/MareArts-ANPR/main/mobile_app/mobile_app_screenshot/detection_list.png&quot;
         alt=&quot;MareArts ANPR detections list with mosaicked plates and MMC make model colour&quot;&gt;
    &lt;figcaption&gt;Detections — mosaicked plates plus MMC&lt;/figcaption&gt;
  &lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;am-scan&quot;&gt;Scan: on-device ANPR and cloud&lt;/h2&gt;
&lt;p&gt;
  Hold the phone at the lane. The app finds the plate, reads the characters,
  and stores time plus GPS. No extra camera box and no PC at the gate.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Single&lt;/strong&gt; — one capture.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Continuous&lt;/strong&gt; — keep scanning; a duplicate window (default 5 seconds) skips the same plate.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Cloud&lt;/strong&gt; — send the frame for OCR plus MMC vehicle info in one step.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  On-device mode keeps detection and OCR on the phone after the models are installed.
  Cloud mode is optional when you want vehicle identity with the plate.
&lt;/p&gt;
&lt;p&gt;
  Camera: 1080p, &lt;strong&gt;720p recommended&lt;/strong&gt;, or 480p. Preview 60 or 30 fps.
  Lower resolution is faster and uses less storage. Zoom 1× / 2×, flash, front or rear camera.
  Landscape scanning keeps boxes and controls upright.
&lt;/p&gt;
&lt;p&gt;
  Trial is &lt;strong&gt;10 scans per day&lt;/strong&gt; without login. A license on
  &lt;a href=&quot;https://www.marearts.com/products/anpr&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;the product page&lt;/a&gt;
  removes that cap.
&lt;/p&gt;

&lt;div class=&quot;shots&quot;&gt;
  &lt;figure&gt;
    &lt;img src=&quot;https://raw.githubusercontent.com/MareArts/MareArts-ANPR/main/mobile_app/mobile_app_screenshot/detection_detail_2.png&quot;
         alt=&quot;MareArts ANPR detection detail with mosaicked plate and MMC vehicle info&quot;&gt;
    &lt;figcaption&gt;Detail — mosaicked plate, make, model, colour&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;figure&gt;
    &lt;img src=&quot;https://www.marearts.com/cdn/shop/files/image1-1.png?v=1764234711&amp;amp;width=600&quot;
         alt=&quot;MareArts ANPR statistics with daily bars, total scans, unique vehicles&quot;&gt;
    &lt;figcaption&gt;Stats — daily activity, unique vehicles&lt;/figcaption&gt;
  &lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;am-mmc&quot;&gt;MMC vehicle info (make, model, colour)&lt;/h2&gt;
&lt;p&gt;
  &lt;strong&gt;MMC&lt;/strong&gt; here means MareArts cloud vehicle identity, not a third-party brand.
  For each detection the API can return:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Make and model (with confidence)&lt;/li&gt;
  &lt;li&gt;Colour (with a colour chip)&lt;/li&gt;
  &lt;li&gt;Type (car, SUV, van, …)&lt;/li&gt;
  &lt;li&gt;Side — front or rear&lt;/li&gt;
  &lt;li&gt;Nation — country of the plate&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  The phone list shows a short line such as “Volvo XC60 · black”.
  The detail card shows all six fields. Cloud scan writes MMC immediately;
  on-device scans pick it up on sync. The
  &lt;a href=&quot;https://www.marearts.com/pages/my-anpr-data&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;web viewer&lt;/a&gt;
  filters the same fields (make, model, colour, type).
&lt;/p&gt;
&lt;p class=&quot;note&quot;&gt;
  MMC uses the MareArts cloud API and is included with the subscription.
  Daily vehicle-info usage is shown in Settings.
&lt;/p&gt;
&lt;div class=&quot;shots&quot;&gt;
  &lt;figure&gt;
    &lt;img src=&quot;https://raw.githubusercontent.com/MareArts/MareArts-ANPR/main/mobile_app/mobile_app_screenshot/detection_list.png&quot;
         alt=&quot;MareArts ANPR phone list with mosaicked plates and MMC lines&quot;&gt;
    &lt;figcaption&gt;List — Volvo XC60 · black, and the rest&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;figure&gt;
    &lt;img src=&quot;https://raw.githubusercontent.com/MareArts/MareArts-ANPR/main/mobile_app/mobile_app_screenshot/detection_detail_2.png&quot;
         alt=&quot;MareArts ANPR vehicle info card with make model colour type side nation&quot;&gt;
    &lt;figcaption&gt;Card — make, model, colour, type, side, nation&lt;/figcaption&gt;
  &lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;am-data&quot;&gt;Detections, map, and stats&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;List&lt;/strong&gt; — grouped by day; All / Latest; swipe to set whitelist, blacklist, or unknown.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Detail&lt;/strong&gt; — full frame, plate crop, confidence, first/last seen, GPS, history of that plate.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Map&lt;/strong&gt; — pins and clusters, satellite or road, optional plate labels, search.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Stats&lt;/strong&gt; — today / week / month / year / custom range; unique vehicles; filter by rule status.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;CSV export&lt;/strong&gt; — plate, time, GPS, confidences, rule note, plus MMC columns.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;shots&quot;&gt;
  &lt;figure class=&quot;land&quot;&gt;
    &lt;img src=&quot;https://www.marearts.com/cdn/shop/files/image3-1.png?v=1764234712&amp;amp;width=720&quot;
         alt=&quot;MareArts ANPR detection map with GPS clusters and plate labels on satellite view&quot;&gt;
    &lt;figcaption&gt;Map — clusters, plate labels, GPS&lt;/figcaption&gt;
  &lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;am-rules&quot;&gt;Whitelist and blacklist&lt;/h2&gt;
&lt;p&gt;
  Rules mark a plate as allowed (green) or blocked (red) on the next scan,
  with sound and vibration. Notes can sit on the detection card.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Search, letter groups, swipe to delete, CSV import and export.&lt;/li&gt;
  &lt;li&gt;Upload a large CSV on
      &lt;a href=&quot;https://www.marearts.com/pages/my-anpr-data&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;marearts.com&lt;/a&gt;,
      then pull the package on the phone (replace or merge).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;am-team&quot;&gt;Team project&lt;/h2&gt;
&lt;p&gt;
  One &lt;strong&gt;team leader&lt;/strong&gt; creates a team and shares a password.
  &lt;strong&gt;Members&lt;/strong&gt; join and contribute detections and rules.
  Cloud sync is two-way. Auto-sync can run when the app goes to the background.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Leader sees every member’s data on the web viewer and can switch member in the dashboard.&lt;/li&gt;
  &lt;li&gt;Desktop viewer for a leader can pull the same team detections.&lt;/li&gt;
  &lt;li&gt;Leave or break team returns a user to solo mode.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Typical use: several guards at a gate, one supervisor on
  &lt;a href=&quot;https://www.marearts.com/pages/my-anpr-data&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;the web viewer&lt;/a&gt;
  without standing at the lane.
&lt;/p&gt;

&lt;h2 id=&quot;am-web&quot;&gt;Web viewer&lt;/h2&gt;
&lt;p&gt;
  After login, &lt;a href=&quot;https://www.marearts.com/pages/my-anpr-data&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;My ANPR Data&lt;/a&gt;
  is the browser console for the same account: detections, MMC filters,
  rule packages, team member switch, export.
  The phone captures; the browser reviews.
&lt;/p&gt;
&lt;div class=&quot;shots&quot;&gt;
  &lt;figure class=&quot;land&quot;&gt;
    &lt;img src=&quot;https://raw.githubusercontent.com/MareArts/MareArts-ANPR/main/mobile_app/mobile_app_screenshot/detection_list_vehicleinfo_web_ui.png&quot;
         alt=&quot;MareArts ANPR web viewer detection list with make model colour columns&quot;&gt;
    &lt;figcaption&gt;Web viewer — detections with MMC columns&lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;figure class=&quot;land&quot;&gt;
    &lt;img src=&quot;https://raw.githubusercontent.com/MareArts/MareArts-ANPR/main/mobile_app/mobile_app_screenshot/Vehicle_info_filter_web_ui.png&quot;
         alt=&quot;MareArts ANPR web viewer filters for vehicle make model color and type&quot;&gt;
    &lt;figcaption&gt;Web viewer — filter by make, model, colour, type&lt;/figcaption&gt;
  &lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;am-desk&quot;&gt;Desktop viewer&lt;/h2&gt;
&lt;p&gt;
  &lt;a href=&quot;https://www.marearts.com/pages/anpr-desktop-download&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;MareArts ANPR Desktop&lt;/a&gt;
  is a free companion for &lt;strong&gt;Windows, macOS, and Linux&lt;/strong&gt;.
  Same login. It is a &lt;strong&gt;read-only viewer&lt;/strong&gt;: it downloads cloud data
  and does not edit or delete it. Capture and rule changes stay on the phone.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Detections with MMC and location&lt;/li&gt;
  &lt;li&gt;Map with clustering&lt;/li&gt;
  &lt;li&gt;Rules (view)&lt;/li&gt;
  &lt;li&gt;Statistics&lt;/li&gt;
  &lt;li&gt;Local image drop — run a still through the MareArts ANPR cloud API&lt;/li&gt;
  &lt;li&gt;One-click sync, optional auto-sync&lt;/li&gt;
  &lt;li&gt;Team leader: all members’ detections, same as the web viewer&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;shots&quot;&gt;
  &lt;figure class=&quot;land&quot;&gt;
    &lt;img src=&quot;https://www.marearts.com/cdn/shop/files/Screenshot_2026-07-24_at_18.43.56.png?v=1784907869&amp;amp;width=900&quot;
         alt=&quot;MareArts ANPR Desktop viewer detections list with vehicle thumbnails and MMC tags&quot;&gt;
    &lt;figcaption&gt;Desktop viewer — detections and MMC on a large screen&lt;/figcaption&gt;
  &lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;am-more&quot;&gt;Webhook, plate regions, SDK&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Webhook&lt;/strong&gt; — JSON to Discord, Slack, Zapier, Make, or your own URL (plate, time, GPS, confidences, bbox, rule, optional image).&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Plate region&lt;/strong&gt; — Universal, Europe+, Korea, North America, China.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Thresholds&lt;/strong&gt; — detection and OCR 60–95% (90% recommended); max plates per frame 1–10.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Python ANPR SDK&lt;/strong&gt; and Road Objects SDK — same license family; offline after activation. See
      &lt;a href=&quot;https://www.marearts.com/products/anpr&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;the license page&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;am-start&quot;&gt;How to start&lt;/h2&gt;
&lt;ol&gt;
  &lt;li&gt;Install &lt;strong&gt;MareArts ANPR&lt;/strong&gt; (search “marearts anpr” on the App Store or Google Play).&lt;/li&gt;
  &lt;li&gt;Open Scan and use the daily trial.&lt;/li&gt;
  &lt;li&gt;Subscribe on
      &lt;a href=&quot;https://www.marearts.com/products/anpr&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;www.marearts.com/products/anpr&lt;/a&gt;.
      The serial key is emailed to the PayPal address and also appears after login.&lt;/li&gt;
  &lt;li&gt;Sign in under Settings. Sync fills the
      &lt;a href=&quot;https://www.marearts.com/pages/my-anpr-data&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;web viewer&lt;/a&gt;
      and the
      &lt;a href=&quot;https://www.marearts.com/pages/anpr-desktop-download&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;desktop viewer&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;stores&quot;&gt;
  &lt;a href=&quot;https://apps.apple.com/us/app/marearts-anpr/id6753904859&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;img alt=&quot;Download MareArts ANPR on the App Store&quot; src=&quot;https://developer.apple.com/assets/elements/badges/download-on-the-app-store.svg&quot;&gt;
  &lt;/a&gt;
  &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.marearts.anpr&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;img alt=&quot;Get MareArts ANPR on Google Play&quot; src=&quot;https://play.google.com/intl/en_us/badges/static/images/badges/en_badge_web_generic.png&quot; style=&quot;height:58px&quot;&gt;
  &lt;/a&gt;
&lt;/div&gt;
&lt;p class=&quot;note&quot;&gt;
  Serial keys are bound to the PayPal email and cannot be moved.
  Plans and SDK options stay on the
  &lt;a href=&quot;https://www.marearts.com/products/anpr&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;product page&lt;/a&gt;.
&lt;/p&gt;

&lt;div class=&quot;cta&quot;&gt;
  &lt;a class=&quot;btn btn-buy&quot; href=&quot;https://www.marearts.com/products/anpr&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Subscribe on marearts.com&lt;/a&gt;
  &lt;a class=&quot;btn btn-site&quot; href=&quot;https://www.marearts.com/pages/anpr-desktop-download&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Download Desktop Viewer&lt;/a&gt;
&lt;/div&gt;

&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/7728461546476975813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2026/08/marearts-anpr-mobile-app-on-device.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/7728461546476975813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/7728461546476975813'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2026/08/marearts-anpr-mobile-app-on-device.html' title='MareArts ANPR App: On-Device Plates, MMC Vehicle Info, Team Sync, Web and Desktop Viewers'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-5655145355271335454</id><published>2026-08-23T03:31:17.532-07:00</published><updated>2026-08-23T03:31:17.532-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ABI"/><category scheme="http://www.blogger.com/atom/ns#" term="API"/><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="ctypes"/><category scheme="http://www.blogger.com/atom/ns#" term="linking"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><title type='text'>API and ABI, and the line between them</title><content type='html'>&lt;style&gt;
/* ------------------------------------------------------------------
   study.marearts.com article body — API/ABI guide.
   Every selector is scoped under #ab-guide so nothing leaks onto the
   theme chrome (post title, date header, sidebar, comments).

   Palette is derived from the blog&#39;s own Awesome Inc. dark theme so
   the post reads as native rather than as an embedded card:
     page background #2d3037   body text #cccccc
     links #f1c232 (gold)      link hover / post titles #29aae1
     date headers #8ce1f5
   There is no light variant on purpose. Blogger has no theme-toggle
   attribute, so a light default would be the only thing that ever
   rendered — which is exactly how this post shipped white the first
   time. Panels are graded around #2d3037 instead of using an absolute
   background, so the article never fights the page it sits on.
   ------------------------------------------------------------------ */
#ab-guide{
  --bg:transparent; --panel:#34383f; --panel2:#3b4048; --line:#454b54;
  --fg:#d4d7dc; --fg-strong:#eef0f3; --fg-dim:#a3a9b2; --fg-faint:#848b95;
  --accent:#f1c232; --accent-2:#29aae1; --warn:#ffb454; --danger:#ff7a84;
  --code-bg:#23262c; --code-fg:#d4d7dc;
  --kw:#c792ea; --str:#c3e88d; --com:#828a94; --num:#f78c6c;
  --dec:#ffcb6b; --fn:#82aaff; --inline-code:#e6d3ff;
  --pass:#4fd6b0; --fail:#ff7a84;
  --mono:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,&quot;JetBrains Mono&quot;,Menlo,Consolas,&quot;Liberation Mono&quot;,monospace;
  --sans:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif;
}
#ab-guide, #ab-guide *{box-sizing:border-box}
#ab-guide{
  background:var(--bg); color:var(--fg);
  font-family:var(--sans); font-size:16px; line-height:1.7;
  -webkit-font-smoothing:antialiased;
  /* No frame: the theme already pads the post column, so a border plus
     its own background would read as a widget pasted onto the page. */
  padding:2px 0 44px; border:0; border-radius:0;
}
#ab-guide .wrap{max-width:1000px;margin:0 auto;min-width:0}

/* headings */
#ab-guide h1{font-size:38px;line-height:1.18;letter-spacing:-.8px;margin:0 0 12px;color:var(--fg)}
#ab-guide .lede{font-size:18px;color:var(--fg-dim);max-width:70ch;margin:0 0 8px}
/* font-family is restated on h2/h4: the theme styles bare `h2` and `h4`
   with a `font:` shorthand, which sets Arial and beats plain inheritance
   from #ab-guide. */
#ab-guide h2{
  font-family:var(--sans);line-height:inherit;
  font-size:15px;text-transform:uppercase;letter-spacing:.1em;color:var(--accent-2);
  margin:64px 0 6px;padding-top:22px;border-top:1px solid var(--line);font-weight:700;
  scroll-margin-top:16px;
}
/* line-height is pinned to inherit rather than left undeclared: the
   site-wide tone CSS sets a heading line-height, and an undeclared
   property is the one thing an opt-out guard cannot protect if that
   guard ever fails to apply. `inherit` reproduces exactly what these
   headings render at today. */
#ab-guide h3{font-size:25px;line-height:inherit;letter-spacing:-.4px;margin:38px 0 10px;color:var(--fg-strong);scroll-margin-top:20px}
#ab-guide h4{font-family:var(--sans);font-size:16.5px;line-height:inherit;font-weight:600;margin:26px 0 8px;color:var(--fg-strong)}
#ab-guide p{max-width:74ch;margin:12px 0}
#ab-guide ul, #ab-guide ol{max-width:74ch;padding-left:22px;margin:10px 0}
/* The theme&#39;s `.main-inner .widget ul{list-style:none}` strips markers from
   every list in the post body, so the markers are put back explicitly. */
#ab-guide ul{list-style:disc}
#ab-guide ol{list-style:decimal}
#ab-guide li{margin:6px 0}
#ab-guide a{color:var(--accent)}
#ab-guide code{
  font-family:var(--mono);font-size:.875em;background:var(--panel2);
  padding:2px 6px;border-radius:4px;border:1px solid var(--line);color:var(--inline-code);
}
#ab-guide strong{color:var(--fg-strong);font-weight:650}
#ab-guide em{font-style:italic}

/* code blocks */
#ab-guide .snippet{margin:18px 0;border:1px solid var(--line);border-radius:10px;overflow:hidden;background:var(--code-bg)}
#ab-guide .snippet-head{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:7px 12px;background:var(--panel);border-bottom:1px solid var(--line);
}
#ab-guide .snippet-name{font-family:var(--mono);font-size:12px;color:var(--fg-faint)}
#ab-guide .snippet-name b{color:var(--fg-dim);font-weight:600}
#ab-guide .copy{
  background:transparent;border:1px solid var(--line);color:var(--fg-faint);
  font-size:11px;padding:3px 9px;border-radius:5px;cursor:pointer;font-family:var(--sans);line-height:1.4;
}
#ab-guide .copy:hover{color:var(--fg);border-color:var(--fg-faint)}
#ab-guide .copy.ok{color:var(--accent-2);border-color:var(--accent-2)}
#ab-guide pre{
  margin:0;padding:14px 16px;overflow-x:auto;background:var(--code-bg);
  font-family:var(--mono);font-size:13.5px;line-height:1.62;color:var(--code-fg);
  border:0;border-radius:0;
}
#ab-guide pre code{background:none;border:0;padding:0;font-size:inherit;color:inherit}
#ab-guide pre::-webkit-scrollbar{height:9px}
#ab-guide pre::-webkit-scrollbar-thumb{background:var(--line);border-radius:5px}
#ab-guide .out pre{color:var(--fg-dim)}
#ab-guide .out .snippet-name b{color:var(--warn)}

/* syntax colors */
#ab-guide .t-kw{color:var(--kw)}
#ab-guide .t-str{color:var(--str)}
#ab-guide .t-com{color:var(--com);font-style:italic}
#ab-guide .t-num{color:var(--num)}
#ab-guide .t-dec{color:var(--dec)}
#ab-guide .t-fn{color:var(--fn)}
#ab-guide .t-pass{color:var(--pass)}
#ab-guide .t-fail{color:var(--fail)}

/* callouts */
/* Info reads cyan, not gold: gold is the theme&#39;s link colour and would
   collide with .warn&#39;s amber at these low alphas. */
#ab-guide .note{
  border-left:3px solid var(--accent-2);background:rgba(41,170,225,.09);
  padding:12px 16px;margin:18px 0;border-radius:0 8px 8px 0;max-width:74ch;
}
#ab-guide .note.warn{border-color:var(--warn);background:rgba(255,180,84,.08)}
#ab-guide .note.trap{border-color:var(--danger);background:rgba(255,122,132,.08)}
#ab-guide .note .tag{
  display:block;font-size:10.5px;text-transform:uppercase;letter-spacing:.1em;
  font-weight:700;color:var(--accent-2);margin-bottom:3px;
}
#ab-guide .note.warn .tag{color:var(--warn)}
#ab-guide .note.trap .tag{color:var(--danger)}
#ab-guide .note p{margin:5px 0}
#ab-guide .note .tag code{
  background:none !important;border:0 !important;padding:0 !important;
  color:inherit !important;font-size:1em !important;
}

/* tables */
#ab-guide .table-wrap{overflow-x:auto;margin:18px 0}
#ab-guide table{border-collapse:collapse;width:100%;margin:0;font-size:14.5px;background:none}
#ab-guide th, #ab-guide td{text-align:left;padding:9px 13px;border:0;border-bottom:1px solid var(--line);vertical-align:top}
#ab-guide th{color:var(--fg-faint);font-size:11.5px;text-transform:uppercase;letter-spacing:.07em;font-weight:700}
#ab-guide td code{font-size:.9em}
#ab-guide tbody tr:hover{background:var(--panel)}

/* furniture */
#ab-guide .kicker{
  font-size:12px;font-weight:700;letter-spacing:.13em;text-transform:uppercase;
  color:var(--accent-2);margin-bottom:14px;
}
#ab-guide .rule{height:1px;background:var(--line);margin:30px 0 4px;max-width:74ch}

#ab-guide .toc{
  border:1px solid var(--line);border-radius:12px;background:var(--panel);
  padding:20px 24px;margin:34px 0 10px;max-width:74ch;
}
#ab-guide .toc h4{margin:0 0 14px;font-size:13px;text-transform:uppercase;letter-spacing:.1em;color:var(--fg-faint)}
#ab-guide .toc ol{margin:0;padding-left:20px;max-width:none}
#ab-guide .toc &gt; ol &gt; li{margin:14px 0}
#ab-guide .toc &gt; ol &gt; li &gt; a{text-decoration:none;font-weight:650;font-size:16.5px}
#ab-guide .toc a{text-decoration:none;color:var(--accent)}
#ab-guide .toc a:hover{text-decoration:underline}
#ab-guide .toc span{color:var(--fg-faint);font-weight:400;font-size:14px}
#ab-guide .toc ul{
  list-style:none;margin:7px 0 0;padding-left:0;max-width:none;
  display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:1px 18px;
}
#ab-guide .toc ul li{margin:0}
#ab-guide .toc ul a{font-size:14px;color:var(--fg-dim)}
#ab-guide .toc ul a:hover{color:var(--accent)}

#ab-guide .takeaway{
  border:1px solid var(--line);border-left:3px solid var(--accent-2);
  border-radius:0 12px 12px 0;background:var(--panel);
  padding:18px 22px;margin:26px 0;max-width:74ch;
}
#ab-guide .takeaway h4{margin:0 0 10px;font-size:14px;text-transform:uppercase;letter-spacing:.08em;color:var(--accent-2)}
#ab-guide .takeaway ul{margin:0;padding-left:20px}

/* Always stacked, never side by side: the theme&#39;s centre column is ~545px
   of content, so two code panes would each get ~265px and clip mid-token
   regardless of viewport width (the 900px media query never fires). */
#ab-guide .grid2{display:grid;grid-template-columns:1fr;gap:16px}
#ab-guide .grid2 .snippet{margin:0;min-width:0}
#ab-guide .badge{
  display:inline-block;font-size:11px;padding:2px 8px;border-radius:20px;
  border:1px solid var(--line);color:var(--fg-faint);margin-left:8px;vertical-align:middle;
  letter-spacing:normal;line-height:1.4;text-align:left;background:none;
}
#ab-guide .kbd{
  font-family:var(--mono);font-size:12px;background:var(--panel2);border:1px solid var(--line);
  border-bottom-width:2px;border-radius:4px;padding:1px 6px;
}
#ab-guide .foot{
  margin-top:70px;padding-top:20px;border-top:1px solid var(--line);
  color:var(--fg-faint);font-size:13px;
}
/* ------------------------------------------------------------------
   The Blogger theme re-colours bare descendants of the post container:
   body{color:#cccccc}, .post-body ul li{color:#cccccc},
   .main-inner .widget ul li{color:#ffffff}, a:link{color:#f1c232},
   h2{color:#8ce1f5}, h4{color:#29aae1}. Re-assert the article palette
   here — #ab-guide carries an id, so it wins on specificity, and the
   !important guards cover the handful of host rules that use it too.
   Kept deliberately narrow: anything with a per-component colour of its
   own (.toc h4, .takeaway h4, .note .tag) must not be caught by these.
   ------------------------------------------------------------------ */
#ab-guide h1, #ab-guide h3{color:var(--fg-strong) !important}
#ab-guide h2{color:var(--accent-2) !important}
#ab-guide p{color:var(--fg) !important}
#ab-guide li{color:var(--fg) !important;padding:0;border:0}
#ab-guide .lede{color:var(--fg-dim) !important}
#ab-guide strong{color:var(--fg-strong) !important}
#ab-guide a, #ab-guide .toc a{color:var(--accent) !important}
#ab-guide .toc ul a{color:var(--fg-dim) !important}
#ab-guide a:hover, #ab-guide .toc ul a:hover{color:var(--accent) !important}
#ab-guide code{background:var(--panel2) !important;color:var(--inline-code) !important}
#ab-guide pre code{background:none !important;color:var(--code-fg) !important}
#ab-guide table{background:none !important;table-layout:auto !important}
#ab-guide th{background:var(--panel2) !important;color:var(--fg-faint) !important}
#ab-guide td{color:var(--fg) !important}
#ab-guide th, #ab-guide td{border-color:var(--line) !important}
#ab-guide tbody tr:hover{background:var(--panel) !important}

@media screen and (max-width:900px){
  #ab-guide{padding:2px 0 36px}
  #ab-guide table{font-size:13.5px}
}
@media screen and (max-width:640px){
  #ab-guide .toc ul{grid-template-columns:1fr}
}

#ab-guide .yes{color:var(--danger);font-weight:650}
#ab-guide .no{color:var(--accent-2);font-weight:650}
#ab-guide .fg-faint{color:var(--fg-faint)}
&lt;/style&gt;

&lt;div id=&quot;ab-guide&quot; data-tone=&quot;self&quot;&gt;
&lt;div class=&quot;wrap&quot;&gt;

&lt;div class=&quot;kicker&quot;&gt;C · Python · Linking&lt;/div&gt;
&lt;p class=&quot;lede&quot;&gt;
  Two acronyms one letter apart, describing promises made at two different moments. An API is what
  you agree to when you write the call. An ABI is what your compiled bytes agree to when they meet
  somebody else&#39;s compiled bytes — and unlike the API, breaking it usually produces no error at all.
&lt;/p&gt;

&lt;div class=&quot;rule&quot;&gt;&lt;/div&gt;

&lt;p&gt;
  The clearest way in is to put them side by side. Only the middle word differs:
  &lt;strong&gt;P&lt;/strong&gt;rogramming or &lt;strong&gt;B&lt;/strong&gt;inary.
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;&lt;th&gt;Acronym&lt;/th&gt;&lt;th&gt;Level&lt;/th&gt;&lt;th&gt;A promise that sounds like&lt;/th&gt;&lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;API&lt;/strong&gt;&lt;br&gt;&lt;span class=&quot;fg-faint&quot;&gt;Application &lt;em&gt;Programming&lt;/em&gt; Interface&lt;/span&gt;&lt;/td&gt;
      &lt;td&gt;source code&lt;/td&gt;
      &lt;td&gt;&quot;there is a function &lt;code&gt;resize(img, width, height)&lt;/code&gt; and it returns an &lt;code&gt;int&lt;/code&gt;&quot;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;ABI&lt;/strong&gt;&lt;br&gt;&lt;span class=&quot;fg-faint&quot;&gt;Application &lt;em&gt;Binary&lt;/em&gt; Interface&lt;/span&gt;&lt;/td&gt;
      &lt;td&gt;machine code and memory&lt;/td&gt;
      &lt;td&gt;&quot;&lt;code&gt;width&lt;/code&gt; is at byte 0 and is 4 bytes; the first argument arrives in register &lt;code&gt;rdi&lt;/code&gt;&quot;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;
  An API is a contract between a programmer and a library. An ABI is a contract between two piles of
  already-compiled machine code. That is why two languages can call each other at all: Python has no
  idea what a C header looks like, but if it lays the bytes out the way the ABI says and puts the
  arguments where the ABI says, the call works.
&lt;/p&gt;
&lt;p&gt;
  This post is in five parts. First the distinction and what an ABI actually specifies. Then the three
  pieces you can see and measure — struct layout, symbol names, argument registers — each with a
  program you can run. Then the same boundary crossed from Python, including two mistakes that produce
  wrong answers in total silence. Finally, what it takes to keep an ABI stable once other people
  depend on it.
&lt;/p&gt;
&lt;p&gt;
  Everything was compiled and run before publishing: gcc 11.4.0 on x86-64 Linux, CPython 3.10.12, GNU
  binutils 2.38. Every output block is copied from a real run.
&lt;/p&gt;

&lt;div class=&quot;toc&quot;&gt;
  &lt;h4&gt;Contents&lt;/h4&gt;
  &lt;ol&gt;
    &lt;li&gt;
      &lt;a href=&quot;#ab-contracts&quot;&gt;Two contracts&lt;/a&gt;
      &lt;span&gt;— the distinction, and why it costs you a rebuild&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-contracts&quot;&gt;What each promises&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-rebuild&quot;&gt;Recompile, relink, neither&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-decides&quot;&gt;What an ABI decides&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;#ab-offsets&quot;&gt;Struct layout&lt;/a&gt;
      &lt;span&gt;— the part you can print out&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-offsets&quot;&gt;Where fields land&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-padding&quot;&gt;Alignment and padding&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-reorder&quot;&gt;Reordering is a break&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;#ab-mangling&quot;&gt;Symbols and registers&lt;/a&gt;
      &lt;span&gt;— what the linker sees, and where arguments go&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-mangling&quot;&gt;Name mangling&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-externc&quot;&gt;extern &quot;C&quot;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-calling&quot;&gt;The calling convention&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-queues&quot;&gt;Two register queues&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;#ab-python&quot;&gt;Crossing from Python&lt;/a&gt;
      &lt;span&gt;— where a mismatch stops being theoretical&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-python&quot;&gt;The library&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-mirror&quot;&gt;A mirror that matches&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-wrong&quot;&gt;A mirror that doesn&#39;t&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-restype&quot;&gt;The restype trap&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;#ab-stability&quot;&gt;Keeping an ABI&lt;/a&gt;
      &lt;span&gt;— what breaks what, and how libraries survive it&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-stability&quot;&gt;What breaks which&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-techniques&quot;&gt;Techniques&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-soname&quot;&gt;soname&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;#ab-tools&quot;&gt;Reference&lt;/a&gt;
      &lt;span&gt;— tools, cheat sheet, and a one-screen summary&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-tools&quot;&gt;Tools&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-cheatsheet&quot;&gt;Cheat sheet&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-closing&quot;&gt;Wrapping up&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#ab-further&quot;&gt;Further reading&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;

&lt;!-- ==================== PART 1 ==================== --&gt;
&lt;h2&gt;Part 1 · Two contracts&lt;/h2&gt;

&lt;h3 id=&quot;ab-contracts&quot;&gt;What each one promises&lt;/h3&gt;
&lt;p&gt;
  Take an ordinary header. It declares a struct and a function:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;the API, as written&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;struct config {
    int    width;
    int    height;
    double scale;
};

int config_area(const struct config *c);&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Everything visible there is API: the names, the types, the order of the parameters, the fact that
  the function takes a pointer rather than a value. If any of it changes, code that calls it stops
  compiling — loudly, with a file and a line number.
&lt;/p&gt;
&lt;p&gt;
  The ABI is everything the compiler decided &lt;em&gt;underneath&lt;/em&gt; that text, and none of it appears in
  the header: that &lt;code&gt;width&lt;/code&gt; begins at byte 0, that &lt;code&gt;scale&lt;/code&gt; begins at byte 8 and
  not byte 12, that the whole struct occupies 16 bytes, that the pointer argument arrives in the
  register &lt;code&gt;rdi&lt;/code&gt;, that the &lt;code&gt;int&lt;/code&gt; comes back in &lt;code&gt;eax&lt;/code&gt;, and that the
  symbol is spelled &lt;code&gt;config_area&lt;/code&gt; rather than &lt;code&gt;_Z11config_areaPK6config&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  Those decisions are just as much a contract, and both sides are bound by them. The difference is
  what happens when one side changes its mind.
&lt;/p&gt;

&lt;h3 id=&quot;ab-rebuild&quot;&gt;Recompile, relink, neither&lt;/h3&gt;
&lt;p&gt;
  The practical consequence of the distinction is what a change costs the people who use your library.
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;&lt;th&gt;Change&lt;/th&gt;&lt;th&gt;API&lt;/th&gt;&lt;th&gt;ABI&lt;/th&gt;&lt;th&gt;What users must do&lt;/th&gt;&lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Fix a bug inside a function body&lt;/td&gt;
      &lt;td class=&quot;no&quot;&gt;intact&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;intact&lt;/td&gt;
      &lt;td&gt;Nothing. Drop in the new &lt;code&gt;.so&lt;/code&gt;.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Add a brand-new function&lt;/td&gt;
      &lt;td class=&quot;no&quot;&gt;intact&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;intact&lt;/td&gt;
      &lt;td&gt;Nothing, unless they want the new one.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Rename a function&lt;/td&gt;
      &lt;td class=&quot;yes&quot;&gt;broken&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;broken&lt;/td&gt;
      &lt;td&gt;Edit their source, rebuild. The compiler tells them.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Reorder two struct fields&lt;/td&gt;
      &lt;td class=&quot;no&quot;&gt;intact&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;broken&lt;/td&gt;
      &lt;td&gt;Rebuild — and &lt;strong&gt;nothing tells them.&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Change a field from &lt;code&gt;int&lt;/code&gt; to &lt;code&gt;long&lt;/code&gt;&lt;/td&gt;
      &lt;td class=&quot;no&quot;&gt;mostly intact&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;broken&lt;/td&gt;
      &lt;td&gt;Rebuild. Again, silently.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;
  The last two rows are the whole reason this topic matters. A broken API is a compiler error; a
  broken ABI is a program that runs and gives you the wrong number. The rest of this post is mostly
  about making that second row concrete enough that you can spot it.
&lt;/p&gt;

&lt;h3 id=&quot;ab-decides&quot;&gt;What an ABI decides&lt;/h3&gt;
&lt;p&gt;
  For a plain C interface on one machine, the list is short and worth memorising:
&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Struct layout&lt;/strong&gt; — which byte each field starts at, and how big the whole thing is. Part 2.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Symbol naming&lt;/strong&gt; — what the function is called in the object file. Part 3.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;The calling convention&lt;/strong&gt; — which register or stack slot each argument travels in, and who cleans up. Part 3.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Return values&lt;/strong&gt; — which register the result comes back in, which depends on its type.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;
  Sizes and alignments of the basic types sit underneath all four. C only guarantees relationships —
  that a &lt;code&gt;long&lt;/code&gt; is at least as wide as an &lt;code&gt;int&lt;/code&gt; — and the ABI picks the actual
  numbers, which is why &lt;code&gt;long&lt;/code&gt; is 8 bytes on Linux and 4 bytes on 64-bit Windows.
&lt;/p&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Naming&lt;/span&gt;
  &lt;p&gt;
    The convention used throughout this post is the x86-64 System V ABI, which is what Linux and macOS
    use. Windows has a different one, as do 32-bit x86 and the various ARM targets. The concepts
    transfer exactly; the specific registers do not.
  &lt;/p&gt;
&lt;/div&gt;

&lt;!-- ==================== PART 2 ==================== --&gt;
&lt;h2&gt;Part 2 · Struct layout&lt;/h2&gt;

&lt;h3 id=&quot;ab-offsets&quot;&gt;Where the fields actually land&lt;/h3&gt;
&lt;p&gt;
  You do not have to guess at any of this. &lt;code&gt;offsetof&lt;/code&gt; and &lt;code&gt;sizeof&lt;/code&gt; report what
  the compiler decided, and &lt;code&gt;_Alignof&lt;/code&gt; reports the rule it was following.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;layout.c&lt;/b&gt; — same fields, two orders&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;struct badly_ordered {
    char   tag;
    double value;
    int    id;
};

struct well_ordered {
    double value;
    int    id;
    char   tag;
};

#define SHOW(S, M)                                                       \
    printf(&quot;  %-6s offset %2zu   size %2zu   align %2zu\n&quot;, #M,          \
           offsetof(S, M), sizeof(((S *)0)-&amp;gt;M), _Alignof(((S *)0)-&amp;gt;M))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;./layout&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;struct badly_ordered   sizeof = 24   align 8
  tag    offset  0   size  1   align  1
  value  offset  8   size  8   align  8
  id     offset 16   size  4   align  4

struct well_ordered    sizeof = 16   align 8
  value  offset  0   size  8   align  8
  id     offset  8   size  4   align  4
  tag    offset 12   size  1   align  1

field bytes actually used: 13
padding in badly_ordered : 11
padding in well_ordered  : 3&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;ab-padding&quot;&gt;Alignment and padding&lt;/h3&gt;
&lt;p&gt;
  Two rules produce every number in that output.
&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;Each field starts at a multiple of its own alignment.&lt;/strong&gt; A &lt;code&gt;double&lt;/code&gt; has
  alignment 8, so it may only begin at byte 0, 8, 16 and so on. In &lt;code&gt;badly_ordered&lt;/code&gt;,
  &lt;code&gt;tag&lt;/code&gt; occupies byte 0, and &lt;code&gt;value&lt;/code&gt; cannot start at byte 1 — the compiler skips
  to byte 8 and leaves seven bytes of nothing behind.
&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;The struct&#39;s own size is rounded up to its largest field alignment.&lt;/strong&gt; That is what
  makes arrays work: if &lt;code&gt;sizeof&lt;/code&gt; were not a multiple of 8, the second element of an array
  would put &lt;code&gt;value&lt;/code&gt; on a misaligned address. In &lt;code&gt;badly_ordered&lt;/code&gt;,
  &lt;code&gt;id&lt;/code&gt; ends at byte 20 and the size rounds up to 24.
&lt;/p&gt;
&lt;p&gt;
  The two structs contain identical data — a double, an int and a char, 13 bytes of payload — and one
  is 50% larger than the other. Sorting fields from widest to narrowest, as &lt;code&gt;well_ordered&lt;/code&gt;
  does, is a reliable way to get most of that back.
&lt;/p&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Note&lt;/span&gt;
  &lt;p&gt;
    Padding bytes have no defined value. This is why &lt;code&gt;memcmp&lt;/code&gt; on two structs can report a
    difference when every field is equal, and why writing a struct straight to a file can leak
    whatever happened to be on the stack.
  &lt;/p&gt;
&lt;/div&gt;

&lt;h3 id=&quot;ab-reorder&quot;&gt;Reordering is an ABI change with no API change&lt;/h3&gt;
&lt;p&gt;
  Now put the two structs next to each other again and ask what a &lt;em&gt;caller&lt;/em&gt; sees. Both have the
  same three fields with the same names and the same types. Any code that says
  &lt;code&gt;c.value = 1.5&lt;/code&gt; compiles unchanged against either one. The API is identical.
&lt;/p&gt;
&lt;p&gt;
  The bytes are not. Field &lt;code&gt;value&lt;/code&gt; lives at offset 8 in one and offset 0 in the other. A
  library compiled against the first and a caller compiled against the second will agree on every
  name and disagree on every address — and no tool in the build will say a word, because each half is
  internally consistent.
&lt;/p&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Trap&lt;/span&gt;
  &lt;p&gt;
    &lt;code&gt;sizeof&lt;/code&gt; matching is not evidence that two layouts agree. Two different orderings can
    easily produce the same total size — you will see exactly that in
    &lt;a href=&quot;#ab-wrong&quot;&gt;part 4&lt;/a&gt;, where a reordered struct is 16 bytes on both sides and still reads
    the wrong bytes.
  &lt;/p&gt;
&lt;/div&gt;

&lt;!-- ==================== PART 3 ==================== --&gt;
&lt;h2&gt;Part 3 · Symbols and registers&lt;/h2&gt;

&lt;h3 id=&quot;ab-mangling&quot;&gt;Name mangling&lt;/h3&gt;
&lt;p&gt;
  A linker does not match calls to functions by reading your source. It matches strings. What string a
  function gets is part of the ABI, and C and C++ answer that question very differently.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;mangling.cpp&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;int add(int a, int b) { return a + b; }

double add(double a, double b) { return a + b; }

namespace geometry {
int add(int a, int b) { return a + b; }
}  // namespace geometry

extern &quot;C&quot; int add_c(int a, int b) { return a + b; }&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;g++ -c mangling.cpp -o mangling.o &amp;amp;&amp;amp; nm mangling.o&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;0000000000000018 T _Z3adddd
0000000000000000 T _Z3addii
0000000000000040 T _ZN8geometry3addEii
0000000000000058 T add_c&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Three functions are all called &lt;code&gt;add&lt;/code&gt; in the source and none of them is called
  &lt;code&gt;add&lt;/code&gt; in the object file. C++ encodes the namespace and the parameter types into the
  symbol — that encoding is what makes overloading possible, since the linker needs a different string
  for each version. &lt;code&gt;_Z3addii&lt;/code&gt; is &lt;code&gt;add&lt;/code&gt; taking two &lt;code&gt;int&lt;/code&gt;s;
  &lt;code&gt;_Z3adddd&lt;/code&gt; is the &lt;code&gt;double&lt;/code&gt; one.
&lt;/p&gt;
&lt;p&gt;
  &lt;code&gt;nm -C&lt;/code&gt; undoes it, as does piping any symbol through &lt;code&gt;c++filt&lt;/code&gt;:
&lt;/p&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;nm -C mangling.o&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;0000000000000018 T add(double, double)
0000000000000000 T add(int, int)
0000000000000040 T geometry::add(int, int)
0000000000000058 T add_c&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;ab-externc&quot;&gt;What &lt;code&gt;extern &quot;C&quot;&lt;/code&gt; is for&lt;/h3&gt;
&lt;p&gt;
  The fourth symbol is the odd one out: &lt;code&gt;add_c&lt;/code&gt;, spelled exactly as written. That is the
  entire effect of &lt;code&gt;extern &quot;C&quot;&lt;/code&gt; — it tells a C++ compiler to use the C naming rule (the
  plain name) and the C calling rule for this function, so that anything outside C++ can find it.
&lt;/p&gt;
&lt;p&gt;
  It is not a performance hint and it does not change the function body. It is a promise about the
  string in the symbol table, which is why every library meant to be called from another language has
  a wall of it around its public header. And it is why C++ features that need mangling — overloads,
  templates, namespaces — cannot appear on such a boundary: there is only one &lt;code&gt;add_c&lt;/code&gt;
  available, so there can only be one function of that name.
&lt;/p&gt;
&lt;p&gt;
  Look at the exported symbols of a C library and you get the flat list you would expect:
&lt;/p&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;nm -D --defined-only libconfig.so&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;0000000000001119 T config_area
0000000000001174 T config_describe
00000000000011de T config_offset_scale
0000000000001137 T config_scaled_area
00000000000011cf T config_sizeof&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  That list, plus the layout of &lt;code&gt;struct config&lt;/code&gt;, is the library&#39;s entire ABI surface. The
  &lt;code&gt;T&lt;/code&gt; means the symbol is defined here and visible to others; &lt;code&gt;U&lt;/code&gt; would mean
  undefined and needed from somewhere else.
&lt;/p&gt;

&lt;h3 id=&quot;ab-calling&quot;&gt;The calling convention&lt;/h3&gt;
&lt;p&gt;
  The last piece is where arguments physically go. Three tiny functions and a disassembler answer it
  directly.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;callconv.c&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;int sum4(int a, int b, int c, int d) { return a + b + c + d; }

double product2(double x, double y) { return x * y; }

int mixed(int a, double x, int b) { return a + b + (int)x; }&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;gcc -O1 -c callconv.c &amp;amp;&amp;amp; objdump -d --no-show-raw-insn callconv.o&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;0000000000000000 &amp;lt;sum4&amp;gt;:
   0:	endbr64
   4:	add    %esi,%edi
   6:	add    %edx,%edi
   8:	lea    (%rdi,%rcx,1),%eax
   b:	ret

000000000000000c &amp;lt;product2&amp;gt;:
   c:	endbr64
  10:	mulsd  %xmm1,%xmm0
  14:	ret

0000000000000015 &amp;lt;mixed&amp;gt;:
  15:	endbr64
  19:	add    %esi,%edi
  1b:	cvttsd2si %xmm0,%eax
  1f:	add    %edi,%eax
  21:	ret&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  There is no prologue, no stack, no memory traffic at all. In &lt;code&gt;sum4&lt;/code&gt; the four arguments
  are already sitting in &lt;code&gt;edi&lt;/code&gt;, &lt;code&gt;esi&lt;/code&gt;, &lt;code&gt;edx&lt;/code&gt; and &lt;code&gt;ecx&lt;/code&gt;
  when the function begins, and the result is left in &lt;code&gt;eax&lt;/code&gt;. That order is not something
  gcc invented; it is written down in the ABI, and every compiler targeting this platform obeys it.
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Kind&lt;/th&gt;&lt;th&gt;Arguments 1–6&lt;/th&gt;&lt;th&gt;Beyond that&lt;/th&gt;&lt;th&gt;Return&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Integers and pointers&lt;/td&gt;
      &lt;td&gt;&lt;code&gt;rdi rsi rdx rcx r8 r9&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;pushed on the stack&lt;/td&gt;
      &lt;td&gt;&lt;code&gt;rax&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Floats and doubles&lt;/td&gt;
      &lt;td&gt;&lt;code&gt;xmm0&lt;/code&gt; … &lt;code&gt;xmm7&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;pushed on the stack&lt;/td&gt;
      &lt;td&gt;&lt;code&gt;xmm0&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;
  &lt;code&gt;product2&lt;/code&gt; confirms the second row: &lt;code&gt;mulsd %xmm1,%xmm0&lt;/code&gt; multiplies the two
  arguments in place and the result is already in the return register.
&lt;/p&gt;

&lt;h3 id=&quot;ab-queues&quot;&gt;The detail that surprises people&lt;/h3&gt;
&lt;p&gt;
  Look again at &lt;code&gt;mixed(int a, double x, int b)&lt;/code&gt;. The instruction is
  &lt;code&gt;add %esi,%edi&lt;/code&gt; — so &lt;code&gt;a&lt;/code&gt; is in &lt;code&gt;edi&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; is in
  &lt;strong&gt;&lt;code&gt;esi&lt;/code&gt;&lt;/strong&gt;, even though &lt;code&gt;b&lt;/code&gt; is the &lt;em&gt;third&lt;/em&gt; parameter.
&lt;/p&gt;
&lt;p&gt;
  The two register sequences are counted independently. Integers take &lt;code&gt;rdi&lt;/code&gt;,
  &lt;code&gt;rsi&lt;/code&gt;, … in order among themselves; floats take &lt;code&gt;xmm0&lt;/code&gt;, &lt;code&gt;xmm1&lt;/code&gt;, …
  in order among themselves. The &lt;code&gt;double&lt;/code&gt; in the middle consumes &lt;code&gt;xmm0&lt;/code&gt; and does
  not consume an integer slot, so &lt;code&gt;b&lt;/code&gt; gets the next integer register rather than the third
  one.
&lt;/p&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Why you care&lt;/span&gt;
  &lt;p&gt;
    Because it means you cannot work out where an argument goes by counting parameters. Any hand-written
    declaration that gets a parameter&#39;s &lt;em&gt;type&lt;/em&gt; wrong — say, declaring a &lt;code&gt;double&lt;/code&gt;
    parameter as &lt;code&gt;int&lt;/code&gt; in an FFI binding — does not merely mistranslate that one value. It
    shifts every argument after it into the wrong register.
  &lt;/p&gt;
&lt;/div&gt;

&lt;!-- ==================== PART 4 ==================== --&gt;
&lt;h2&gt;Part 4 · Crossing over from Python&lt;/h2&gt;

&lt;h3 id=&quot;ab-python&quot;&gt;The library&lt;/h3&gt;
&lt;p&gt;
  Everything so far has been observation. This part is where a mismatch actually costs you, and the
  most convenient way to build one is a C library and a Python client, because Python has no access
  to the header and has to be told the layout by hand.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;libconfig.c&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;struct config {
    int    width;
    int    height;
    double scale;
};

int config_area(const struct config *c) {
    return c-&amp;gt;width * c-&amp;gt;height;
}

const char *config_describe(const struct config *c) {
    static char buf[64];
    snprintf(buf, sizeof buf, &quot;%dx%d @ %.2fx&quot;, c-&amp;gt;width, c-&amp;gt;height, c-&amp;gt;scale);
    return buf;
}

/* Self-description, so a caller can verify its mirror instead of trusting it. */
size_t config_sizeof(void) { return sizeof(struct config); }
size_t config_offset_scale(void) { return offsetof(struct config, scale); }&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Those last two functions are worth a moment. They export nothing useful to a program — but they let
  a caller &lt;em&gt;check&lt;/em&gt; its assumptions instead of hoping. A library that describes its own layout
  turns a silent class of bug into an assertion, for the price of two lines.
&lt;/p&gt;

&lt;h3 id=&quot;ab-mirror&quot;&gt;A mirror that matches&lt;/h3&gt;
&lt;p&gt;
  On the Python side, &lt;code&gt;ctypes&lt;/code&gt; needs the layout restated. This declaration is a hand-copy of
  the C struct, and the whole exercise depends on it being right.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;client.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;class Config(ctypes.Structure):
    _fields_ = [
        (&quot;width&quot;, ctypes.c_int),
        (&quot;height&quot;, ctypes.c_int),
        (&quot;scale&quot;, ctypes.c_double),
    ]

lib.config_area.argtypes = [ctypes.POINTER(Config)]
lib.config_area.restype = ctypes.c_int

assert ctypes.sizeof(Config) == lib.config_sizeof()
assert Config.scale.offset == lib.config_offset_scale()&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;python3 client.py&lt;/b&gt; — part 1&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;== 1. matching mirror ==
sizeof        : python 16 | c 16
offset(scale) : python 8 | c 8
area          : 2073600
describe      : 1920x1080 @ 1.50x&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Python computed offset 8 for &lt;code&gt;scale&lt;/code&gt; by applying the same alignment rules the C compiler
  applied, independently, from the field types alone. That is not a coincidence — &lt;code&gt;ctypes&lt;/code&gt;
  implements the platform ABI. It is also the reason the next section works the way it does.
&lt;/p&gt;

&lt;h3 id=&quot;ab-wrong&quot;&gt;A mirror that doesn&#39;t&lt;/h3&gt;
&lt;p&gt;
  Now the realistic accident: somebody writes the same three fields in a different order. Perhaps they
  copied from documentation that listed them alphabetically. Every name is right, every type is right.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;client.py&lt;/b&gt; — the same fields, reordered&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;class ConfigWrong(ctypes.Structure):
    _fields_ = [
        (&quot;scale&quot;, ctypes.c_double),
        (&quot;width&quot;, ctypes.c_int),
        (&quot;height&quot;, ctypes.c_int),
    ]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;python3 client.py&lt;/b&gt; — part 2&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;== 2. reordered mirror ==
sizeof        : python 16 | c 16 -&gt; agrees, and proves nothing
offset(scale) : python 0 | c 8 -&gt; the actual disagreement
area          : 0
describe      : 0x1073217536 @ 0.00x
no exception, no warning, no crash&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  A 1920×1080 image now has an area of zero, and a height of 1073217536. Those numbers are not random:
  C read &lt;code&gt;width&lt;/code&gt; from bytes 0–3, which in this layout hold the bottom half of the double
  &lt;code&gt;1.5&lt;/code&gt;, and that half is all zeros. It read &lt;code&gt;height&lt;/code&gt; from bytes 4–7, the top
  half of the same double, which is &lt;code&gt;0x3FF80000&lt;/code&gt; — the number printed.
&lt;/p&gt;
&lt;p&gt;
  Three things about that output deserve to be uncomfortable. There is no exception. There is no
  warning. And &lt;code&gt;sizeof&lt;/code&gt; agrees perfectly on both sides, because reordering these particular
  fields happens to produce the same total. A size check would have passed this straight through; only
  the offset check catches it.
&lt;/p&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Trap&lt;/span&gt;
  &lt;p&gt;
    &lt;code&gt;ctypes&lt;/code&gt; type-checks the Python side thoroughly and the C side not at all. It will
    refuse a &lt;code&gt;ConfigWrong&lt;/code&gt; where you declared &lt;code&gt;POINTER(Config)&lt;/code&gt; — but it has no
    way to know what the library thinks either of them looks like. Every guarantee stops at the
    boundary.
  &lt;/p&gt;
&lt;/div&gt;

&lt;h3 id=&quot;ab-restype&quot;&gt;The &lt;code&gt;restype&lt;/code&gt; trap&lt;/h3&gt;
&lt;p&gt;
  The other everyday mistake is forgetting to declare what comes back. &lt;code&gt;ctypes&lt;/code&gt; assumes a
  C &lt;code&gt;int&lt;/code&gt; unless told otherwise, and part 3 of the calling convention says an
  &lt;code&gt;int&lt;/code&gt; comes back in &lt;code&gt;rax&lt;/code&gt; while a &lt;code&gt;double&lt;/code&gt; comes back in
  &lt;code&gt;xmm0&lt;/code&gt;. Two different registers.
&lt;/p&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;python3 client.py&lt;/b&gt; — part 3&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;== 3. missing restype ==
default (int) : 0
c_double      : 3110400.0
expected      : 3110400.0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The first call reads an integer register that the function never wrote to. It printed &lt;code&gt;0&lt;/code&gt;
  here and it will print whatever is left over there on your machine; the point is only that it has
  nothing to do with the answer.
&lt;/p&gt;
&lt;p&gt;
  The same failure with a pointer return is worse. Left as the default &lt;code&gt;int&lt;/code&gt;, a returned
  pointer is truncated to its low 32 bits, and dereferencing the result is a segmentation fault that
  appears to come from inside the C library. Setting &lt;code&gt;argtypes&lt;/code&gt; and &lt;code&gt;restype&lt;/code&gt; on
  every function you import is not ceremony — it is the only place the ABI gets written down on the
  Python side.
&lt;/p&gt;

&lt;div class=&quot;takeaway&quot;&gt;
  &lt;h4&gt;What the Python examples actually demonstrate&lt;/h4&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;strong&gt;An FFI binding is a hand-copy of an ABI.&lt;/strong&gt; Nothing checks it against the library, so it drifts the moment the library changes.&lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;A matching &lt;code&gt;sizeof&lt;/code&gt; proves very little.&lt;/strong&gt; Compare offsets, field by field, or compare nothing.&lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;Have the library describe itself.&lt;/strong&gt; Two exported functions turned an invisible failure into an &lt;code&gt;assert&lt;/code&gt; that fires on line one.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;

&lt;!-- ==================== PART 5 ==================== --&gt;
&lt;h2&gt;Part 5 · Keeping an ABI stable&lt;/h2&gt;

&lt;h3 id=&quot;ab-stability&quot;&gt;What breaks which&lt;/h3&gt;
&lt;p&gt;
  Once other people ship binaries built against your library, every change falls into one of these
  boxes. The dangerous column is the one where the API survives and the ABI does not, because that is
  the change nobody notices.
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;&lt;th&gt;Change to a public struct or function&lt;/th&gt;&lt;th&gt;API&lt;/th&gt;&lt;th&gt;ABI&lt;/th&gt;&lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;Add a function&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;ok&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;ok&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Change a function body&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;ok&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;ok&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Rename a parameter in the header&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;ok&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;ok&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Reorder struct fields&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;ok&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;broken&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Insert a field in the middle&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;ok&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;broken&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Widen a field, &lt;code&gt;int&lt;/code&gt; → &lt;code&gt;long&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;ok&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;broken&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Add a field at the end&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;ok&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;broken if callers allocate it&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Change a parameter&#39;s type&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;broken&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;broken&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Remove or rename a function&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;broken&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;broken&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Change a &lt;code&gt;#define&lt;/code&gt; constant&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;behaviour changes&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;ok&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;
  &quot;Add a field at the end&quot; is the interesting one. If callers only ever receive a pointer your library
  allocated, growing the struct is harmless — they never compute its size. If callers declare one on
  their own stack, they will allocate the old, smaller size, and your library will write past the end
  of it.
&lt;/p&gt;

&lt;h3 id=&quot;ab-techniques&quot;&gt;How libraries stay compatible&lt;/h3&gt;

&lt;h4&gt;Hide the struct entirely&lt;/h4&gt;
&lt;p&gt;
  The strongest option: callers never see the fields, only a pointer to something they cannot inspect.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;opaque handle&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;/* in the public header */
typedef struct config config_t;        /* declared, never defined */

config_t *config_create(void);
void      config_set_scale(config_t *c, double scale);
int       config_area(const config_t *c);
void      config_destroy(config_t *c);&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The layout is now a private implementation detail — it can change in any release, because no caller
  ever computed an offset into it. The cost is a function call per field and an allocator round trip.
  This is how most C libraries with long support windows do it.
&lt;/p&gt;

&lt;h4&gt;Put the size in the struct&lt;/h4&gt;
&lt;p&gt;
  When callers must allocate, have them declare how big their version is, and check.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;versioned struct&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;struct config {
    size_t struct_size;    /* caller sets this to sizeof(struct config) */
    int    width;
    int    height;
    double scale;
    /* new fields may only be appended below */
};

int config_area(const struct config *c) {
    if (c-&amp;gt;struct_size &amp;lt; offsetof(struct config, scale)) return -1;
    ...
}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The library can now tell an old caller from a new one at runtime and read only the fields that
  caller actually has. The rule is absolute, though: fields may only ever be appended, and existing
  ones may never move or change width.
&lt;/p&gt;

&lt;h4&gt;Reserve space up front&lt;/h4&gt;
&lt;p&gt;
  A cruder version of the same idea — &lt;code&gt;char reserved[32];&lt;/code&gt; at the end of the struct, spent
  later on new fields without changing the size. It works, it is ugly, and it is everywhere.
&lt;/p&gt;

&lt;h4&gt;Version the symbol, not the struct&lt;/h4&gt;
&lt;p&gt;
  When a function genuinely has to change shape, keep the old one and add a new name:
  &lt;code&gt;config_area&lt;/code&gt; stays, &lt;code&gt;config_area2&lt;/code&gt; appears. Old binaries keep finding the old
  symbol. The C standard library has done this for decades, which is why symbols with version suffixes
  turn up in &lt;code&gt;nm&lt;/code&gt; output on any mature library.
&lt;/p&gt;

&lt;h3 id=&quot;ab-soname&quot;&gt;soname, and how the loader picks a file&lt;/h3&gt;
&lt;p&gt;
  Shared libraries carry a name inside them, and it is that name — not the filename — that gets
  recorded in every program linked against them.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;building with a soname&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;gcc -shared -fPIC -Wl,-soname,libconfig.so.1 -o libconfig.so.1.0.0 libconfig.c
readelf -d libconfig.so.1.0.0 | head -6&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;readelf -d libconfig.so.1.0.0&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;Dynamic section at offset 0x2e10 contains 25 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000000e (SONAME)             Library soname: [libconfig.so.1]
 0x000000000000000c (INIT)               0x1000&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The convention that falls out of this is the familiar three-level filename. The file is
  &lt;code&gt;libconfig.so.1.0.0&lt;/code&gt;; the soname is &lt;code&gt;libconfig.so.1&lt;/code&gt;, and that is what programs
  record; the bare &lt;code&gt;libconfig.so&lt;/code&gt; is a symlink that only the linker uses at build time.
&lt;/p&gt;
&lt;p&gt;
  The middle number is the promise. Bump the patch level for a bug fix, bump the minor for added
  functions, and bump the &lt;strong&gt;soname&lt;/strong&gt; to &lt;code&gt;.so.2&lt;/code&gt; when the ABI breaks. Because
  the soname is part of the filename, version 1 and version 2 can sit in the same directory and old
  programs keep loading the one they were built against. That is the whole mechanism by which a Linux
  system runs binaries compiled years apart.
&lt;/p&gt;

&lt;!-- ==================== PART 6 ==================== --&gt;
&lt;h2&gt;Part 6 · Reference&lt;/h2&gt;

&lt;h3 id=&quot;ab-tools&quot;&gt;Tools worth knowing&lt;/h3&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;nm -D --defined-only lib.so&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Exported symbols — the callable ABI surface&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;nm -C&lt;/code&gt;, &lt;code&gt;c++filt&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Demangle C++ symbol names&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;readelf -d lib.so&lt;/code&gt;&lt;/td&gt;&lt;td&gt;soname and the list of libraries it needs&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;readelf -Ws lib.so&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Full symbol table with sizes and visibility&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;objdump -d --no-show-raw-insn f.o&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Disassembly — see the calling convention directly&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;ldd ./program&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Which libraries actually get loaded, and from where&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;gcc -fdump-lang-raw&lt;/code&gt;, &lt;code&gt;pahole&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Struct layout and padding, reported by the toolchain&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;offsetof&lt;/code&gt;, &lt;code&gt;_Alignof&lt;/code&gt;, &lt;code&gt;_Static_assert&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Assert the layout from inside the program itself&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3 id=&quot;ab-cheatsheet&quot;&gt;Cheat sheet&lt;/h3&gt;

&lt;h4&gt;The distinction&lt;/h4&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;API&lt;/td&gt;&lt;td&gt;Source-level contract. Broken → compiler error, with a line number.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;ABI&lt;/td&gt;&lt;td&gt;Binary-level contract. Broken → wrong answers, usually with no message at all.&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;x86-64 System V, in four lines&lt;/h4&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;Integer / pointer arguments&lt;/td&gt;&lt;td&gt;&lt;code&gt;rdi rsi rdx rcx r8 r9&lt;/code&gt;, then the stack&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Float / double arguments&lt;/td&gt;&lt;td&gt;&lt;code&gt;xmm0&lt;/code&gt;–&lt;code&gt;xmm7&lt;/code&gt;, counted separately&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Return value&lt;/td&gt;&lt;td&gt;&lt;code&gt;rax&lt;/code&gt;, or &lt;code&gt;xmm0&lt;/code&gt; for floating point&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Struct field offsets&lt;/td&gt;&lt;td&gt;Each field aligned to its own width; total rounded up to the largest&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;Writing an FFI binding&lt;/h4&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;Set &lt;code&gt;argtypes&lt;/code&gt; and &lt;code&gt;restype&lt;/code&gt;&lt;/td&gt;&lt;td&gt;On every single function. The defaults are wrong for pointers and doubles.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Assert &lt;code&gt;sizeof&lt;/code&gt; &lt;em&gt;and&lt;/em&gt; offsets&lt;/td&gt;&lt;td&gt;Sizes can match while layouts differ.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Export a self-description&lt;/td&gt;&lt;td&gt;Two functions returning &lt;code&gt;sizeof&lt;/code&gt; and an &lt;code&gt;offsetof&lt;/code&gt; pay for themselves.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Prefer opaque pointers&lt;/td&gt;&lt;td&gt;A layout nobody can see is a layout nobody can get wrong.&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;Wrapping up&lt;/h2&gt;

&lt;h3 id=&quot;ab-closing&quot;&gt;What to take away&lt;/h3&gt;
&lt;p&gt;
  The mnemonic in the first table is worth keeping — &lt;em&gt;Programming&lt;/em&gt; versus &lt;em&gt;Binary&lt;/em&gt;, one
  contract for people writing code and one for code that has already been written. But the reason to
  care is narrower than that.
&lt;/p&gt;

&lt;div class=&quot;takeaway&quot;&gt;
  &lt;h4&gt;The short list&lt;/h4&gt;
  &lt;ul&gt;
    &lt;li&gt;
      &lt;strong&gt;An API break is loud; an ABI break is silent.&lt;/strong&gt; The compiler is on your side for
      one of them and completely absent for the other.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Field order is part of your public interface.&lt;/strong&gt; It does not look like it in the
      header, and swapping two lines is a breaking change.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Every hand-written binding is a copy of a layout, so make it checkable.&lt;/strong&gt; Export
      &lt;code&gt;sizeof&lt;/code&gt; and a couple of offsets, assert them at import time, and the entire category
      of bug in part 4 turns into a failed assertion.
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;
  The stability techniques in part 5 only matter once someone else ships a binary against your code.
  Until then the ABI is a private matter and you can rearrange whatever you like. The day that stops
  being true is the day the opaque pointer starts looking cheap.
&lt;/p&gt;

&lt;h3 id=&quot;ab-further&quot;&gt;Further reading&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://gitlab.com/x86-psABIs/x86-64-ABI&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;The x86-64 psABI&lt;/a&gt; — the actual specification; chapter 3 is the calling convention and the struct classification rules&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.python.org/3/library/ctypes.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;ctypes&lt;/a&gt; — the standard-library FFI used throughout part 4&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Program Library HOWTO&lt;/a&gt; — sonames, versioning and the symlink convention&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://akkadia.org/drepper/dsohowto.pdf&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;How to Write Shared Libraries&lt;/a&gt; — Ulrich Drepper; dense, and still the best single document on symbol visibility and versioning&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.cppreference.com/w/cpp/language/language_linkage&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Language linkage&lt;/a&gt; — what &lt;code&gt;extern &quot;C&quot;&lt;/code&gt; is defined to do&lt;/li&gt;
&lt;/ul&gt;

&lt;!-- ==================== APPENDIX ==================== --&gt;
&lt;h2&gt;Appendix · The complete programs&lt;/h2&gt;

&lt;h3 id=&quot;ab-files&quot;&gt;Building and running&lt;/h3&gt;
&lt;p&gt;
  Five short files produced every output on this page. They are reproduced in full below, so copying
  the snippets into one directory is enough to reproduce all of it.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;build and run everything&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;gcc -std=c11 -Wall -Wextra -o layout layout.c &amp;amp;&amp;amp; ./layout

gcc -std=c11 -Wall -Wextra -shared -fPIC -o libconfig.so libconfig.c
python3 client.py

g++ -c mangling.cpp -o mangling.o &amp;amp;&amp;amp; nm mangling.o &amp;amp;&amp;amp; nm -C mangling.o

gcc -O1 -c callconv.c -o callconv.o
objdump -d --no-show-raw-insn callconv.o

gcc -shared -fPIC -Wl,-soname,libconfig.so.1 -o libconfig.so.1.0.0 libconfig.c
readelf -d libconfig.so.1.0.0 | head -6&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Verified on gcc 11.4.0 and GNU binutils 2.38 (Ubuntu 22.04, x86-64) with CPython 3.10.12. The one
  value that is not reproducible is the integer read in part 3 of &lt;code&gt;client.py&lt;/code&gt;, which is
  whatever the return register happened to contain.
&lt;/p&gt;

&lt;h3 id=&quot;ab-src-layout&quot;&gt;layout.c &lt;span class=&quot;badge&quot;&gt;43 lines&lt;/span&gt;&lt;/h3&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;layout.c&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;#include &amp;lt;stddef.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;

/* Same three fields, same API, two different binary layouts. */

struct badly_ordered {
    char   tag;
    double value;
    int    id;
};

struct well_ordered {
    double value;
    int    id;
    char   tag;
};

#define SHOW(S, M)                                                       \
    printf(&quot;  %-6s offset %2zu   size %2zu   align %2zu\n&quot;, #M,          \
           offsetof(S, M), sizeof(((S *)0)-&amp;gt;M), _Alignof(((S *)0)-&amp;gt;M))

int main(void) {
    size_t payload = sizeof(double) + sizeof(int) + sizeof(char);

    printf(&quot;struct badly_ordered   sizeof = %2zu   align %zu\n&quot;,
           sizeof(struct badly_ordered), _Alignof(struct badly_ordered));
    SHOW(struct badly_ordered, tag);
    SHOW(struct badly_ordered, value);
    SHOW(struct badly_ordered, id);

    printf(&quot;\nstruct well_ordered    sizeof = %2zu   align %zu\n&quot;,
           sizeof(struct well_ordered), _Alignof(struct well_ordered));
    SHOW(struct well_ordered, value);
    SHOW(struct well_ordered, id);
    SHOW(struct well_ordered, tag);

    printf(&quot;\nfield bytes actually used: %zu\n&quot;, payload);
    printf(&quot;padding in badly_ordered : %zu\n&quot;,
           sizeof(struct badly_ordered) - payload);
    printf(&quot;padding in well_ordered  : %zu\n&quot;,
           sizeof(struct well_ordered) - payload);
    return 0;
}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;ab-src-callconv&quot;&gt;callconv.c &lt;span class=&quot;badge&quot;&gt;9 lines&lt;/span&gt;&lt;/h3&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;callconv.c&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;/* Where do arguments actually go? Build and look:
     gcc -O1 -c callconv.c -o callconv.o
     objdump -d --no-show-raw-insn callconv.o */

int sum4(int a, int b, int c, int d) { return a + b + c + d; }

double product2(double x, double y) { return x * y; }

int mixed(int a, double x, int b) { return a + b + (int)x; }&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;ab-src-mangling&quot;&gt;mangling.cpp &lt;span class=&quot;badge&quot;&gt;12 lines&lt;/span&gt;&lt;/h3&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;mangling.cpp&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;/* What a linker actually sees. Build with:
     g++ -c mangling.cpp -o mangling.o &amp;amp;&amp;amp; nm mangling.o */

int add(int a, int b) { return a + b; }

double add(double a, double b) { return a + b; }

namespace geometry {
int add(int a, int b) { return a + b; }
}  // namespace geometry

extern &quot;C&quot; int add_c(int a, int b) { return a + b; }&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;ab-src-libconfig&quot;&gt;libconfig.c &lt;span class=&quot;badge&quot;&gt;29 lines&lt;/span&gt;&lt;/h3&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;libconfig.c&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;#include &amp;lt;stddef.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;

/* Everything a caller in another language has to agree with lives here:
   the layout of struct config, and the exported symbols below. */

struct config {
    int    width;
    int    height;
    double scale;
};

int config_area(const struct config *c) {
    return c-&amp;gt;width * c-&amp;gt;height;
}

double config_scaled_area(const struct config *c) {
    return c-&amp;gt;width * c-&amp;gt;height * c-&amp;gt;scale;
}

const char *config_describe(const struct config *c) {
    static char buf[64];
    snprintf(buf, sizeof buf, &quot;%dx%d @ %.2fx&quot;, c-&amp;gt;width, c-&amp;gt;height, c-&amp;gt;scale);
    return buf;
}

/* Self-description, so a caller can verify its mirror instead of trusting it. */
size_t config_sizeof(void) { return sizeof(struct config); }
size_t config_offset_scale(void) { return offsetof(struct config, scale); }&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;ab-src-client&quot;&gt;client.py &lt;span class=&quot;badge&quot;&gt;76 lines&lt;/span&gt;&lt;/h3&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;client.py&lt;/b&gt;&lt;/span&gt;&lt;button type=&quot;button&quot; class=&quot;copy&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;&quot;&quot;&quot;Three ways to talk to libconfig.so: one right, two wrong.&quot;&quot;&quot;

import ctypes

lib = ctypes.CDLL(&quot;./libconfig.so&quot;)
lib.config_sizeof.restype = ctypes.c_size_t
lib.config_offset_scale.restype = ctypes.c_size_t

# ---- 1. a mirror that matches the C struct -------------------------------

class Config(ctypes.Structure):
    _fields_ = [
        (&quot;width&quot;, ctypes.c_int),
        (&quot;height&quot;, ctypes.c_int),
        (&quot;scale&quot;, ctypes.c_double),
    ]

lib.config_area.argtypes = [ctypes.POINTER(Config)]
lib.config_area.restype = ctypes.c_int
lib.config_describe.argtypes = [ctypes.POINTER(Config)]
lib.config_describe.restype = ctypes.c_char_p

print(&quot;== 1. matching mirror ==&quot;)
print(&quot;sizeof        : python&quot;, ctypes.sizeof(Config), &quot;| c&quot;, lib.config_sizeof())
print(&quot;offset(scale) : python&quot;, Config.scale.offset, &quot;| c&quot;, lib.config_offset_scale())
assert ctypes.sizeof(Config) == lib.config_sizeof()
assert Config.scale.offset == lib.config_offset_scale()

cfg = Config(width=1920, height=1080, scale=1.5)
print(&quot;area          :&quot;, lib.config_area(ctypes.byref(cfg)))
print(&quot;describe      :&quot;, lib.config_describe(ctypes.byref(cfg)).decode())

# ---- 2. the same fields, declared in a different order -------------------
# A second handle, as if a different program had written its own mirror.

class ConfigWrong(ctypes.Structure):
    _fields_ = [
        (&quot;scale&quot;, ctypes.c_double),
        (&quot;width&quot;, ctypes.c_int),
        (&quot;height&quot;, ctypes.c_int),
    ]

other = ctypes.CDLL(&quot;./libconfig.so&quot;)
other.config_area.argtypes = [ctypes.POINTER(ConfigWrong)]
other.config_area.restype = ctypes.c_int
other.config_describe.argtypes = [ctypes.POINTER(ConfigWrong)]
other.config_describe.restype = ctypes.c_char_p
other.config_offset_scale.restype = ctypes.c_size_t

print(&quot;\n== 2. reordered mirror ==&quot;)
print(&quot;sizeof        : python&quot;, ctypes.sizeof(ConfigWrong), &quot;| c&quot;, lib.config_sizeof(),
      &quot;-&amp;gt; agrees, and proves nothing&quot;)
print(&quot;offset(scale) : python&quot;, ConfigWrong.scale.offset, &quot;| c&quot;,
      other.config_offset_scale(), &quot;-&amp;gt; the actual disagreement&quot;)

bad = ConfigWrong(scale=1.5, width=1920, height=1080)
print(&quot;area          :&quot;, other.config_area(ctypes.byref(bad)))
print(&quot;describe      :&quot;, other.config_describe(ctypes.byref(bad)).decode())
print(&quot;no exception, no warning, no crash&quot;)

# ---- 3. a function called without declaring its return type --------------

print(&quot;\n== 3. missing restype ==&quot;)
lib.config_scaled_area.argtypes = [ctypes.POINTER(Config)]
print(&quot;default (int) :&quot;, lib.config_scaled_area(ctypes.byref(cfg)))

lib.config_scaled_area.restype = ctypes.c_double
print(&quot;c_double      :&quot;, lib.config_scaled_area(ctypes.byref(cfg)))
print(&quot;expected      :&quot;, 1920 * 1080 * 1.5)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;script&gt;
(function () {
  var root = document.getElementById(&#39;ab-guide&#39;);
  if (!root || root.dataset.abInit) return;
  root.dataset.abInit = &#39;1&#39;;

  var C_KW = (&quot;auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|&quot;
            + &quot;goto|if|inline|int|long|register|restrict|return|short|signed|sizeof|static|struct|&quot;
            + &quot;switch|typedef|union|unsigned|void|volatile|while|_Bool|_Generic|_Static_assert|&quot;
            + &quot;size_t|NULL&quot;).split(&quot;|&quot;);

  var PY_KW = (&quot;False|None|True|and|as|assert|async|await|break|class|continue|def|del|elif|&quot;
             + &quot;else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|&quot;
             + &quot;pass|raise|return|try|while|with|yield|self|match|case&quot;).split(&quot;|&quot;);

  var cRe = new RegExp(
      &quot;(/\\*[\\s\\S]*?\\*/|//[^\\n]*)&quot;
    + &quot;|(\&quot;(?:\\\\.|[^\&quot;\\\\\\n])*\&quot;|&#39;(?:\\\\.|[^&#39;\\\\\\n])*&#39;)&quot;
    + &quot;|(^[ \\t]*#[ \\t]*[a-z_]+)&quot;
    + &quot;|\\b(&quot; + C_KW.join(&quot;|&quot;) + &quot;)\\b&quot;
    + &quot;|\\b(\\d[\\w.]*)\\b&quot;
    + &quot;|\\b([a-zA-Z_]\\w*)(?=\\s*\\()&quot;
    , &quot;gm&quot;);

  var pyRe = new RegExp(
      &quot;(#[^\\n]*)&quot;
    + &quot;|(\&quot;\&quot;\&quot;[\\s\\S]*?\&quot;\&quot;\&quot;|&#39;&#39;&#39;[\\s\\S]*?&#39;&#39;&#39;&quot;
    +   &quot;|\&quot;(?:\\\\.|[^\&quot;\\\\\\n])*\&quot;|&#39;(?:\\\\.|[^&#39;\\\\\\n])*&#39;)&quot;
    + &quot;|(@[\\w.]+)&quot;
    + &quot;|\\b(&quot; + PY_KW.join(&quot;|&quot;) + &quot;)\\b&quot;
    + &quot;|\\b(\\d[\\w.]*)\\b&quot;
    + &quot;|\\b([a-zA-Z_]\\w*)(?=\\()&quot;
    , &quot;g&quot;);

  var shRe = /(#[^\n]*)|(&quot;(?:\\.|[^&quot;\\])*&quot;|&#39;(?:\\.|[^&#39;\\])*&#39;)|(^|\s)(--?[\w-]+)/g;

  function esc(s) {
    return s.replace(/&amp;/g, &quot;&amp;amp;&quot;).replace(/&lt;/g, &quot;&amp;lt;&quot;).replace(/&gt;/g, &quot;&amp;gt;&quot;);
  }

  function highlightC(text) {
    return esc(text).replace(cRe, function (m, com, str, dir, kw, num, fn) {
      if (com) return &#39;&lt;span class=&quot;t-com&quot;&gt;&#39; + com + &quot;&lt;/span&gt;&quot;;
      if (str) return &#39;&lt;span class=&quot;t-str&quot;&gt;&#39; + str + &quot;&lt;/span&gt;&quot;;
      if (dir) return &#39;&lt;span class=&quot;t-dec&quot;&gt;&#39; + dir + &quot;&lt;/span&gt;&quot;;
      if (kw)  return &#39;&lt;span class=&quot;t-kw&quot;&gt;&#39;  + kw  + &quot;&lt;/span&gt;&quot;;
      if (num) return &#39;&lt;span class=&quot;t-num&quot;&gt;&#39; + num + &quot;&lt;/span&gt;&quot;;
      if (fn)  return &#39;&lt;span class=&quot;t-fn&quot;&gt;&#39;  + fn  + &quot;&lt;/span&gt;&quot;;
      return m;
    });
  }

  function highlightPy(text) {
    return esc(text).replace(pyRe, function (m, com, str, dec, kw, num, fn) {
      if (com) return &#39;&lt;span class=&quot;t-com&quot;&gt;&#39; + com + &quot;&lt;/span&gt;&quot;;
      if (str) return &#39;&lt;span class=&quot;t-str&quot;&gt;&#39; + str + &quot;&lt;/span&gt;&quot;;
      if (dec) return &#39;&lt;span class=&quot;t-dec&quot;&gt;&#39; + dec + &quot;&lt;/span&gt;&quot;;
      if (kw)  return &#39;&lt;span class=&quot;t-kw&quot;&gt;&#39;  + kw  + &quot;&lt;/span&gt;&quot;;
      if (num) return &#39;&lt;span class=&quot;t-num&quot;&gt;&#39; + num + &quot;&lt;/span&gt;&quot;;
      if (fn)  return &#39;&lt;span class=&quot;t-fn&quot;&gt;&#39;  + fn  + &quot;&lt;/span&gt;&quot;;
      return m;
    });
  }

  function highlightSh(text) {
    return esc(text).replace(shRe, function (m, com, str, pre, flag) {
      if (com)  return &#39;&lt;span class=&quot;t-com&quot;&gt;&#39; + com + &quot;&lt;/span&gt;&quot;;
      if (str)  return &#39;&lt;span class=&quot;t-str&quot;&gt;&#39; + str + &quot;&lt;/span&gt;&quot;;
      if (flag) return pre + &#39;&lt;span class=&quot;t-dec&quot;&gt;&#39; + flag + &quot;&lt;/span&gt;&quot;;
      return m;
    });
  }

  function highlightOut(text) {
    return esc(text)
      .replace(/^(.*\berror:.*)$/gm, &#39;&lt;span class=&quot;t-fail&quot;&gt;$1&lt;/span&gt;&#39;)
      .replace(/^(.*in expansion of macro.*)$/gm, &#39;&lt;span class=&quot;t-com&quot;&gt;$1&lt;/span&gt;&#39;);
  }

  root.querySelectorAll(&quot;pre code&quot;).forEach(function (el) {
    var raw = el.textContent;
    el.dataset.raw = raw;
    if (el.classList.contains(&quot;out&quot;))     el.innerHTML = highlightOut(raw);
    else if (el.classList.contains(&quot;c&quot;))  el.innerHTML = highlightC(raw);
    else if (el.classList.contains(&quot;py&quot;)) el.innerHTML = highlightPy(raw);
    else                                  el.innerHTML = highlightSh(raw);
  });

  root.querySelectorAll(&quot;.copy&quot;).forEach(function (btn) {
    btn.addEventListener(&quot;click&quot;, function (ev) {
      ev.preventDefault();
      var code = btn.closest(&quot;.snippet&quot;).querySelector(&quot;code&quot;);
      var text = code.dataset.raw || code.textContent;
      var done = function () {
        btn.textContent = &quot;copied&quot;;
        btn.classList.add(&quot;ok&quot;);
        setTimeout(function () { btn.textContent = &quot;copy&quot;; btn.classList.remove(&quot;ok&quot;); }, 1200);
      };
      if (navigator.clipboard &amp;&amp; navigator.clipboard.writeText) {
        navigator.clipboard.writeText(text).then(done, function () {});
      } else {
        var ta = document.createElement(&quot;textarea&quot;);
        ta.value = text; ta.style.position = &quot;fixed&quot;; ta.style.opacity = &quot;0&quot;;
        document.body.appendChild(ta); ta.select();
        try { document.execCommand(&quot;copy&quot;); done(); } catch (e) {}
        document.body.removeChild(ta);
      }
    });
  });
})();
&lt;/script&gt;
</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/5655145355271335454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2026/08/api-and-abi-and-line-between-them.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/5655145355271335454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/5655145355271335454'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2026/08/api-and-abi-and-line-between-them.html' title='API and ABI, and the line between them'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-4011059620180217256</id><published>2026-08-23T00:33:31.770-07:00</published><updated>2026-08-23T01:32:56.594-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="preprocessor"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><category scheme="http://www.blogger.com/atom/ns#" term="tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="X-macro"/><title type='text'>The X-macro, from #define to runtime reflection</title><content type='html'>&lt;style&gt;
/* ------------------------------------------------------------------
   study.marearts.com article body — X-macro guide.
   Every selector is scoped under #xm-guide so nothing leaks onto the
   theme chrome (post title, date header, sidebar, comments).

   Palette is derived from the blog&#39;s own Awesome Inc. dark theme so
   the post reads as native rather than as an embedded card:
     page background #2d3037   body text #cccccc
     links #f1c232 (gold)      link hover / post titles #29aae1
     date headers #8ce1f5
   There is no light variant on purpose. Blogger has no theme-toggle
   attribute, so a light default would be the only thing that ever
   rendered — which is exactly how this post shipped white the first
   time. Panels are graded around #2d3037 instead of using an absolute
   background, so the article never fights the page it sits on.
   ------------------------------------------------------------------ */
#xm-guide{
  --bg:transparent; --panel:#34383f; --panel2:#3b4048; --line:#454b54;
  --fg:#d4d7dc; --fg-strong:#eef0f3; --fg-dim:#a3a9b2; --fg-faint:#848b95;
  --accent:#f1c232; --accent-2:#29aae1; --warn:#ffb454; --danger:#ff7a84;
  --code-bg:#23262c; --code-fg:#d4d7dc;
  --kw:#c792ea; --str:#c3e88d; --com:#828a94; --num:#f78c6c;
  --dec:#ffcb6b; --fn:#82aaff; --inline-code:#e6d3ff;
  --pass:#4fd6b0; --fail:#ff7a84;
  --mono:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,&quot;JetBrains Mono&quot;,Menlo,Consolas,&quot;Liberation Mono&quot;,monospace;
  --sans:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif;
}
#xm-guide, #xm-guide *{box-sizing:border-box}
#xm-guide{
  background:var(--bg); color:var(--fg);
  font-family:var(--sans); font-size:16px; line-height:1.7;
  -webkit-font-smoothing:antialiased;
  /* No frame: the theme already pads the post column, so a border plus
     its own background would read as a widget pasted onto the page. */
  padding:2px 0 44px; border:0; border-radius:0;
}
#xm-guide .wrap{max-width:1000px;margin:0 auto;min-width:0}

/* headings */
#xm-guide h1{font-size:38px;line-height:1.18;letter-spacing:-.8px;margin:0 0 12px;color:var(--fg)}
#xm-guide .lede{font-size:18px;color:var(--fg-dim);max-width:70ch;margin:0 0 8px}
/* font-family is restated on h2/h4: the theme styles bare `h2` and `h4`
   with a `font:` shorthand, which sets Arial and beats plain inheritance
   from #xm-guide. */
#xm-guide h2{
  font-family:var(--sans);line-height:inherit;
  font-size:15px;text-transform:uppercase;letter-spacing:.1em;color:var(--accent-2);
  margin:64px 0 6px;padding-top:22px;border-top:1px solid var(--line);font-weight:700;
  scroll-margin-top:16px;
}
/* line-height is pinned to inherit rather than left undeclared: the
   site-wide tone CSS sets a heading line-height, and an undeclared
   property is the one thing an opt-out guard cannot protect if that
   guard ever fails to apply. `inherit` reproduces exactly what these
   headings render at today. */
#xm-guide h3{font-size:25px;line-height:inherit;letter-spacing:-.4px;margin:38px 0 10px;color:var(--fg-strong);scroll-margin-top:20px}
#xm-guide h4{font-family:var(--sans);font-size:16.5px;line-height:inherit;font-weight:600;margin:26px 0 8px;color:var(--fg-strong)}
#xm-guide p{max-width:74ch;margin:12px 0}
#xm-guide ul, #xm-guide ol{max-width:74ch;padding-left:22px;margin:10px 0}
/* The theme&#39;s `.main-inner .widget ul{list-style:none}` strips markers from
   every list in the post body, so the markers are put back explicitly. */
#xm-guide ul{list-style:disc}
#xm-guide ol{list-style:decimal}
#xm-guide li{margin:6px 0}
#xm-guide a{color:var(--accent)}
#xm-guide code{
  font-family:var(--mono);font-size:.875em;background:var(--panel2);
  padding:2px 6px;border-radius:4px;border:1px solid var(--line);color:var(--inline-code);
}
#xm-guide strong{color:var(--fg-strong);font-weight:650}
#xm-guide em{font-style:italic}

/* code blocks */
#xm-guide .snippet{margin:18px 0;border:1px solid var(--line);border-radius:10px;overflow:hidden;background:var(--code-bg)}
#xm-guide .snippet-head{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:7px 12px;background:var(--panel);border-bottom:1px solid var(--line);
}
#xm-guide .snippet-name{font-family:var(--mono);font-size:12px;color:var(--fg-faint)}
#xm-guide .snippet-name b{color:var(--fg-dim);font-weight:600}
#xm-guide .copy{
  background:transparent;border:1px solid var(--line);color:var(--fg-faint);
  font-size:11px;padding:3px 9px;border-radius:5px;cursor:pointer;font-family:var(--sans);line-height:1.4;
}
#xm-guide .copy:hover{color:var(--fg);border-color:var(--fg-faint)}
#xm-guide .copy.ok{color:var(--accent-2);border-color:var(--accent-2)}
#xm-guide pre{
  margin:0;padding:14px 16px;overflow-x:auto;background:var(--code-bg);
  font-family:var(--mono);font-size:13.5px;line-height:1.62;color:var(--code-fg);
  border:0;border-radius:0;
}
#xm-guide pre code{background:none;border:0;padding:0;font-size:inherit;color:inherit}
#xm-guide pre::-webkit-scrollbar{height:9px}
#xm-guide pre::-webkit-scrollbar-thumb{background:var(--line);border-radius:5px}
#xm-guide .out pre{color:var(--fg-dim)}
#xm-guide .out .snippet-name b{color:var(--warn)}

/* syntax colors */
#xm-guide .t-kw{color:var(--kw)}
#xm-guide .t-str{color:var(--str)}
#xm-guide .t-com{color:var(--com);font-style:italic}
#xm-guide .t-num{color:var(--num)}
#xm-guide .t-dec{color:var(--dec)}
#xm-guide .t-fn{color:var(--fn)}
#xm-guide .t-pass{color:var(--pass)}
#xm-guide .t-fail{color:var(--fail)}

/* callouts */
/* Info reads cyan, not gold: gold is the theme&#39;s link colour and would
   collide with .warn&#39;s amber at these low alphas. */
#xm-guide .note{
  border-left:3px solid var(--accent-2);background:rgba(41,170,225,.09);
  padding:12px 16px;margin:18px 0;border-radius:0 8px 8px 0;max-width:74ch;
}
#xm-guide .note.warn{border-color:var(--warn);background:rgba(255,180,84,.08)}
#xm-guide .note.trap{border-color:var(--danger);background:rgba(255,122,132,.08)}
#xm-guide .note .tag{
  display:block;font-size:10.5px;text-transform:uppercase;letter-spacing:.1em;
  font-weight:700;color:var(--accent-2);margin-bottom:3px;
}
#xm-guide .note.warn .tag{color:var(--warn)}
#xm-guide .note.trap .tag{color:var(--danger)}
#xm-guide .note p{margin:5px 0}
#xm-guide .note .tag code{
  background:none !important;border:0 !important;padding:0 !important;
  color:inherit !important;font-size:1em !important;
}

/* tables */
#xm-guide .table-wrap{overflow-x:auto;margin:18px 0}
#xm-guide table{border-collapse:collapse;width:100%;margin:0;font-size:14.5px;background:none}
#xm-guide th, #xm-guide td{text-align:left;padding:9px 13px;border:0;border-bottom:1px solid var(--line);vertical-align:top}
#xm-guide th{color:var(--fg-faint);font-size:11.5px;text-transform:uppercase;letter-spacing:.07em;font-weight:700}
#xm-guide td code{font-size:.9em}
#xm-guide tbody tr:hover{background:var(--panel)}

/* furniture */
#xm-guide .kicker{
  font-size:12px;font-weight:700;letter-spacing:.13em;text-transform:uppercase;
  color:var(--accent-2);margin-bottom:14px;
}
#xm-guide .rule{height:1px;background:var(--line);margin:30px 0 4px;max-width:74ch}

#xm-guide .toc{
  border:1px solid var(--line);border-radius:12px;background:var(--panel);
  padding:20px 24px;margin:34px 0 10px;max-width:74ch;
}
#xm-guide .toc h4{margin:0 0 14px;font-size:13px;text-transform:uppercase;letter-spacing:.1em;color:var(--fg-faint)}
#xm-guide .toc ol{margin:0;padding-left:20px;max-width:none}
#xm-guide .toc &gt; ol &gt; li{margin:14px 0}
#xm-guide .toc &gt; ol &gt; li &gt; a{text-decoration:none;font-weight:650;font-size:16.5px}
#xm-guide .toc a{text-decoration:none;color:var(--accent)}
#xm-guide .toc a:hover{text-decoration:underline}
#xm-guide .toc span{color:var(--fg-faint);font-weight:400;font-size:14px}
#xm-guide .toc ul{
  list-style:none;margin:7px 0 0;padding-left:0;max-width:none;
  display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:1px 18px;
}
#xm-guide .toc ul li{margin:0}
#xm-guide .toc ul a{font-size:14px;color:var(--fg-dim)}
#xm-guide .toc ul a:hover{color:var(--accent)}

#xm-guide .takeaway{
  border:1px solid var(--line);border-left:3px solid var(--accent-2);
  border-radius:0 12px 12px 0;background:var(--panel);
  padding:18px 22px;margin:26px 0;max-width:74ch;
}
#xm-guide .takeaway h4{margin:0 0 10px;font-size:14px;text-transform:uppercase;letter-spacing:.08em;color:var(--accent-2)}
#xm-guide .takeaway ul{margin:0;padding-left:20px}

/* Always stacked, never side by side: the theme&#39;s centre column is ~545px
   of content, so two code panes would each get ~265px and clip mid-token
   regardless of viewport width (the 900px media query never fires). */
#xm-guide .grid2{display:grid;grid-template-columns:1fr;gap:16px}
#xm-guide .grid2 .snippet{margin:0;min-width:0}
#xm-guide .badge{
  display:inline-block;font-size:11px;padding:2px 8px;border-radius:20px;
  border:1px solid var(--line);color:var(--fg-faint);margin-left:8px;vertical-align:middle;
  letter-spacing:normal;line-height:1.4;text-align:left;background:none;
}
#xm-guide .kbd{
  font-family:var(--mono);font-size:12px;background:var(--panel2);border:1px solid var(--line);
  border-bottom-width:2px;border-radius:4px;padding:1px 6px;
}
#xm-guide .foot{
  margin-top:70px;padding-top:20px;border-top:1px solid var(--line);
  color:var(--fg-faint);font-size:13px;
}
/* ------------------------------------------------------------------
   The Blogger theme re-colours bare descendants of the post container:
   body{color:#cccccc}, .post-body ul li{color:#cccccc},
   .main-inner .widget ul li{color:#ffffff}, a:link{color:#f1c232},
   h2{color:#8ce1f5}, h4{color:#29aae1}. Re-assert the article palette
   here — #xm-guide carries an id, so it wins on specificity, and the
   !important guards cover the handful of host rules that use it too.
   Kept deliberately narrow: anything with a per-component colour of its
   own (.toc h4, .takeaway h4, .note .tag) must not be caught by these.
   ------------------------------------------------------------------ */
#xm-guide h1, #xm-guide h3{color:var(--fg-strong) !important}
#xm-guide h2{color:var(--accent-2) !important}
#xm-guide p{color:var(--fg) !important}
#xm-guide li{color:var(--fg) !important;padding:0;border:0}
#xm-guide .lede{color:var(--fg-dim) !important}
#xm-guide strong{color:var(--fg-strong) !important}
#xm-guide a, #xm-guide .toc a{color:var(--accent) !important}
#xm-guide .toc ul a{color:var(--fg-dim) !important}
#xm-guide a:hover, #xm-guide .toc ul a:hover{color:var(--accent) !important}
#xm-guide code{background:var(--panel2) !important;color:var(--inline-code) !important}
#xm-guide pre code{background:none !important;color:var(--code-fg) !important}
#xm-guide table{background:none !important;table-layout:auto !important}
#xm-guide th{background:var(--panel2) !important;color:var(--fg-faint) !important}
#xm-guide td{color:var(--fg) !important}
#xm-guide th, #xm-guide td{border-color:var(--line) !important}
#xm-guide tbody tr:hover{background:var(--panel) !important}

@media screen and (max-width:900px){
  #xm-guide{padding:2px 0 36px}
  #xm-guide table{font-size:13.5px}
}
@media screen and (max-width:640px){
  #xm-guide .toc ul{grid-template-columns:1fr}
}
&lt;/style&gt;

&lt;div id=&quot;xm-guide&quot; data-tone=&quot;self&quot;&gt;
&lt;div class=&quot;wrap&quot;&gt;

&lt;div class=&quot;kicker&quot;&gt;C · Preprocessor&lt;/div&gt;
&lt;p class=&quot;lede&quot;&gt;
  C forgets the name of every field the moment it finishes compiling. The X-macro is how a C
  programmer gets those names back — by writing the list once and replaying it as an enum, a string
  table, a descriptor table, and a set of registration calls that run before &lt;code&gt;main&lt;/code&gt;.
&lt;/p&gt;

&lt;div class=&quot;rule&quot;&gt;&lt;/div&gt;

&lt;p&gt;
  Almost everyone meets &lt;code&gt;#define&lt;/code&gt; as a way to name the number &lt;code&gt;100&lt;/code&gt; and then never
  thinks about it again. That is a shame, because the preprocessor is the only part of C that can
  write C for you, and there is one pattern in particular that turns it from a curiosity into
  something load-bearing.
&lt;/p&gt;
&lt;p&gt;
  The problem it solves is dull enough that it hides in plain sight: &lt;strong&gt;one piece of knowledge,
  written down in two places.&lt;/strong&gt; An enum and the array of names that goes with it. A struct and
  the code that serialises it. A config table and the parser that reads it. Each pair is fine on the
  day it is written and wrong three months later, when someone edits one half.
&lt;/p&gt;
&lt;p&gt;
  This is written as a path. Part 1 is the mechanics — what a macro actually does, and how a list
  grows a hole in it. Part 2 builds the useful thing: a runtime table describing a struct, with
  offsets the compiler computes. Part 3 makes that table reachable, first from elsewhere in the
  program and then from Python. Part 4 is the part people learn the hard way.
&lt;/p&gt;
&lt;p&gt;
  Everything here was compiled and run before publishing — gcc 11.4.0 on x86-64, CPython 3.10 — and
  every output block is copied from a real run, including the error message.
&lt;/p&gt;

&lt;div class=&quot;toc&quot;&gt;
  &lt;h4&gt;Contents&lt;/h4&gt;
  &lt;ol&gt;
    &lt;li&gt;
      &lt;a href=&quot;#xm-text&quot;&gt;The preprocessor&lt;/a&gt;
      &lt;span&gt;— what is really happening before the compiler starts&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-text&quot;&gt;A macro is text&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-drift&quot;&gt;Two lists that drift&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-xmacro&quot;&gt;The list with a hole&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-operators&quot;&gt;# and ##&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;#xm-layout&quot;&gt;Describing a struct&lt;/a&gt;
      &lt;span&gt;— the payoff: a table the compiler fills in&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-layout&quot;&gt;What C throws away&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-table&quot;&gt;The field table&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-padding&quot;&gt;Padding you&#39;d get wrong&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-reuse&quot;&gt;One list, another output&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-rename&quot;&gt;Renaming breaks the build&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;#xm-registry&quot;&gt;Making it reachable&lt;/a&gt;
      &lt;span&gt;— from a table nobody can find to one everybody can&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-registry&quot;&gt;Registering before main&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-counter&quot;&gt;Unique names&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-ffi&quot;&gt;Reading it from Python&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-mirror&quot;&gt;Building a mirror&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;#xm-pitfalls&quot;&gt;Practice&lt;/a&gt;
      &lt;span&gt;— traps, tooling, and knowing when to stop&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-pitfalls&quot;&gt;Pitfalls&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-expand&quot;&gt;Debugging expansions&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-when-not&quot;&gt;When not to&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-cheatsheet&quot;&gt;Cheat sheet&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-closing&quot;&gt;Wrapping up&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-further&quot;&gt;Further reading&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;#xm-files&quot;&gt;Appendix&lt;/a&gt;
      &lt;span&gt;— the three programs in full, and how to build them&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-files&quot;&gt;Building and running&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-src-demo&quot;&gt;demo.c&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-src-reflect&quot;&gt;reflect.c&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#xm-src-python&quot;&gt;read_layout.py&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;


&lt;!-- ==================== PART 1 ==================== --&gt;
&lt;h2&gt;Part 1 · The preprocessor&lt;/h2&gt;

&lt;h3 id=&quot;xm-text&quot;&gt;A macro is text, not a value&lt;/h3&gt;
&lt;p&gt;
  Most people meet &lt;code&gt;#define&lt;/code&gt; as a way to name a constant, and stop there.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;the half everyone knows&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;#define MAX_USERS 100&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The other half is that a macro can take parameters, and that what it does is
  &lt;strong&gt;substitute text before the compiler ever sees the file&lt;/strong&gt;.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;the other half&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;#define SQUARE(x) ((x) * (x))

int n = SQUARE(3 + 1);      /* becomes ((3 + 1) * (3 + 1)), so 16 */&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Nothing is evaluated. No types are checked. There is no function call, no scope, no
  &lt;code&gt;x&lt;/code&gt; anywhere at runtime. The preprocessor pastes characters and moves on, and the
  compiler then reads the result as if you had typed it yourself.
&lt;/p&gt;
&lt;p&gt;
  Hold on to that sentence, because every clever thing below is just careful pasting. The parentheses
  around &lt;code&gt;(x)&lt;/code&gt; in that snippet are the classic example of why: without them,
  &lt;code&gt;SQUARE(3 + 1)&lt;/code&gt; pastes into &lt;code&gt;3 + 1 * 3 + 1&lt;/code&gt;, which is 7.
&lt;/p&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Mental model&lt;/span&gt;
  &lt;p&gt;
    A macro is not a function that runs early. It is a find-and-replace rule that runs on your source
    text. When an expansion surprises you, the answer is always visible in the pasted text — see
    &lt;a href=&quot;#xm-expand&quot;&gt;debugging expansions&lt;/a&gt;.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;xm-drift&quot;&gt;Two lists that must agree&lt;/h3&gt;
&lt;p&gt;
  Say you have three colours. You need an enum for the code, and names for logging.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;the obvious way&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;enum color { COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_COUNT };

static const char *color_names[] = { &quot;RED&quot;, &quot;GREEN&quot;, &quot;BLUE&quot; };&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  This is fine. It stays fine right up until someone adds &lt;code&gt;COLOR_YELLOW&lt;/code&gt; to the enum and
  does not touch the array. Now &lt;code&gt;color_names[COLOR_YELLOW]&lt;/code&gt; reads past the end of the
  array, and nothing warns you — as far as the compiler is concerned these are two unrelated
  declarations that happen to sit next to each other. Keeping them in sync is a rule that lives only
  in someone&#39;s memory.
&lt;/p&gt;
&lt;p&gt;
  The same shape shows up everywhere once you start looking for it: an enum and the &lt;code&gt;switch&lt;/code&gt;
  over it, a struct and its serialiser, a set of command-line flags and the help text. Two lists, one
  fact, and a silent failure when they disagree.
&lt;/p&gt;


&lt;h3 id=&quot;xm-xmacro&quot;&gt;The X-macro: give the list a parameter&lt;/h3&gt;
&lt;p&gt;
  The idea is to write the list exactly once, but leave a hole where the &lt;em&gt;action&lt;/em&gt; goes.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;the list&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;#define COLOR_LIST(X) \
    X(RED)            \
    X(GREEN)          \
    X(BLUE)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  &lt;code&gt;COLOR_LIST&lt;/code&gt; is not a value and cannot be used on its own. It is a list that does not yet
  know what to do with its items — &lt;code&gt;X&lt;/code&gt; is the hole. By convention that parameter is named
  &lt;code&gt;X&lt;/code&gt;, which is the whole reason the pattern is called an X-macro; any name works.
&lt;/p&gt;
&lt;p&gt;
  Now define what a single item should become, and hand it in.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;two actions, one list&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;#define AS_ENUM(name)   COLOR_##name,
#define AS_STRING(name) #name,

enum color { COLOR_LIST(AS_ENUM) COLOR_COUNT };

static const char *color_names[] = { COLOR_LIST(AS_STRING) };&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  &lt;code&gt;COLOR_LIST(AS_ENUM)&lt;/code&gt; pastes into &lt;code&gt;COLOR_RED, COLOR_GREEN, COLOR_BLUE,&lt;/code&gt; and
  &lt;code&gt;COLOR_LIST(AS_STRING)&lt;/code&gt; pastes into &lt;code&gt;&quot;RED&quot;, &quot;GREEN&quot;, &quot;BLUE&quot;,&lt;/code&gt;. Two completely
  different pieces of code out of one list, and the trailing comma is harmless in both because
  &lt;code&gt;COLOR_COUNT&lt;/code&gt; follows the first and C allows a trailing comma in an initialiser.
&lt;/p&gt;
&lt;p&gt;
  Add &lt;code&gt;X(YELLOW)&lt;/code&gt; to the list and &lt;strong&gt;both&lt;/strong&gt; the enum and the name array grow.
  The synchronisation bug is not fixed by discipline here; it has been made impossible to write.
&lt;/p&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;./demo&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;colors: 3
  0 = RED
  1 = GREEN
  2 = BLUE&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Note&lt;/span&gt;
  &lt;p&gt;
    Notice where the comma lives: inside &lt;code&gt;AS_ENUM&lt;/code&gt; and &lt;code&gt;AS_STRING&lt;/code&gt;, not in
    &lt;code&gt;COLOR_LIST&lt;/code&gt;. The list carries no punctuation at all, because different actions want
    different separators — an enum wants commas, a sequence of statements wants none.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;xm-operators&quot;&gt;The two operators: &lt;code&gt;#&lt;/code&gt; and &lt;code&gt;##&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;
  Those action macros used two operators that exist nowhere else in C.
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;&lt;th&gt;Operator&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Given &lt;code&gt;name&lt;/code&gt; = &lt;code&gt;RED&lt;/code&gt;&lt;/th&gt;&lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;#name&lt;/code&gt;&lt;/td&gt;&lt;td&gt;stringify&lt;/td&gt;&lt;td&gt;produces the string literal &lt;code&gt;&quot;RED&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;A##B&lt;/code&gt;&lt;/td&gt;&lt;td&gt;token paste&lt;/td&gt;&lt;td&gt;&lt;code&gt;COLOR_##name&lt;/code&gt; produces the single token &lt;code&gt;COLOR_RED&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;
  The property that makes &lt;code&gt;#&lt;/code&gt; worth the trouble is that the string comes from
  &lt;strong&gt;the actual token you wrote&lt;/strong&gt;. You cannot end up with a name string that disagrees
  with the identifier beside it, because they are literally the same characters. Every hand-written
  &lt;code&gt;&quot;id&quot;&lt;/code&gt; next to a field called &lt;code&gt;id&lt;/code&gt; is a copy waiting to go stale;
  &lt;code&gt;#M&lt;/code&gt; is not a copy.
&lt;/p&gt;
&lt;p&gt;
  &lt;code&gt;##&lt;/code&gt; is what lets one list generate distinct identifiers — &lt;code&gt;COLOR_RED&lt;/code&gt;,
  &lt;code&gt;sensor_reading_fields&lt;/code&gt;, &lt;code&gt;FIELD_IDX_timestamp&lt;/code&gt;. It has one sharp edge, which
  we will hit in &lt;a href=&quot;#xm-counter&quot;&gt;the section on unique names&lt;/a&gt;: &lt;code&gt;##&lt;/code&gt; suppresses macro
  expansion of its own operands.
&lt;/p&gt;


&lt;!-- ==================== PART 2 ==================== --&gt;
&lt;h2&gt;Part 2 · Describing a struct&lt;/h2&gt;

&lt;h3 id=&quot;xm-layout&quot;&gt;What C throws away&lt;/h3&gt;
&lt;p&gt;
  Colours are a warm-up. Here is the use that actually earns the pattern its place.
&lt;/p&gt;
&lt;p&gt;
  C discards field names at compile time. After the compiler is done, a struct is a size and a set of
  byte offsets; the word &lt;code&gt;timestamp&lt;/code&gt; exists in the debug info, if you asked for it, and
  nowhere else. So the moment something outside the compiler needs to know that &quot;byte 16 of this
  struct is a &lt;code&gt;double&lt;/code&gt; called &lt;code&gt;timestamp&lt;/code&gt;&quot; — a serialiser, a logger, a test
  harness, another language — somebody has to write that down.
&lt;/p&gt;
&lt;p&gt;
  Writing it down by hand is the two-lists problem again, with worse consequences, because now the
  second list contains numbers.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;demo.c&lt;/b&gt; — the struct&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;struct sensor_reading {
    int    id;
    int    sample_count;
    float  temperature;
    double timestamp;
    char  *label;
};&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;demo.c&lt;/b&gt; — what we want to produce&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;typedef enum { FIELD_INT, FIELD_FLOAT, FIELD_DOUBLE, FIELD_PTR } field_type;

typedef struct {
    const char *name;
    field_type  type;
    unsigned    offset;
    unsigned    size;
} field_desc;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3 id=&quot;xm-table&quot;&gt;Building the field table&lt;/h3&gt;
&lt;p&gt;
  Same shape as before: write the list once, with a hole. Each item now carries three pieces of
  information instead of one — the struct it belongs to, the member, and a type tag.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;demo.c&lt;/b&gt; — the list&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;#define SENSOR_FIELDS(X)                               \
    X(struct sensor_reading, id, FIELD_INT)            \
    X(struct sensor_reading, sample_count, FIELD_INT)  \
    X(struct sensor_reading, temperature, FIELD_FLOAT) \
    X(struct sensor_reading, timestamp, FIELD_DOUBLE)  \
    X(struct sensor_reading, label, FIELD_PTR)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;demo.c&lt;/b&gt; — one action, one table&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;#define AS_FIELD_DESC(S, M, T) \
    { #M, (T), (unsigned)offsetof(S, M), (unsigned)sizeof(((S *)0)-&amp;gt;M) },

static const field_desc sensor_layout[] = { SENSOR_FIELDS(AS_FIELD_DESC) };&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Two things in that action macro are worth stopping on.&lt;/p&gt;

&lt;p&gt;
  &lt;strong&gt;&lt;code&gt;offsetof(S, M)&lt;/code&gt;&lt;/strong&gt; is a standard macro from &lt;code&gt;&amp;lt;stddef.h&amp;gt;&lt;/code&gt;,
  and the crucial word is &lt;em&gt;standard&lt;/em&gt;: the compiler computes the byte offset. You never type a
  number, so the table cannot drift from the real layout when a field is inserted, when the order
  changes, or when padding rules differ between targets.
&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;&lt;code&gt;sizeof(((S *)0)-&amp;gt;M)&lt;/code&gt;&lt;/strong&gt; is the idiom for &quot;the size of member
  &lt;code&gt;M&lt;/code&gt; of type &lt;code&gt;S&lt;/code&gt;&quot; when you have no instance to point at. It looks like a null
  dereference and is not one: &lt;code&gt;sizeof&lt;/code&gt; does not evaluate its operand, it only inspects the
  operand&#39;s type, so nothing is ever read from address zero. C11 also offers
  &lt;code&gt;sizeof(((S){0}).M)&lt;/code&gt; if the cast makes you uncomfortable.
&lt;/p&gt;
&lt;p&gt;
  Here is what the preprocessor genuinely emits for the first entry, lifted out of
  &lt;code&gt;gcc -E -P demo.c&lt;/code&gt;:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;gcc -E -P demo.c&lt;/b&gt; — after pasting&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;{&quot;id&quot;, (FIELD_INT), (unsigned)__builtin_offsetof (struct sensor_reading, id),
 (unsigned)sizeof(((struct sensor_reading *)0)-&amp;gt;id)},&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;…and what the compiler folds that into, before anything runs:&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;constant-folded&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;{&quot;id&quot;, 0, 0, 4}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  There is no runtime cost to any of this. The table is a static array of constants in
  &lt;code&gt;.rodata&lt;/code&gt;, exactly as if it had been typed out by hand — the difference is only in who
  typed it.
&lt;/p&gt;


&lt;h3 id=&quot;xm-padding&quot;&gt;The padding you would have got wrong&lt;/h3&gt;
&lt;p&gt;The full table, printed at runtime:&lt;/p&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;./demo&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;sizeof(struct sensor_reading) = 32
field count = 5
name           type  offset  size
id             0     0       4
sample_count   0     4       4
temperature    1     8       4
timestamp      2     16      8
label          3     24      8&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Look at &lt;code&gt;temperature&lt;/code&gt;: it starts at byte 8 and is 4 bytes long, so it ends at 12. But
  &lt;code&gt;timestamp&lt;/code&gt; starts at 16, not 12. The compiler inserted four bytes of padding so the
  &lt;code&gt;double&lt;/code&gt; lands on an 8-byte boundary. The five field sizes add up to 28; the struct is 32.
&lt;/p&gt;
&lt;p&gt;
  A hand-written table would have said 12, and every read through it would have been off by four
  bytes from that field onward — the kind of bug that produces plausible-looking garbage rather than a
  crash. &lt;code&gt;offsetof&lt;/code&gt; did not get it wrong, and cannot.
&lt;/p&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;ABI&lt;/span&gt;
  &lt;p&gt;
    These numbers are for the x86-64 System V ABI. On a different target the offsets and the total
    size may differ. That is an argument &lt;em&gt;for&lt;/em&gt; &lt;code&gt;offsetof&lt;/code&gt; rather than a caveat about
    it: the same source produces the right table on each target.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;xm-reuse&quot;&gt;The same list, a different output&lt;/h3&gt;
&lt;p&gt;
  The list is now a reusable asset, and this is where the pattern starts paying compound interest. A
  different action over the same list gives you named indices into the table:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;demo.c&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;#define AS_INDEX(S, M, T) FIELD_IDX_##M,

enum { SENSOR_FIELDS(AS_INDEX) SENSOR_FIELD_COUNT };&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;./demo&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;FIELD_IDX_timestamp = 3&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Note that &lt;code&gt;AS_INDEX&lt;/code&gt; ignores two of its three parameters. That is normal and fine — the
  list is a fixed shape, and each action takes what it needs. Adding one field to the struct and one
  line to the list now updates the descriptor table, the index enum, and the count, in one edit.
&lt;/p&gt;
&lt;p&gt;
  Other actions people write over the same list, without changing it: a &lt;code&gt;switch&lt;/code&gt; that
  converts a field name string back to an index, a printf-style dumper with the right format specifier
  per type tag, a JSON writer, a comparison function, a fuzzer that fills each field with the right
  kind of noise.
&lt;/p&gt;


&lt;h3 id=&quot;xm-rename&quot;&gt;Renaming a field breaks the build — on purpose&lt;/h3&gt;
&lt;p&gt;
  This is the property that makes the syntax worth tolerating, and it is easy to miss because nothing
  visibly happens on a good day.
&lt;/p&gt;
&lt;p&gt;
  Rename &lt;code&gt;id&lt;/code&gt; to &lt;code&gt;reading_id&lt;/code&gt; in the struct and forget the list. The build stops:
&lt;/p&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;gcc -std=c11 -Wall -Wextra -o demo demo.c&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;error: ‘struct sensor_reading’ has no member named ‘id’
   50 |     {#M, (T), (unsigned)offsetof(S, M), (unsigned)sizeof(((S *)0)-&amp;gt;M)},
      |                         ^~~~~~~~
   43 |     X(struct sensor_reading, id, FIELD_INT)
      |     ^ in expansion of macro ‘AS_FIELD_DESC’&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Compare that with the hand-written table, where the string &lt;code&gt;&quot;id&quot;&lt;/code&gt; would go on cheerfully
  naming a field that no longer exists, and the offset next to it would now describe a different
  field entirely. &lt;strong&gt;A stale hand-written mirror is silent; a stale X-macro list is a compile
  error.&lt;/strong&gt; The entire pattern can be justified on that one sentence.
&lt;/p&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Reading the error&lt;/span&gt;
  &lt;p&gt;
    The compiler points at line 50 — inside &lt;code&gt;AS_FIELD_DESC&lt;/code&gt;, which is not where your
    mistake is — and then adds an &quot;in expansion of macro&quot; note pointing at line 43, which is. Always
    read down to the note.
  &lt;/p&gt;
&lt;/div&gt;


&lt;!-- ==================== PART 3 ==================== --&gt;
&lt;h2&gt;Part 3 · Making it reachable&lt;/h2&gt;

&lt;h3 id=&quot;xm-registry&quot;&gt;Registering yourself before &lt;code&gt;main&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;
  A table is only useful if something can find it. The usual arrangement is a small registry that
  types add themselves to:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;reflect.c&lt;/b&gt; — the registry API&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;void layout_register(const char *type_name, const field_desc *fields,
                     size_t count, size_t struct_size);

const field_desc *layout_lookup(const char *type_name, size_t *count_out);&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  You could call &lt;code&gt;layout_register&lt;/code&gt; from &lt;code&gt;main&lt;/code&gt;. But then every new type means
  editing &lt;code&gt;main&lt;/code&gt;, and a central list of every type in the program is exactly the drift
  problem from &lt;a href=&quot;#xm-drift&quot;&gt;part 1&lt;/a&gt;, moved up one level. Better to have the call happen by
  itself:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;reflect.c&lt;/b&gt; — one line adds a type&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;#define REGISTER_LAYOUT(NAME, STRUCT, FIELDS)                               \
    static const field_desc NAME##_fields[] = { FIELDS(AS_FIELD_DESC) };    \
    __attribute__((constructor)) static void NAME##_register_layout(void) { \
        layout_register(#NAME, NAME##_fields,                               \
                        sizeof(NAME##_fields) / sizeof(NAME##_fields[0]),   \
                        sizeof(STRUCT));                                    \
    }

REGISTER_LAYOUT(sensor_reading, struct sensor_reading, SENSOR_FIELDS)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  That one invocation generates three things at once: a static table built from the field list, a
  function that hands it to the registry, and the annotation that makes the function run on its own.
  &lt;code&gt;#NAME&lt;/code&gt; supplies the lookup key, and &lt;code&gt;sizeof(arr)/sizeof(arr[0])&lt;/code&gt; supplies the
  count without anyone counting.
&lt;/p&gt;
&lt;p&gt;
  &lt;code&gt;__attribute__((constructor))&lt;/code&gt; marks a function to run before &lt;code&gt;main&lt;/code&gt; — or, in
  a shared library, at load time. It is a GCC and Clang extension rather than ISO C; MSVC has its own
  mechanism via &lt;code&gt;.CRT$XCU&lt;/code&gt;, and the portable fallback is an explicit &lt;code&gt;init()&lt;/code&gt;
  that you do have to remember to call. In C++ the same effect falls out of a global object&#39;s
  constructor, which is why you see the trick spelled as a dummy &lt;code&gt;static Registrar r{}&lt;/code&gt;
  there.
&lt;/p&gt;

&lt;div class=&quot;takeaway&quot;&gt;
  &lt;h4&gt;Why this shape keeps showing up&lt;/h4&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;strong&gt;The knowledge sits next to the thing it describes.&lt;/strong&gt; The field list lives beside the struct, not in a registry file three directories away.&lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;Adding a type is a local edit.&lt;/strong&gt; No shared file to touch, so no merge conflict when two people add a type in the same week.&lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;Nothing can be half-added.&lt;/strong&gt; The table, the registration and the name all come from one macro invocation, so there is no state where one exists without the others.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;


&lt;h3 id=&quot;xm-counter&quot;&gt;Unique names when the macro is used twice&lt;/h3&gt;
&lt;p&gt;
  &lt;code&gt;NAME##_fields&lt;/code&gt; works because the caller supplies a distinct &lt;code&gt;NAME&lt;/code&gt;. Sometimes
  a macro has to be usable twice in one file with nothing to distinguish the uses — two registrations
  of the same struct under different keys, say. The standard-ish trick is &lt;code&gt;__COUNTER__&lt;/code&gt;,
  which expands to 0, 1, 2, … each time it is read.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;the two-step dance&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;#define UNIQUE_IMPL2(ctr) static int tmp_var_##ctr;
#define UNIQUE_IMPL(ctr)  UNIQUE_IMPL2(ctr)
#define MAKE_UNIQUE()     UNIQUE_IMPL(__COUNTER__)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Trap&lt;/span&gt;
  &lt;p&gt;
    The middle layer is not decoration. &lt;code&gt;##&lt;/code&gt; suppresses expansion of its operands, so
    without &lt;code&gt;UNIQUE_IMPL&lt;/code&gt; you get a variable literally named
    &lt;code&gt;tmp_var___COUNTER__&lt;/code&gt; — and a redefinition error on the second use. The extra
    indirection forces &lt;code&gt;__COUNTER__&lt;/code&gt; to expand to a number &lt;em&gt;before&lt;/em&gt; it reaches the
    paste.
  &lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;
  &lt;code&gt;__COUNTER__&lt;/code&gt; is supported by GCC, Clang and MSVC but is not in the standard.
  &lt;code&gt;__LINE__&lt;/code&gt; is the portable substitute and is fine whenever one use per line is an
  acceptable restriction.
&lt;/p&gt;


&lt;h3 id=&quot;xm-ffi&quot;&gt;Reading the table from another language&lt;/h3&gt;
&lt;p&gt;
  Once the table lives in a shared library behind a plain C function, anything with an FFI can read
  it. Python&#39;s &lt;code&gt;ctypes&lt;/code&gt; is in the standard library, so this needs no dependencies:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;read_layout.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;class FieldDesc(ctypes.Structure):
    _fields_ = [(&quot;name&quot;, ctypes.c_char_p), (&quot;type&quot;, ctypes.c_int),
                (&quot;offset&quot;, ctypes.c_uint), (&quot;size&quot;, ctypes.c_uint)]

lib = ctypes.CDLL(&quot;./libreflect.so&quot;)
lib.layout_lookup.restype = ctypes.POINTER(FieldDesc)

count = ctypes.c_size_t(0)
table = lib.layout_lookup(b&quot;sensor_reading&quot;, ctypes.byref(count))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The &lt;code&gt;FieldDesc&lt;/code&gt; declaration on the Python side does have to match the C one by hand —
  that is the one mirror you cannot escape. But it is a single four-field descriptor type that changes
  approximately never, and it buys you the description of every other struct in the program.
&lt;/p&gt;


&lt;h3 id=&quot;xm-mirror&quot;&gt;Building the mirror at runtime&lt;/h3&gt;
&lt;p&gt;
  Because the table carries names, type tags and offsets, the caller can construct a matching
  structure definition &lt;strong&gt;while the program runs&lt;/strong&gt;, instead of hand-writing one per struct:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;read_layout.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;TAGS = {0: ctypes.c_int, 1: ctypes.c_float, 2: ctypes.c_double, 3: ctypes.c_void_p}

fields = [(table[i].name.decode(), TAGS[table[i].type]) for i in range(count.value)]
Mirror = type(&quot;SensorReading&quot;, (ctypes.Structure,), {&quot;_fields_&quot;: fields})&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;python3 read_layout.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;id             tag=0 offset=0   size=4
sample_count   tag=0 offset=4   size=4
temperature    tag=1 offset=8   size=4
timestamp      tag=2 offset=16  size=8
label          tag=3 offset=24  size=8

built mirror : SensorReading
python sizeof: 32
c sizeof     : 32
mirror.timestamp offset: 16&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The two &lt;code&gt;sizeof&lt;/code&gt; values agreeing is the check that matters, and it is worth asserting
  rather than eyeballing. If they differ, the description is wrong somewhere and every subsequent
  read through the mirror lands on the wrong bytes — silently, with plausible values.
&lt;/p&gt;
&lt;p&gt;
  This is the whole payoff, and it is worth stating plainly: &lt;strong&gt;the struct is defined once, in C,
  and everybody else asks it what it looks like.&lt;/strong&gt; No generated bindings to regenerate, no
  Python file to update when a field moves, no version skew between a library and the script reading
  it — because the description ships inside the library.
&lt;/p&gt;


&lt;!-- ==================== PART 4 ==================== --&gt;
&lt;h2&gt;Part 4 · Practice&lt;/h2&gt;

&lt;h3 id=&quot;xm-pitfalls&quot;&gt;Pitfalls&lt;/h3&gt;

&lt;h4&gt;The trailing backslash must be the last character on the line&lt;/h4&gt;
&lt;p&gt;
  One trailing space after it and the continuation silently ends, taking the rest of your list with
  it. Some compilers warn; do not count on it. This is the single most common way to lose an hour to
  this pattern, and it is invisible in a diff.
&lt;/p&gt;

&lt;h4&gt;Put the punctuation in the action, not the list&lt;/h4&gt;
&lt;p&gt;
  Different actions need different separators. Keep the list free of commas and semicolons so it can
  serve an enum, an initialiser and a sequence of statements without special cases.
&lt;/p&gt;

&lt;h4&gt;Order matters when position matters&lt;/h4&gt;
&lt;p&gt;
  If consumers index the table by position, the list must follow the struct&#39;s declaration order.
  Nothing enforces this — the build still succeeds, and only the &lt;code&gt;offset&lt;/code&gt; column looks odd.
  If you can, index by name instead.
&lt;/p&gt;

&lt;h4&gt;Macros do not recurse&lt;/h4&gt;
&lt;p&gt;
  A list cannot include itself, directly or through another macro. Nested lists work only in a strict
  hierarchy. If you find yourself wanting recursion, you have outgrown the pattern.
&lt;/p&gt;

&lt;h4&gt;Keep the list next to the thing it describes&lt;/h4&gt;
&lt;p&gt;
  A field list in a different file from the struct can drift in the one way the pattern exists to
  prevent: somebody adds a field, never sees the list, and the table is quietly incomplete. Note that
  this failure is &lt;em&gt;not&lt;/em&gt; caught by the compiler — the &lt;a href=&quot;#xm-rename&quot;&gt;rename check&lt;/a&gt; only
  fires for fields the list mentions.
&lt;/p&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;The one gap&lt;/span&gt;
  &lt;p&gt;
    An X-macro list catches renamed and deleted fields. It does not catch &lt;em&gt;added&lt;/em&gt; ones. If
    completeness matters, add a static assertion that the field sizes plus known padding equal
    &lt;code&gt;sizeof&lt;/code&gt; the struct, or simply assert the struct size and let the build break when it
    changes.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;xm-expand&quot;&gt;Debugging with the preprocessor, not by staring&lt;/h3&gt;
&lt;p&gt;
  Nearly every X-macro bug becomes obvious the moment you look at the pasted text. Do not reason about
  it; print it.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;see what the compiler sees&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;gcc -E -P demo.c                      # preprocess only, strip line markers
gcc -E -P demo.c | clang-format       # ...and make it readable
gcc -E -P demo.c | sed -n &#39;/sensor_layout/,/;/p&#39;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  &lt;code&gt;-E&lt;/code&gt; stops after preprocessing and &lt;code&gt;-P&lt;/code&gt; drops the &lt;code&gt;#line&lt;/code&gt; markers
  that otherwise dominate the output. Everything the compiler will see is in there, including the
  expansion you were sure was correct.
&lt;/p&gt;


&lt;h3 id=&quot;xm-when-not&quot;&gt;When not to reach for it&lt;/h3&gt;

&lt;h4&gt;When the list has exactly one consumer&lt;/h4&gt;
&lt;p&gt;
  If you only need the enum, write the enum. The pattern costs readability up front and repays it per
  consumer; it breaks even at two and clearly pays at three.
&lt;/p&gt;

&lt;h4&gt;When the list is large, or comes from somewhere else&lt;/h4&gt;
&lt;p&gt;
  Past a few dozen entries, or when the real source of truth is a schema file, a protobuf definition
  or a database, generate a &lt;code&gt;.c&lt;/code&gt; file from a script. Generated code can be read, diffed and
  stepped through in a debugger; a wall of backslash continuations cannot.
&lt;/p&gt;

&lt;h4&gt;When you want type dispatch, not list replay&lt;/h4&gt;
&lt;p&gt;
  C11&#39;s &lt;code&gt;_Generic&lt;/code&gt; selects an expression based on a type. It solves a different problem and
  reads far better for that one.
&lt;/p&gt;

&lt;h4&gt;When the language has real reflection&lt;/h4&gt;
&lt;p&gt;
  This entire pattern is a workaround for C discarding names. In a language that keeps them, use what
  the language gives you.
&lt;/p&gt;


&lt;h3 id=&quot;xm-cheatsheet&quot;&gt;Cheat sheet&lt;/h3&gt;

&lt;h4&gt;Preprocessor operators and predefined macros&lt;/h4&gt;
&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;#x&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Stringify the argument as written&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;a##b&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Paste two tokens into one; suppresses expansion of both operands&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;__COUNTER__&lt;/code&gt;&lt;/td&gt;&lt;td&gt;0, 1, 2, … per read — needs a two-step macro to paste with&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;__LINE__&lt;/code&gt;, &lt;code&gt;__FILE__&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Portable alternatives; one use per line&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;__VA_ARGS__&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Variadic macro arguments, for actions of varying arity&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;h4&gt;Layout introspection&lt;/h4&gt;
&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;offsetof(S, M)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Byte offset of a member, from &lt;code&gt;&amp;lt;stddef.h&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;sizeof(((S *)0)-&amp;gt;M)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Size of a member with no instance; operand is not evaluated&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;sizeof(a) / sizeof(a[0])&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Element count of a real array — not of a pointer&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;_Static_assert(c, &quot;msg&quot;)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Compile-time check; useful for pinning struct size&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;h4&gt;Running code before &lt;code&gt;main&lt;/code&gt;&lt;/h4&gt;
&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;__attribute__((constructor))&lt;/code&gt;&lt;/td&gt;&lt;td&gt;GCC and Clang; also runs at &lt;code&gt;dlopen&lt;/code&gt; time&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Global object constructor&lt;/td&gt;&lt;td&gt;C++; the same effect, portably&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;.CRT$XCU&lt;/code&gt; section&lt;/td&gt;&lt;td&gt;MSVC equivalent&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Explicit &lt;code&gt;init()&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Portable fallback, at the cost of a central call site&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;h4&gt;Commands&lt;/h4&gt;
&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;gcc -E -P f.c&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Show the pasted text the compiler will read&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;gcc -Wall -Wextra&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Catches trailing-comma and unused-macro-argument mistakes&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pahole ./a.out&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Print struct layout and padding, independently of your table&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;


&lt;h2&gt;Wrapping up&lt;/h2&gt;

&lt;h3 id=&quot;xm-closing&quot;&gt;What actually matters here&lt;/h3&gt;
&lt;p&gt;
  The X-macro has a reputation for being a clever trick, which undersells it. It is a way of making a
  class of bug unrepresentable, and the syntax is the price.
&lt;/p&gt;

&lt;div class=&quot;takeaway&quot;&gt;
  &lt;h4&gt;The short list&lt;/h4&gt;
  &lt;ul&gt;
    &lt;li&gt;
      &lt;strong&gt;The list with a hole is the whole idea.&lt;/strong&gt; &lt;code&gt;LIST(X)&lt;/code&gt; plus an action
      macro; everything else in this document is a choice of action.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Let the compiler compute the numbers.&lt;/strong&gt; &lt;code&gt;offsetof&lt;/code&gt; and
      &lt;code&gt;sizeof&lt;/code&gt; mean the table cannot disagree with the struct, on any target, ever.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;A stale hand-written mirror is silent; a stale list is a compile error.&lt;/strong&gt; That
      trade — a little syntax now for a loud failure later — is the reason to use it.
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;
  The registry and the FFI reader in part 3 are a step further than most code needs, but they are the
  natural end of the road: once the description exists as data, the interesting question stops being
  &quot;how do I keep these in sync&quot; and becomes &quot;who else would like to read this&quot;. Usually the answer is
  more people than you expected.
&lt;/p&gt;


&lt;h3 id=&quot;xm-further&quot;&gt;Further reading&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://gcc.gnu.org/onlinedocs/cpp/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;The C Preprocessor&lt;/a&gt; — GCC&#39;s manual; the chapters on stringizing, concatenation and argument prescan are the relevant ones&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.cppreference.com/w/c/types/offsetof&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;offsetof&lt;/a&gt; — including exactly when it is undefined behaviour&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.python.org/3/library/ctypes.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;ctypes&lt;/a&gt; — the FFI used in part 3, standard library, no build step&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.kernel.org/doc/html/latest/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;The Linux kernel&lt;/a&gt; — &lt;code&gt;include/linux/kvm_host.h&lt;/code&gt; and the tracepoint headers are X-macros at industrial scale, for better and worse&lt;/li&gt;
&lt;/ul&gt;


&lt;!-- ==================== APPENDIX ==================== --&gt;
&lt;h2&gt;Appendix · The complete programs&lt;/h2&gt;

&lt;h3 id=&quot;xm-files&quot;&gt;Building and running&lt;/h3&gt;
&lt;p&gt;
  Everything above came from three short files, reproduced in full below so this page stands on its
  own — copy the three snippets into a directory and the commands work as written.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;build and run everything&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;gcc -std=c11 -Wall -Wextra -o demo demo.c &amp;amp;&amp;amp; ./demo

gcc -std=c11 -Wall -Wextra -shared -fPIC -o libreflect.so reflect.c
python3 read_layout.py

gcc -E -P demo.c | head -40        # see what the preprocessor produced&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Verified on gcc 11.4.0 (Ubuntu 22.04, x86-64) and CPython 3.10.12. Every output block on this page
  is copied from a real run, including the compiler error in &lt;a href=&quot;#xm-rename&quot;&gt;the rename
  section&lt;/a&gt;, which was produced by renaming &lt;code&gt;id&lt;/code&gt; to &lt;code&gt;reading_id&lt;/code&gt; in a copy of
  &lt;code&gt;demo.c&lt;/code&gt;.
&lt;/p&gt;


&lt;h3 id=&quot;xm-src-demo&quot;&gt;demo.c &lt;span class=&quot;badge&quot;&gt;74 lines&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;
  The warm-up and the field table, in one standalone program. Nothing outside the C standard library.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;demo.c&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;#include &amp;lt;stddef.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;

/* ---------- Warm-up: one list, two outputs ---------- */

#define COLOR_LIST(X) \
    X(RED)            \
    X(GREEN)          \
    X(BLUE)

#define AS_ENUM(name)   COLOR_##name,
#define AS_STRING(name) #name,

enum color { COLOR_LIST(AS_ENUM) COLOR_COUNT };

static const char *color_names[] = {COLOR_LIST(AS_STRING)};

/* ---------- Main: a runtime field table ---------- */

struct sensor_reading {
    int    id;
    int    sample_count;
    float  temperature;
    double timestamp;
    char  *label;
};

typedef enum {
    FIELD_INT = 0,
    FIELD_FLOAT = 1,
    FIELD_DOUBLE = 2,
    FIELD_PTR = 3
} field_type;

typedef struct {
    const char *name;
    field_type  type;
    unsigned    offset;
    unsigned    size;
} field_desc;

#define SENSOR_FIELDS(X)                              \
    X(struct sensor_reading, id, FIELD_INT)           \
    X(struct sensor_reading, sample_count, FIELD_INT) \
    X(struct sensor_reading, temperature, FIELD_FLOAT)\
    X(struct sensor_reading, timestamp, FIELD_DOUBLE) \
    X(struct sensor_reading, label, FIELD_PTR)

#define AS_FIELD_DESC(S, M, T) \
    {#M, (T), (unsigned)offsetof(S, M), (unsigned)sizeof(((S *)0)-&amp;gt;M)},

static const field_desc sensor_layout[] = {SENSOR_FIELDS(AS_FIELD_DESC)};

#define AS_INDEX(S, M, T) FIELD_IDX_##M,

enum { SENSOR_FIELDS(AS_INDEX) SENSOR_FIELD_COUNT };

int main(void) {
    printf(&quot;colors: %d\n&quot;, (int)COLOR_COUNT);
    for (int i = 0; i &amp;lt; COLOR_COUNT; i++)
        printf(&quot;  %d = %s\n&quot;, i, color_names[i]);

    printf(&quot;\nsizeof(struct sensor_reading) = %zu\n&quot;,
           sizeof(struct sensor_reading));
    printf(&quot;field count = %d\n&quot;, (int)SENSOR_FIELD_COUNT);
    printf(&quot;%-14s %-5s %-7s %s\n&quot;, &quot;name&quot;, &quot;type&quot;, &quot;offset&quot;, &quot;size&quot;);
    for (size_t i = 0; i &amp;lt; sizeof(sensor_layout) / sizeof(sensor_layout[0]); i++)
        printf(&quot;%-14s %-5d %-7u %u\n&quot;, sensor_layout[i].name,
               (int)sensor_layout[i].type, sensor_layout[i].offset,
               sensor_layout[i].size);

    printf(&quot;\nFIELD_IDX_timestamp = %d\n&quot;, (int)FIELD_IDX_timestamp);
    return 0;
}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3 id=&quot;xm-src-reflect&quot;&gt;reflect.c &lt;span class=&quot;badge&quot;&gt;83 lines&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;
  The registry plus a type that puts itself in it. Built as a shared library; it has no
  &lt;code&gt;main&lt;/code&gt;, and the only thing that runs is the constructor.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;reflect.c&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;#include &amp;lt;stddef.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

typedef struct {
    const char *name;
    int         type;
    unsigned    offset;
    unsigned    size;
} field_desc;

typedef struct {
    const char       *type_name;
    const field_desc *fields;
    size_t            count;
    size_t            struct_size;
} type_layout;

/* A tiny fixed-capacity registry. */
static type_layout g_registry[16];
static size_t      g_registry_count;

void layout_register(const char *type_name, const field_desc *fields, size_t count,
                     size_t struct_size) {
    if (g_registry_count &amp;gt;= 16) return;
    g_registry[g_registry_count].type_name = type_name;
    g_registry[g_registry_count].fields = fields;
    g_registry[g_registry_count].count = count;
    g_registry[g_registry_count].struct_size = struct_size;
    g_registry_count++;
}

const field_desc *layout_lookup(const char *type_name, size_t *out_count) {
    for (size_t i = 0; i &amp;lt; g_registry_count; i++) {
        if (strcmp(type_name, g_registry[i].type_name) == 0) {
            if (out_count) *out_count = g_registry[i].count;
            return g_registry[i].fields;
        }
    }
    if (out_count) *out_count = 0;
    return NULL;
}

size_t layout_sizeof(const char *type_name) {
    for (size_t i = 0; i &amp;lt; g_registry_count; i++)
        if (strcmp(type_name, g_registry[i].type_name) == 0)
            return g_registry[i].struct_size;
    return 0;
}

/* ---- a type that registers itself ---- */

struct sensor_reading {
    int    id;
    int    sample_count;
    float  temperature;
    double timestamp;
    char  *label;
};

#define FIELD_INT 0
#define FIELD_FLOAT 1
#define FIELD_DOUBLE 2
#define FIELD_PTR 3

#define SENSOR_FIELDS(X)                               \
    X(struct sensor_reading, id, FIELD_INT)            \
    X(struct sensor_reading, sample_count, FIELD_INT)  \
    X(struct sensor_reading, temperature, FIELD_FLOAT) \
    X(struct sensor_reading, timestamp, FIELD_DOUBLE)  \
    X(struct sensor_reading, label, FIELD_PTR)

#define AS_FIELD_DESC(S, M, T) \
    {#M, (T), (unsigned)offsetof(S, M), (unsigned)sizeof(((S *)0)-&amp;gt;M)},

#define REGISTER_LAYOUT(NAME, STRUCT, FIELDS)                                 \
    static const field_desc NAME##_fields[] = {FIELDS(AS_FIELD_DESC)};        \
    __attribute__((constructor)) static void NAME##_register_layout(void) {   \
        layout_register(#NAME, NAME##_fields,                                 \
                        sizeof(NAME##_fields) / sizeof(NAME##_fields[0]),     \
                        sizeof(STRUCT));                                      \
    }

REGISTER_LAYOUT(sensor_reading, struct sensor_reading, SENSOR_FIELDS)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Note&lt;/span&gt;
  &lt;p&gt;
    &lt;code&gt;field_desc&lt;/code&gt; is declared identically in both C files rather than shared through a
    header, so that each one can be read on its own. In a real program it would live in a header, and
    &lt;code&gt;layout_register&lt;/code&gt; would be declared there too.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;xm-src-python&quot;&gt;read_layout.py &lt;span class=&quot;badge&quot;&gt;37 lines&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;
  The other side of the wall: no C compiler involved, no generated bindings, just the library and the
  standard library.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;read_layout.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import ctypes


class FieldDesc(ctypes.Structure):
    _fields_ = [
        (&quot;name&quot;, ctypes.c_char_p),
        (&quot;type&quot;, ctypes.c_int),
        (&quot;offset&quot;, ctypes.c_uint),
        (&quot;size&quot;, ctypes.c_uint),
    ]


lib = ctypes.CDLL(&quot;./libreflect.so&quot;)

lib.layout_lookup.argtypes = [ctypes.c_char_p, ctypes.POINTER(ctypes.c_size_t)]
lib.layout_lookup.restype = ctypes.POINTER(FieldDesc)
lib.layout_sizeof.argtypes = [ctypes.c_char_p]
lib.layout_sizeof.restype = ctypes.c_size_t

TAGS = {0: ctypes.c_int, 1: ctypes.c_float, 2: ctypes.c_double, 3: ctypes.c_void_p}

count = ctypes.c_size_t(0)
table = lib.layout_lookup(b&quot;sensor_reading&quot;, ctypes.byref(count))

fields = []
for i in range(count.value):
    f = table[i]
    print(f&quot;{f.name.decode():14} tag={f.type} offset={f.offset:&amp;lt;3} size={f.size}&quot;)
    fields.append((f.name.decode(), TAGS[f.type]))

Mirror = type(&quot;SensorReading&quot;, (ctypes.Structure,), {&quot;_fields_&quot;: fields})

print()
print(&quot;built mirror :&quot;, Mirror.__name__)
print(&quot;python sizeof:&quot;, ctypes.sizeof(Mirror))
print(&quot;c sizeof     :&quot;, lib.layout_sizeof(b&quot;sensor_reading&quot;))
print(&quot;mirror.timestamp offset:&quot;, Mirror.timestamp.offset)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Setting &lt;code&gt;argtypes&lt;/code&gt; and &lt;code&gt;restype&lt;/code&gt; is not optional decoration. Without them
  &lt;code&gt;ctypes&lt;/code&gt; assumes every argument and the return value are &lt;code&gt;int&lt;/code&gt;, which on
  x86-64 truncates pointers to 32 bits and produces a segfault that looks like it came from the C
  side.
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;script&gt;
(function () {
  var root = document.getElementById(&#39;xm-guide&#39;);
  if (!root || root.dataset.xmInit) return;
  root.dataset.xmInit = &#39;1&#39;;

  var C_KW = (&quot;auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|&quot;
            + &quot;goto|if|inline|int|long|register|restrict|return|short|signed|sizeof|static|struct|&quot;
            + &quot;switch|typedef|union|unsigned|void|volatile|while|_Bool|_Generic|_Static_assert|&quot;
            + &quot;size_t|NULL&quot;).split(&quot;|&quot;);

  var PY_KW = (&quot;False|None|True|and|as|assert|async|await|break|class|continue|def|del|elif|&quot;
             + &quot;else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|&quot;
             + &quot;pass|raise|return|try|while|with|yield|self|match|case&quot;).split(&quot;|&quot;);

  var cRe = new RegExp(
      &quot;(/\\*[\\s\\S]*?\\*/|//[^\\n]*)&quot;
    + &quot;|(\&quot;(?:\\\\.|[^\&quot;\\\\\\n])*\&quot;|&#39;(?:\\\\.|[^&#39;\\\\\\n])*&#39;)&quot;
    + &quot;|(^[ \\t]*#[ \\t]*[a-z_]+)&quot;
    + &quot;|\\b(&quot; + C_KW.join(&quot;|&quot;) + &quot;)\\b&quot;
    + &quot;|\\b(\\d[\\w.]*)\\b&quot;
    + &quot;|\\b([a-zA-Z_]\\w*)(?=\\s*\\()&quot;
    , &quot;gm&quot;);

  var pyRe = new RegExp(
      &quot;(#[^\\n]*)&quot;
    + &quot;|(\&quot;\&quot;\&quot;[\\s\\S]*?\&quot;\&quot;\&quot;|&#39;&#39;&#39;[\\s\\S]*?&#39;&#39;&#39;&quot;
    +   &quot;|\&quot;(?:\\\\.|[^\&quot;\\\\\\n])*\&quot;|&#39;(?:\\\\.|[^&#39;\\\\\\n])*&#39;)&quot;
    + &quot;|(@[\\w.]+)&quot;
    + &quot;|\\b(&quot; + PY_KW.join(&quot;|&quot;) + &quot;)\\b&quot;
    + &quot;|\\b(\\d[\\w.]*)\\b&quot;
    + &quot;|\\b([a-zA-Z_]\\w*)(?=\\()&quot;
    , &quot;g&quot;);

  var shRe = /(#[^\n]*)|(&quot;(?:\\.|[^&quot;\\])*&quot;|&#39;(?:\\.|[^&#39;\\])*&#39;)|(^|\s)(--?[\w-]+)/g;

  function esc(s) {
    return s.replace(/&amp;/g, &quot;&amp;amp;&quot;).replace(/&lt;/g, &quot;&amp;lt;&quot;).replace(/&gt;/g, &quot;&amp;gt;&quot;);
  }

  function highlightC(text) {
    return esc(text).replace(cRe, function (m, com, str, dir, kw, num, fn) {
      if (com) return &#39;&lt;span class=&quot;t-com&quot;&gt;&#39; + com + &quot;&lt;/span&gt;&quot;;
      if (str) return &#39;&lt;span class=&quot;t-str&quot;&gt;&#39; + str + &quot;&lt;/span&gt;&quot;;
      if (dir) return &#39;&lt;span class=&quot;t-dec&quot;&gt;&#39; + dir + &quot;&lt;/span&gt;&quot;;
      if (kw)  return &#39;&lt;span class=&quot;t-kw&quot;&gt;&#39;  + kw  + &quot;&lt;/span&gt;&quot;;
      if (num) return &#39;&lt;span class=&quot;t-num&quot;&gt;&#39; + num + &quot;&lt;/span&gt;&quot;;
      if (fn)  return &#39;&lt;span class=&quot;t-fn&quot;&gt;&#39;  + fn  + &quot;&lt;/span&gt;&quot;;
      return m;
    });
  }

  function highlightPy(text) {
    return esc(text).replace(pyRe, function (m, com, str, dec, kw, num, fn) {
      if (com) return &#39;&lt;span class=&quot;t-com&quot;&gt;&#39; + com + &quot;&lt;/span&gt;&quot;;
      if (str) return &#39;&lt;span class=&quot;t-str&quot;&gt;&#39; + str + &quot;&lt;/span&gt;&quot;;
      if (dec) return &#39;&lt;span class=&quot;t-dec&quot;&gt;&#39; + dec + &quot;&lt;/span&gt;&quot;;
      if (kw)  return &#39;&lt;span class=&quot;t-kw&quot;&gt;&#39;  + kw  + &quot;&lt;/span&gt;&quot;;
      if (num) return &#39;&lt;span class=&quot;t-num&quot;&gt;&#39; + num + &quot;&lt;/span&gt;&quot;;
      if (fn)  return &#39;&lt;span class=&quot;t-fn&quot;&gt;&#39;  + fn  + &quot;&lt;/span&gt;&quot;;
      return m;
    });
  }

  function highlightSh(text) {
    return esc(text).replace(shRe, function (m, com, str, pre, flag) {
      if (com)  return &#39;&lt;span class=&quot;t-com&quot;&gt;&#39; + com + &quot;&lt;/span&gt;&quot;;
      if (str)  return &#39;&lt;span class=&quot;t-str&quot;&gt;&#39; + str + &quot;&lt;/span&gt;&quot;;
      if (flag) return pre + &#39;&lt;span class=&quot;t-dec&quot;&gt;&#39; + flag + &quot;&lt;/span&gt;&quot;;
      return m;
    });
  }

  function highlightOut(text) {
    return esc(text)
      .replace(/^(.*\berror:.*)$/gm, &#39;&lt;span class=&quot;t-fail&quot;&gt;$1&lt;/span&gt;&#39;)
      .replace(/^(.*in expansion of macro.*)$/gm, &#39;&lt;span class=&quot;t-com&quot;&gt;$1&lt;/span&gt;&#39;);
  }

  root.querySelectorAll(&quot;pre code&quot;).forEach(function (el) {
    var raw = el.textContent;
    el.dataset.raw = raw;
    if (el.classList.contains(&quot;out&quot;))     el.innerHTML = highlightOut(raw);
    else if (el.classList.contains(&quot;c&quot;))  el.innerHTML = highlightC(raw);
    else if (el.classList.contains(&quot;py&quot;)) el.innerHTML = highlightPy(raw);
    else                                  el.innerHTML = highlightSh(raw);
  });

  root.querySelectorAll(&quot;.copy&quot;).forEach(function (btn) {
    btn.addEventListener(&quot;click&quot;, function (ev) {
      ev.preventDefault();
      var code = btn.closest(&quot;.snippet&quot;).querySelector(&quot;code&quot;);
      var text = code.dataset.raw || code.textContent;
      var done = function () {
        btn.textContent = &quot;copied&quot;;
        btn.classList.add(&quot;ok&quot;);
        setTimeout(function () { btn.textContent = &quot;copy&quot;; btn.classList.remove(&quot;ok&quot;); }, 1200);
      };
      if (navigator.clipboard &amp;&amp; navigator.clipboard.writeText) {
        navigator.clipboard.writeText(text).then(done, function () {});
      } else {
        var ta = document.createElement(&quot;textarea&quot;);
        ta.value = text; ta.style.position = &quot;fixed&quot;; ta.style.opacity = &quot;0&quot;;
        document.body.appendChild(ta); ta.select();
        try { document.execCommand(&quot;copy&quot;); done(); } catch (e) {}
        document.body.removeChild(ta);
      }
    });
  });
})();
&lt;/script&gt;
</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/4011059620180217256/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2026/08/the-x-macro-from-define-to-runtime.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/4011059620180217256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/4011059620180217256'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2026/08/the-x-macro-from-define-to-runtime.html' title='The X-macro, from #define to runtime reflection'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-7710306273686310939</id><published>2026-07-29T00:11:03.409-07:00</published><updated>2026-07-29T00:11:03.409-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="dataclasses"/><category scheme="http://www.blogger.com/atom/ns#" term="default arguments"/><category scheme="http://www.blogger.com/atom/ns#" term="mutable defaults"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="python3"/><category scheme="http://www.blogger.com/atom/ns#" term="Ruff"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial"/><title type='text'>The list that remembers: mutable default arguments in Python</title><content type='html'>&lt;style&gt;
/* ------------------------------------------------------------------
   study.marearts.com article body — mutable-defaults guide.
   Every selector is scoped under #md-guide so nothing leaks onto the
   theme chrome (post title, date header, sidebar, comments).

   Palette is derived from the blog&#39;s own Awesome Inc. dark theme so
   the post reads as native rather than as an embedded card:
     page background #2d3037   body text #cccccc
     links #f1c232 (gold)      link hover / post titles #29aae1
     date headers #8ce1f5
   There is no light variant on purpose. Blogger has no theme-toggle
   attribute, so a light default would be the only thing that ever
   rendered — which is exactly how this post shipped white the first
   time. Panels are graded around #2d3037 instead of using an absolute
   background, so the article never fights the page it sits on.
   ------------------------------------------------------------------ */
#md-guide{
  --bg:transparent; --panel:#34383f; --panel2:#3b4048; --line:#454b54;
  --fg:#d4d7dc; --fg-strong:#eef0f3; --fg-dim:#a3a9b2; --fg-faint:#848b95;
  --accent:#f1c232; --accent-2:#29aae1; --warn:#ffb454; --danger:#ff7a84;
  --code-bg:#23262c; --code-fg:#d4d7dc;
  --kw:#c792ea; --str:#c3e88d; --com:#828a94; --num:#f78c6c;
  --dec:#ffcb6b; --fn:#82aaff; --inline-code:#e6d3ff;
  --pass:#4fd6b0; --fail:#ff7a84;
  --mono:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,&quot;JetBrains Mono&quot;,Menlo,Consolas,&quot;Liberation Mono&quot;,monospace;
  --sans:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif;
}
#md-guide, #md-guide *{box-sizing:border-box}
#md-guide{
  background:var(--bg); color:var(--fg);
  font-family:var(--sans); font-size:16px; line-height:1.7;
  -webkit-font-smoothing:antialiased;
  /* No frame: the theme already pads the post column, so a border plus
     its own background would read as a widget pasted onto the page. */
  padding:2px 0 44px; border:0; border-radius:0;
}
#md-guide .wrap{max-width:1000px;margin:0 auto;min-width:0}

/* headings */
#md-guide h1{font-size:38px;line-height:1.18;letter-spacing:-.8px;margin:0 0 12px;color:var(--fg)}
#md-guide .lede{font-size:18px;color:var(--fg-dim);max-width:70ch;margin:0 0 8px}
/* font-family is restated on h2/h4: the theme styles bare `h2` and `h4`
   with a `font:` shorthand, which sets Arial and beats plain inheritance
   from #md-guide. */
#md-guide h2{
  font-family:var(--sans);line-height:inherit;
  font-size:15px;text-transform:uppercase;letter-spacing:.1em;color:var(--accent-2);
  margin:64px 0 6px;padding-top:22px;border-top:1px solid var(--line);font-weight:700;
  scroll-margin-top:16px;
}
/* line-height is pinned to inherit rather than left undeclared: the
   site-wide tone CSS sets a heading line-height, and an undeclared
   property is the one thing an opt-out guard cannot protect if that
   guard ever fails to apply. `inherit` reproduces exactly what these
   headings render at today. */
#md-guide h3{font-size:25px;line-height:inherit;letter-spacing:-.4px;margin:38px 0 10px;color:var(--fg-strong);scroll-margin-top:20px}
#md-guide h4{font-family:var(--sans);font-size:16.5px;line-height:inherit;font-weight:600;margin:26px 0 8px;color:var(--fg-strong)}
#md-guide p{max-width:74ch;margin:12px 0}
#md-guide ul, #md-guide ol{max-width:74ch;padding-left:22px;margin:10px 0}
/* The theme&#39;s `.main-inner .widget ul{list-style:none}` strips markers from
   every list in the post body, so the markers are put back explicitly. */
#md-guide ul{list-style:disc}
#md-guide ol{list-style:decimal}
#md-guide li{margin:6px 0}
#md-guide a{color:var(--accent)}
#md-guide code{
  font-family:var(--mono);font-size:.875em;background:var(--panel2);
  padding:2px 6px;border-radius:4px;border:1px solid var(--line);color:var(--inline-code);
}
#md-guide strong{color:var(--fg-strong);font-weight:650}
#md-guide em{font-style:italic}

/* code blocks */
#md-guide .snippet{margin:18px 0;border:1px solid var(--line);border-radius:10px;overflow:hidden;background:var(--code-bg)}
#md-guide .snippet-head{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:7px 12px;background:var(--panel);border-bottom:1px solid var(--line);
}
#md-guide .snippet-name{font-family:var(--mono);font-size:12px;color:var(--fg-faint)}
#md-guide .snippet-name b{color:var(--fg-dim);font-weight:600}
#md-guide .copy{
  background:transparent;border:1px solid var(--line);color:var(--fg-faint);
  font-size:11px;padding:3px 9px;border-radius:5px;cursor:pointer;font-family:var(--sans);line-height:1.4;
}
#md-guide .copy:hover{color:var(--fg);border-color:var(--fg-faint)}
#md-guide .copy.ok{color:var(--accent-2);border-color:var(--accent-2)}
#md-guide pre{
  margin:0;padding:14px 16px;overflow-x:auto;background:var(--code-bg);
  font-family:var(--mono);font-size:13.5px;line-height:1.62;color:var(--code-fg);
  border:0;border-radius:0;
}
#md-guide pre code{background:none;border:0;padding:0;font-size:inherit;color:inherit}
#md-guide pre::-webkit-scrollbar{height:9px}
#md-guide pre::-webkit-scrollbar-thumb{background:var(--line);border-radius:5px}
#md-guide .out pre{color:var(--fg-dim)}
#md-guide .out .snippet-name b{color:var(--warn)}

/* syntax colors */
#md-guide .t-kw{color:var(--kw)}
#md-guide .t-str{color:var(--str)}
#md-guide .t-com{color:var(--com);font-style:italic}
#md-guide .t-num{color:var(--num)}
#md-guide .t-dec{color:var(--dec)}
#md-guide .t-fn{color:var(--fn)}
#md-guide .t-pass{color:var(--pass)}
#md-guide .t-fail{color:var(--fail)}

/* callouts */
/* Info reads cyan, not gold: gold is the theme&#39;s link colour and would
   collide with .warn&#39;s amber at these low alphas. */
#md-guide .note{
  border-left:3px solid var(--accent-2);background:rgba(41,170,225,.09);
  padding:12px 16px;margin:18px 0;border-radius:0 8px 8px 0;max-width:74ch;
}
#md-guide .note.warn{border-color:var(--warn);background:rgba(255,180,84,.08)}
#md-guide .note.trap{border-color:var(--danger);background:rgba(255,122,132,.08)}
#md-guide .note .tag{
  display:block;font-size:10.5px;text-transform:uppercase;letter-spacing:.1em;
  font-weight:700;color:var(--accent-2);margin-bottom:3px;
}
#md-guide .note.warn .tag{color:var(--warn)}
#md-guide .note.trap .tag{color:var(--danger)}
#md-guide .note p{margin:5px 0}
#md-guide .note .tag code{
  background:none !important;border:0 !important;padding:0 !important;
  color:inherit !important;font-size:1em !important;
}

/* tables */
#md-guide .table-wrap{overflow-x:auto;margin:18px 0}
#md-guide table{border-collapse:collapse;width:100%;margin:0;font-size:14.5px;background:none}
#md-guide th, #md-guide td{text-align:left;padding:9px 13px;border:0;border-bottom:1px solid var(--line);vertical-align:top}
#md-guide th{color:var(--fg-faint);font-size:11.5px;text-transform:uppercase;letter-spacing:.07em;font-weight:700}
#md-guide td code{font-size:.9em}
#md-guide tbody tr:hover{background:var(--panel)}

/* furniture */
#md-guide .kicker{
  font-size:12px;font-weight:700;letter-spacing:.13em;text-transform:uppercase;
  color:var(--accent-2);margin-bottom:14px;
}
#md-guide .rule{height:1px;background:var(--line);margin:30px 0 4px;max-width:74ch}

#md-guide .toc{
  border:1px solid var(--line);border-radius:12px;background:var(--panel);
  padding:20px 24px;margin:34px 0 10px;max-width:74ch;
}
#md-guide .toc h4{margin:0 0 14px;font-size:13px;text-transform:uppercase;letter-spacing:.1em;color:var(--fg-faint)}
#md-guide .toc ol{margin:0;padding-left:20px;max-width:none}
#md-guide .toc &gt; ol &gt; li{margin:14px 0}
#md-guide .toc &gt; ol &gt; li &gt; a{text-decoration:none;font-weight:650;font-size:16.5px}
#md-guide .toc a{text-decoration:none;color:var(--accent)}
#md-guide .toc a:hover{text-decoration:underline}
#md-guide .toc span{color:var(--fg-faint);font-weight:400;font-size:14px}
#md-guide .toc ul{
  list-style:none;margin:7px 0 0;padding-left:0;max-width:none;
  display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:1px 18px;
}
#md-guide .toc ul li{margin:0}
#md-guide .toc ul a{font-size:14px;color:var(--fg-dim)}
#md-guide .toc ul a:hover{color:var(--accent)}

#md-guide .takeaway{
  border:1px solid var(--line);border-left:3px solid var(--accent-2);
  border-radius:0 12px 12px 0;background:var(--panel);
  padding:18px 22px;margin:26px 0;max-width:74ch;
}
#md-guide .takeaway h4{margin:0 0 10px;font-size:14px;text-transform:uppercase;letter-spacing:.08em;color:var(--accent-2)}
#md-guide .takeaway ul{margin:0;padding-left:20px}

/* Always stacked, never side by side: the theme&#39;s centre column is ~545px
   of content, so two code panes would each get ~265px and clip mid-token
   regardless of viewport width (the 900px media query never fires). */
#md-guide .grid2{display:grid;grid-template-columns:1fr;gap:16px}
#md-guide .grid2 .snippet{margin:0;min-width:0}
#md-guide .pt-badge{
  display:inline-block;font-size:11px;padding:2px 8px;border-radius:20px;
  border:1px solid var(--line);color:var(--fg-faint);margin-left:8px;vertical-align:middle;
  letter-spacing:normal;line-height:1.4;text-align:left;background:none;
}
#md-guide .kbd{
  font-family:var(--mono);font-size:12px;background:var(--panel2);border:1px solid var(--line);
  border-bottom-width:2px;border-radius:4px;padding:1px 6px;
}
#md-guide .foot{
  margin-top:70px;padding-top:20px;border-top:1px solid var(--line);
  color:var(--fg-faint);font-size:13px;
}
/* ------------------------------------------------------------------
   The Blogger theme re-colours bare descendants of the post container:
   body{color:#cccccc}, .post-body ul li{color:#cccccc},
   .main-inner .widget ul li{color:#ffffff}, a:link{color:#f1c232},
   h2{color:#8ce1f5}, h4{color:#29aae1}. Re-assert the article palette
   here — #md-guide carries an id, so it wins on specificity, and the
   !important guards cover the handful of host rules that use it too.
   Kept deliberately narrow: anything with a per-component colour of its
   own (.toc h4, .takeaway h4, .note .tag) must not be caught by these.
   ------------------------------------------------------------------ */
#md-guide h1, #md-guide h3{color:var(--fg-strong) !important}
#md-guide h2{color:var(--accent-2) !important}
#md-guide p{color:var(--fg) !important}
#md-guide li{color:var(--fg) !important;padding:0;border:0}
#md-guide .lede{color:var(--fg-dim) !important}
#md-guide strong{color:var(--fg-strong) !important}
#md-guide a, #md-guide .toc a{color:var(--accent) !important}
#md-guide .toc ul a{color:var(--fg-dim) !important}
#md-guide a:hover, #md-guide .toc ul a:hover{color:var(--accent) !important}
#md-guide code{background:var(--panel2) !important;color:var(--inline-code) !important}
#md-guide pre code{background:none !important;color:var(--code-fg) !important}
#md-guide table{background:none !important;table-layout:auto !important}
#md-guide th{background:var(--panel2) !important;color:var(--fg-faint) !important}
#md-guide td{color:var(--fg) !important}
#md-guide th, #md-guide td{border-color:var(--line) !important}
#md-guide tbody tr:hover{background:var(--panel) !important}

@media screen and (max-width:900px){
  #md-guide{padding:2px 0 36px}
  #md-guide table{font-size:13.5px}
}
@media screen and (max-width:640px){
  #md-guide .toc ul{grid-template-columns:1fr}
}

/* ------------------------------------------------------------------
   Components used by this post only.
   ------------------------------------------------------------------ */

/* Flow diagram for the shared-default mechanism. A bare `pre` on purpose:
   the highlighter only touches `pre code`, so omitting the `code` element
   is what stops it from eating the hl- spans. The block scrolls rather
   than wraps — every line is aligned by character column, so a wrap would
   scramble the callouts. 11.5px because the widest annotation line is 70
   columns, which is 1–2px too wide for the 543px post column at 12px. */
#md-guide .diagram{
  margin:22px 0;padding:18px 20px;border:1px dashed var(--line);border-radius:10px;
  background:var(--code-bg);overflow-x:auto;
}
#md-guide .diagram pre{
  margin:0;padding:0;background:none;border:0;border-radius:0;
  font-family:var(--mono);font-size:11.5px;line-height:1.75;
  color:var(--fg-dim);white-space:pre;overflow:visible;
}
#md-guide .diagram .hl-a{color:var(--fn)}
#md-guide .diagram .hl-b{color:var(--dec)}
#md-guide .diagram .hl-c{color:var(--pass)}
#md-guide .diagram .hl-d{color:var(--danger)}
#md-guide .diagram::-webkit-scrollbar{height:9px}
#md-guide .diagram::-webkit-scrollbar-thumb{background:var(--line);border-radius:5px}

/* safe / unsafe verdict column in the part-6 table. The theme-hardening
   block above sets `td{color:... !important}`, so these need !important
   too — an important declaration beats a more specific plain one. */
#md-guide td.yes{color:var(--pass) !important;font-weight:650}
#md-guide td.no{color:var(--danger) !important;font-weight:650}

/* Lint-rule slugs in the part-7 table. */
#md-guide .sub{font-family:var(--mono);font-size:12px;color:var(--fg-faint)}

/* broken / correct labels on the paired snippets in part 4. */
#md-guide .snippet-name.bad b{color:var(--danger)}
#md-guide .snippet-name.good b{color:var(--pass)}
&lt;/style&gt;

&lt;div id=&quot;md-guide&quot; data-tone=&quot;self&quot;&gt;
&lt;div class=&quot;wrap&quot;&gt;

&lt;div class=&quot;kicker&quot;&gt;Python · Language&lt;/div&gt;
&lt;p class=&quot;lede&quot;&gt;
  &lt;code&gt;def append_to(item, target=[])&lt;/code&gt; looks like it starts from an empty list every time. It does
  not. One list is created when the &lt;code&gt;def&lt;/code&gt; statement runs, and every call for the rest of the
  program&#39;s life shares it.
&lt;/p&gt;

&lt;div class=&quot;rule&quot;&gt;&lt;/div&gt;

&lt;p&gt;
  This is the most famous gotcha in Python, and it is famous for a reason: the code is short, the
  intent is obvious, and it is wrong. There is no error, no warning at runtime, and the symptom
  depends on what earlier callers happened to do — which makes it genuinely hard to track down when
  you meet it in a real codebase rather than in a blog post.
&lt;/p&gt;
&lt;p&gt;
  It is also a two-minute fix once you know the rule. Every output below is copied from a real run on
  CPython 3.10.
&lt;/p&gt;

&lt;div class=&quot;toc&quot;&gt;
  &lt;h4&gt;Contents&lt;/h4&gt;
  &lt;ol&gt;
    &lt;li&gt;&lt;a href=&quot;#md-bug&quot;&gt;The bug&lt;/a&gt; &lt;span&gt;— three calls, one list&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#md-why&quot;&gt;Why it happens&lt;/a&gt; &lt;span&gt;— the default lives on the function object&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#md-real&quot;&gt;The shape you actually hit&lt;/a&gt; &lt;span&gt;— two carts, one basket&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#md-fix&quot;&gt;The fix&lt;/a&gt; &lt;span&gt;— the &lt;code&gt;None&lt;/code&gt; sentinel&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#md-variants&quot;&gt;Variations and near-misses&lt;/a&gt; &lt;span&gt;— &lt;code&gt;or []&lt;/code&gt;, sentinel objects, dataclasses&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#md-safe&quot;&gt;What is safe, what is not&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#md-lint&quot;&gt;Letting a linter catch it&lt;/a&gt; &lt;span&gt;— B006 vs B008&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#md-cheatsheet&quot;&gt;Cheat sheet&lt;/a&gt;&lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;


&lt;h2&gt;Part 1 · The bug&lt;/h2&gt;

&lt;h3 id=&quot;md-bug&quot;&gt;Three calls, one list&lt;/h3&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;append.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def append_to(item, target=[]):
    target.append(item)
    return target

print(append_to(1))
print(append_to(2))
print(append_to(3))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python append.py&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;[1]
[1, 2]        ← expected [2]
[1, 2, 3]     ← expected [3]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The first call behaves. The second reveals that &lt;code&gt;target&lt;/code&gt; was not empty when the call started.
  The list is accumulating across calls, because it is the same list each time.
&lt;/p&gt;


&lt;h2&gt;Part 2 · Why it happens&lt;/h2&gt;

&lt;h3 id=&quot;md-why&quot;&gt;The default lives on the function object&lt;/h3&gt;
&lt;p&gt;
  A default argument expression is evaluated &lt;strong&gt;once, when the &lt;code&gt;def&lt;/code&gt; statement executes&lt;/strong&gt; —
  not on each call. The resulting object is stored on the function and handed to every call that omits
  the argument. So &lt;code&gt;[]&lt;/code&gt; is not an instruction to make a fresh list; it is one list, made once.
&lt;/p&gt;

&lt;div class=&quot;diagram&quot;&gt;
&lt;pre&gt;def append_to(item, target=&lt;span class=&quot;hl-d&quot;&gt;[]&lt;/span&gt;):
                           &lt;span class=&quot;hl-d&quot;&gt;~~&lt;/span&gt;
                           &lt;span class=&quot;hl-b&quot;&gt;evaluated once, at def time —&lt;/span&gt;
                           &lt;span class=&quot;hl-b&quot;&gt;the resulting list is stored on the function&lt;/span&gt;

   &lt;span class=&quot;hl-a&quot;&gt;call 1&lt;/span&gt; ──┐
   &lt;span class=&quot;hl-a&quot;&gt;call 2&lt;/span&gt; ──┼──▶ &lt;span class=&quot;hl-c&quot;&gt;that one list&lt;/span&gt; ──▶ [1] ─▶ [1, 2] ─▶ [1, 2, 3]
   &lt;span class=&quot;hl-a&quot;&gt;call 3&lt;/span&gt; ──┘    &lt;span class=&quot;hl-c&quot;&gt;(never replaced, never reset)&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You do not have to take this on faith. The list is reachable through &lt;code&gt;__defaults__&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;show_default.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def append_to(item, target=[]):
    target.append(item)
    return target

print(append_to.__defaults__)
append_to(1)
print(append_to.__defaults__)
append_to(2)
print(append_to.__defaults__)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python show_default.py&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;([],)
([1],)        ← the list attached to the function has changed
([1, 2],)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  That is the whole story. The default is a piece of state hanging off the function, and
  &lt;code&gt;target.append(item)&lt;/code&gt; mutates it. Nothing resets it between calls, because nothing was ever
  going to.
&lt;/p&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Note what is &lt;em&gt;not&lt;/em&gt; the problem&lt;/span&gt;
  &lt;p&gt;
    Rebinding is fine. &lt;code&gt;def f(n=0): n += 1&lt;/code&gt; cannot leak, because &lt;code&gt;n += 1&lt;/code&gt; on an integer
    creates a new object and points the local name at it — the stored default is untouched. The bug
    needs &lt;em&gt;mutation&lt;/em&gt; of the default object, which is why only mutable types are affected.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h2&gt;Part 3 · The shape you actually hit&lt;/h2&gt;

&lt;h3 id=&quot;md-real&quot;&gt;Two carts, one basket&lt;/h3&gt;
&lt;p&gt;
  Nobody writes &lt;code&gt;append_to&lt;/code&gt; in production. What people do write is a constructor with an empty
  collection as its default — and then the shared object is shared between &lt;em&gt;instances&lt;/em&gt;:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;cart.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;class Cart:
    def __init__(self, items=[]):
        self.items = items

a = Cart()
b = Cart()
a.items.append(&quot;apple&quot;)

print(b.items)
print(a.items is b.items)
print(Cart.__init__.__defaults__)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python cart.py&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;[&#39;apple&#39;]              ← a different cart, with someone else&#39;s apple in it
True                   ← it was the same list all along
([&#39;apple&#39;],)           ← and it is living on Cart.__init__&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Two independent objects, one shared basket. Worse, the default is attached to the &lt;em&gt;class&lt;/em&gt;, so the
  contamination outlives both instances and reaches every &lt;code&gt;Cart()&lt;/code&gt; created later in the process.
&lt;/p&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Why it is hard to debug&lt;/span&gt;
  &lt;p&gt;
    The reproduction condition is &quot;what did some earlier caller put in there&quot;, which is not visible
    from the failing line, is not in the traceback, and often depends on test ordering. A unit test
    that constructs one &lt;code&gt;Cart&lt;/code&gt; passes. The suite fails only when another test ran first — and
    then passes again when you run it alone to investigate.
  &lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;
  Passing the argument explicitly sidesteps it, which is part of why the bug hides so well: the code
  path that everyone tests is usually the one that supplies a value.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;explicit argument, no sharing&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;c = Cart(items=[])       # a genuinely new list
c.items.append(&quot;pear&quot;)
print(c.items, a.items)  # [&#39;pear&#39;] [&#39;apple&#39;]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h2&gt;Part 4 · The fix&lt;/h2&gt;

&lt;h3 id=&quot;md-fix&quot;&gt;The &lt;code&gt;None&lt;/code&gt; sentinel&lt;/h3&gt;
&lt;p&gt;
  Make the default an immutable marker, and build the real object inside the body. The construction
  then happens per call, which is what you wanted in the first place.
&lt;/p&gt;

&lt;div class=&quot;grid2&quot;&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name bad&quot;&gt;&lt;b&gt;broken&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def append_to(item, target=[]):
    target.append(item)
    return target


class Cart:
    def __init__(self, items=[]):
        self.items = items&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name good&quot;&gt;&lt;b&gt;correct&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def append_to(item, target=None):
    if target is None:
        target = []
    target.append(item)
    return target

class Cart:
    def __init__(self, items=None):
        self.items = [] if items is None else items&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;the fixed version&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;append_to(1) → [1]
append_to(2) → [2]
append_to(3) → [3]
append_to.__defaults__ → (None,)      ← nothing to accumulate into&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  &lt;code&gt;None&lt;/code&gt; is a singleton and immutable, so storing it on the function is harmless. The important
  part is the &lt;code&gt;is None&lt;/code&gt; check: it is what turns &quot;one object, made once&quot; into &quot;a new object per
  call&quot;.
&lt;/p&gt;

&lt;h4&gt;Type it honestly&lt;/h4&gt;
&lt;p&gt;
  If the codebase is annotated, the parameter now genuinely accepts &lt;code&gt;None&lt;/code&gt;, and the annotation
  should say so:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;annotated&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def append_to(item: int, target: list[int] | None = None) -&amp;gt; list[int]:
    if target is None:
        target = []
    target.append(item)
    return target&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  On Python 3.9 and earlier, write &lt;code&gt;Optional[List[int]]&lt;/code&gt; from &lt;code&gt;typing&lt;/code&gt;, or add
  &lt;code&gt;from __future__ import annotations&lt;/code&gt; to use the &lt;code&gt;|&lt;/code&gt; syntax anyway.
&lt;/p&gt;


&lt;h2&gt;Part 5 · Variations and near-misses&lt;/h2&gt;

&lt;h3 id=&quot;md-variants&quot;&gt;Three things worth knowing&lt;/h3&gt;

&lt;h4&gt;&lt;code&gt;or []&lt;/code&gt; is shorter and subtly different&lt;/h4&gt;
&lt;p&gt;
  &lt;code&gt;target = target or []&lt;/code&gt; is a common abbreviation. It fixes the sharing, but it also replaces any
  &lt;em&gt;falsy&lt;/em&gt; argument the caller passed — including an empty list they expected you to fill:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;or_trap.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def with_or(item, target=None):
    target = target or []          # empty list from the caller gets discarded
    target.append(item)
    return target

def with_is_none(item, target=None):
    target = [] if target is None else target
    target.append(item)
    return target

mine = []
with_or(&quot;x&quot;, mine)
print(&quot;or      →&quot;, mine)

mine = []
with_is_none(&quot;x&quot;, mine)
print(&quot;is None →&quot;, mine)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python or_trap.py&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;or      → []            ← the caller&#39;s list was never touched
is None → [&#39;x&#39;]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The &lt;code&gt;or&lt;/code&gt; version quietly appended to a throwaway list and the caller&#39;s stayed empty. Same class
  of confusion for &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;&quot;&quot;&lt;/code&gt; and &lt;code&gt;False&lt;/code&gt;. Prefer &lt;code&gt;is None&lt;/code&gt;: it tests for
  exactly the thing you meant.
&lt;/p&gt;

&lt;h4&gt;When &lt;code&gt;None&lt;/code&gt; is itself a valid value&lt;/h4&gt;
&lt;p&gt;
  Sometimes &lt;code&gt;None&lt;/code&gt; is meaningful data and you still need to distinguish &quot;not supplied&quot;. Use a
  private sentinel object:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;sentinel object&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;_MISSING = object()

def fetch(key, default=_MISSING):
    if default is _MISSING:
        raise KeyError(key)     # no default supplied
    return default              # default supplied — possibly None

print(fetch(&quot;k&quot;, None))         # None
fetch(&quot;k&quot;)                      # KeyError: &#39;k&#39;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This is how &lt;code&gt;dict.pop&lt;/code&gt; and friends behave, and why they can tell those two cases apart.&lt;/p&gt;

&lt;h4&gt;Dataclasses refuse to let you do it&lt;/h4&gt;
&lt;p&gt;
  &lt;code&gt;@dataclass&lt;/code&gt; knows about this bug and raises at class-creation time rather than letting you ship
  it:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;bad_dc.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;from dataclasses import dataclass

@dataclass
class Bad:
    items: list = []&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python bad_dc.py&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;ValueError: mutable default &amp;lt;class &#39;list&#39;&amp;gt; for field items is not allowed: use default_factory&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Note that this fires at import, before any instance exists — the decorator inspects the defaults
  while building the class. The sanctioned form is a factory, called once per instance:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;good_dc.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;from dataclasses import dataclass, field

@dataclass
class Good:
    items: list = field(default_factory=list)

g1, g2 = Good(), Good()
g1.items.append(&quot;apple&quot;)
print(g1.items, g2.items, g1.items is g2.items)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python good_dc.py&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;[&#39;apple&#39;] [] False&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  &lt;code&gt;default_factory&lt;/code&gt; is the &quot;call it per invocation&quot; idea made explicit — the same thing the
  &lt;code&gt;None&lt;/code&gt; check does by hand.
&lt;/p&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;When the sharing is deliberate&lt;/span&gt;
  &lt;p&gt;
    A mutable default occasionally &lt;em&gt;is&lt;/em&gt; the point — a memo dict that must persist across calls. It
    works, but it hides a piece of global state in a signature where no reader expects it. Use a
    module-level variable or &lt;code&gt;functools.cache&lt;/code&gt; instead; both announce themselves.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h2&gt;Part 6 · What is safe, what is not&lt;/h2&gt;

&lt;h3 id=&quot;md-safe&quot;&gt;A quick classification&lt;/h3&gt;
&lt;p&gt;
  The rule follows directly from the mechanism: the stored object is only a hazard if something can
  mutate it.
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Default&lt;/th&gt;&lt;th&gt;Safe?&lt;/th&gt;&lt;th&gt;Because&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;None&lt;/code&gt;, &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;&quot;&quot;&lt;/code&gt;, &lt;code&gt;True&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;yes&lt;/td&gt;&lt;td&gt;Immutable; cannot be changed in place&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;()&lt;/code&gt;, &lt;code&gt;frozenset()&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;yes&lt;/td&gt;&lt;td&gt;Immutable containers&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;A module-level constant&lt;/td&gt;&lt;td class=&quot;yes&quot;&gt;usually&lt;/td&gt;&lt;td&gt;Safe if genuinely immutable — a shared &lt;code&gt;CONFIG&lt;/code&gt; dict is not&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;[]&lt;/code&gt;, &lt;code&gt;{}&lt;/code&gt;, &lt;code&gt;set()&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;no&lt;/td&gt;&lt;td&gt;One object, mutated in place by every caller&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;A custom class instance&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;no&lt;/td&gt;&lt;td&gt;One instance shared across calls&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;datetime.now()&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;no&quot;&gt;no&lt;/td&gt;&lt;td&gt;Not mutation — it freezes at import time&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;That last row is a different bug wearing the same clothes, and it is worth seeing on its own:&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;frozen at import, not &quot;now&quot;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import time
from datetime import datetime

def stamped(when=datetime.now()):
    return when

t1 = stamped()
time.sleep(0.05)
t2 = stamped()
print(t1 == t2)          # True — both are the moment the module was imported&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  A long-running service will hand out the same timestamp for days. The test suite will not notice,
  because it imports and calls within the same instant.
&lt;/p&gt;


&lt;h2&gt;Part 7 · Letting a linter catch it&lt;/h2&gt;

&lt;h3 id=&quot;md-lint&quot;&gt;B006 and B008&lt;/h3&gt;
&lt;p&gt;
  You should never be finding this by reading. &lt;code&gt;flake8-bugbear&lt;/code&gt; — bundled into Ruff as the
  &lt;code&gt;B&lt;/code&gt; rules — catches both variants:
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Rule&lt;/th&gt;&lt;th&gt;Catches&lt;/th&gt;&lt;th&gt;Example&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code&gt;B006&lt;/code&gt;&lt;br&gt;&lt;span class=&quot;sub&quot;&gt;mutable-argument-default&lt;/span&gt;&lt;/td&gt;
      &lt;td&gt;A mutable &lt;em&gt;literal or constructor&lt;/em&gt; as a default — the bug in this post&lt;/td&gt;
      &lt;td&gt;&lt;code&gt;def f(x=[])&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code&gt;B008&lt;/code&gt;&lt;br&gt;&lt;span class=&quot;sub&quot;&gt;function-call-in-default-argument&lt;/span&gt;&lt;/td&gt;
      &lt;td&gt;Any &lt;em&gt;function call&lt;/em&gt; in a default, evaluated once at import&lt;/td&gt;
      &lt;td&gt;&lt;code&gt;def f(t=datetime.now())&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;pyproject.toml&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;toml&quot;&gt;[tool.ruff.lint]
extend-select = [&quot;B&quot;]      # all of flake8-bugbear, B006 and B008 included&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; ruff check --select B006,B008 --output-format concise .&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;app.py:4:28: B006 Do not use mutable data structures for argument defaults
app.py:9:21: B006 Do not use mutable data structures for argument defaults
app.py:13:18: B008 Do not perform function call `datetime.now` in argument defaults;
              instead, perform the call within the function, or read the default from
              a module-level singleton variable
app.py:18:30: B006 Do not use mutable data structures for argument defaults
Found 4 errors.&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;The two rules get conflated&lt;/span&gt;
  &lt;p&gt;
    &lt;code&gt;target=[]&lt;/code&gt; is &lt;strong&gt;B006&lt;/strong&gt;, not B008. The advice &quot;perform the call within the function&quot;
    belongs to B008&#39;s message — apt for &lt;code&gt;datetime.now()&lt;/code&gt;, but a list literal is not a call. The
    remedy happens to be the same shape in both cases: move the work inside the body.
  &lt;/p&gt;
&lt;/div&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;B008 has real exceptions&lt;/span&gt;
  &lt;p&gt;
    Some frameworks give a call in the default an actual meaning — FastAPI&#39;s &lt;code&gt;Depends()&lt;/code&gt; is the
    standard example. Ruff&#39;s &lt;code&gt;extend-immutable-calls&lt;/code&gt; exists for these; list the specific callable
    rather than disabling the rule.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h2&gt;Wrapping up&lt;/h2&gt;

&lt;h3 id=&quot;md-cheatsheet&quot;&gt;Cheat sheet&lt;/h3&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Instead of&lt;/th&gt;&lt;th&gt;Write&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;def f(x=[])&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;def f(x=None)&lt;/code&gt; then &lt;code&gt;if x is None: x = []&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;def f(x={})&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;def f(x=None)&lt;/code&gt; then &lt;code&gt;x = {} if x is None else x&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;def f(t=datetime.now())&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;def f(t=None)&lt;/code&gt; then &lt;code&gt;t = t or datetime.now()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;x = x or []&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;x = [] if x is None else x&lt;/code&gt; — unless discarding falsy input is intended&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;items: list = []&lt;/code&gt; in a dataclass&lt;/td&gt;&lt;td&gt;&lt;code&gt;items: list = field(default_factory=list)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;A memo dict in the signature&lt;/td&gt;&lt;td&gt;A module-level variable, or &lt;code&gt;functools.cache&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;div class=&quot;takeaway&quot;&gt;
  &lt;h4&gt;The short list&lt;/h4&gt;
  &lt;ul&gt;
    &lt;li&gt;
      &lt;strong&gt;Defaults are evaluated once, at &lt;code&gt;def&lt;/code&gt; time.&lt;/strong&gt; The object is stored on the
      function and reused forever; &lt;code&gt;[]&lt;/code&gt; means one list, not a fresh one per call.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;You can watch it happen&lt;/strong&gt; in &lt;code&gt;f.__defaults__&lt;/code&gt; — the list grows in place.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;The damage scales in constructors.&lt;/strong&gt; A default &lt;code&gt;items=[]&lt;/code&gt; in
      &lt;code&gt;__init__&lt;/code&gt; is shared by every instance the process ever creates.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Default to &lt;code&gt;None&lt;/code&gt; and build inside the body.&lt;/strong&gt; Test with &lt;code&gt;is None&lt;/code&gt;,
      not &lt;code&gt;or&lt;/code&gt;, so a caller&#39;s empty list is still theirs.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Enable &lt;code&gt;B&lt;/code&gt; in Ruff.&lt;/strong&gt; B006 and B008 find every instance in seconds, and
      neither bug ever announces itself at runtime.
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;

&lt;h3 id=&quot;md-further&quot;&gt;Further reading&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.python.org/3/reference/compound_stmts.html#function-definitions&quot;&gt;Python reference — function definitions&lt;/a&gt;: the paragraph that states defaults are evaluated once, and warns about this exact case&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.python.org/3/faq/programming.html#why-are-default-values-shared-between-objects&quot;&gt;Official FAQ — why are default values shared between objects?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.python.org/3/library/dataclasses.html#mutable-default-values&quot;&gt;dataclasses — mutable default values&lt;/a&gt;: why &lt;code&gt;default_factory&lt;/code&gt; exists&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.astral.sh/ruff/rules/mutable-argument-default/&quot;&gt;Ruff — B006&lt;/a&gt; and &lt;a href=&quot;https://docs.astral.sh/ruff/rules/function-call-in-default-argument/&quot;&gt;B008&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;foot&quot;&gt;
  Every runnable snippet verified against CPython 3.10.
&lt;/div&gt;

&lt;/div&gt;
&lt;/div&gt;

&lt;script&gt;
(function () {
  var root = document.getElementById(&#39;md-guide&#39;);
  if (!root || root.dataset.mdInit) return;
  root.dataset.mdInit = &#39;1&#39;;

  var PY_KW = (&quot;False|None|True|and|as|assert|async|await|break|class|continue|def|del|elif|&quot;
             + &quot;else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|&quot;
             + &quot;pass|raise|return|try|while|with|yield|self|match|case&quot;).split(&quot;|&quot;);

  var pyRe = new RegExp(
      &quot;(#[^\\n]*)&quot;                                        /* 1 comment */
    + &quot;|(\&quot;\&quot;\&quot;[\\s\\S]*?\&quot;\&quot;\&quot;|&#39;&#39;&#39;[\\s\\S]*?&#39;&#39;&#39;&quot;          /* 2 triple strings */
    +   &quot;|\&quot;(?:\\\\.|[^\&quot;\\\\\\n])*\&quot;|&#39;(?:\\\\.|[^&#39;\\\\\\n])*&#39;)&quot;
    + &quot;|(@[\\w.]+)&quot;                                        /* 3 decorator */
    + &quot;|\\b(&quot; + PY_KW.join(&quot;|&quot;) + &quot;)\\b&quot;                   /* 4 keyword */
    + &quot;|\\b(\\d[\\w.]*)\\b&quot;                                /* 5 number */
    + &quot;|\\b([a-zA-Z_]\\w*)(?=\\()&quot;                         /* 6 call */
    , &quot;g&quot;);

  var shRe = /(#[^\n]*)|(&quot;(?:\\.|[^&quot;\\])*&quot;|&#39;(?:\\.|[^&#39;\\])*&#39;)|(^|\s)(--?[\w-]+)/g;

  function esc(s) {
    return s.replace(/&amp;/g, &quot;&amp;amp;&quot;).replace(/&lt;/g, &quot;&amp;lt;&quot;).replace(/&gt;/g, &quot;&amp;gt;&quot;);
  }

  function highlightPy(text) {
    return esc(text).replace(pyRe, function (m, com, str, dec, kw, num, fn) {
      if (com) return &#39;&lt;span class=&quot;t-com&quot;&gt;&#39; + com + &quot;&lt;/span&gt;&quot;;
      if (str) return &#39;&lt;span class=&quot;t-str&quot;&gt;&#39; + str + &quot;&lt;/span&gt;&quot;;
      if (dec) return &#39;&lt;span class=&quot;t-dec&quot;&gt;&#39; + dec + &quot;&lt;/span&gt;&quot;;
      if (kw)  return &#39;&lt;span class=&quot;t-kw&quot;&gt;&#39;  + kw  + &quot;&lt;/span&gt;&quot;;
      if (num) return &#39;&lt;span class=&quot;t-num&quot;&gt;&#39; + num + &quot;&lt;/span&gt;&quot;;
      if (fn)  return &#39;&lt;span class=&quot;t-fn&quot;&gt;&#39;  + fn  + &quot;&lt;/span&gt;&quot;;
      return m;
    });
  }

  function highlightSh(text) {
    return esc(text).replace(shRe, function (m, com, str, pre, flag) {
      if (com)  return &#39;&lt;span class=&quot;t-com&quot;&gt;&#39; + com + &quot;&lt;/span&gt;&quot;;
      if (str)  return &#39;&lt;span class=&quot;t-str&quot;&gt;&#39; + str + &quot;&lt;/span&gt;&quot;;
      if (flag) return pre + &#39;&lt;span class=&quot;t-dec&quot;&gt;&#39; + flag + &quot;&lt;/span&gt;&quot;;
      return m;
    });
  }

  function highlightOut(text) {
    return esc(text)
      .replace(/\b(\d+ passed)\b/g, &#39;&lt;span class=&quot;t-pass&quot;&gt;$1&lt;/span&gt;&#39;)
      .replace(/\b(\d+ (?:failed|error[s]?))\b/g, &#39;&lt;span class=&quot;t-fail&quot;&gt;$1&lt;/span&gt;&#39;)
      .replace(/^(E .*)$/gm, &#39;&lt;span class=&quot;t-fail&quot;&gt;$1&lt;/span&gt;&#39;)
      .replace(/\b(PASSED)\b/g, &#39;&lt;span class=&quot;t-pass&quot;&gt;$1&lt;/span&gt;&#39;)
      .replace(/\b(FAILED|ERROR)\b/g, &#39;&lt;span class=&quot;t-fail&quot;&gt;$1&lt;/span&gt;&#39;);
  }

  root.querySelectorAll(&quot;pre code&quot;).forEach(function (el) {
    var raw = el.textContent;
    el.dataset.raw = raw;
    if (el.classList.contains(&quot;py&quot;))        el.innerHTML = highlightPy(raw);
    else if (el.classList.contains(&quot;out&quot;))  el.innerHTML = highlightOut(raw);
    else                                    el.innerHTML = highlightSh(raw);
  });

  root.querySelectorAll(&quot;.copy&quot;).forEach(function (btn) {
    btn.addEventListener(&quot;click&quot;, function (ev) {
      ev.preventDefault();
      var code = btn.closest(&quot;.snippet&quot;).querySelector(&quot;code&quot;);
      var text = code.dataset.raw || code.textContent;
      var done = function () {
        btn.textContent = &quot;copied&quot;;
        btn.classList.add(&quot;ok&quot;);
        setTimeout(function () { btn.textContent = &quot;copy&quot;; btn.classList.remove(&quot;ok&quot;); }, 1200);
      };
      if (navigator.clipboard &amp;&amp; navigator.clipboard.writeText) {
        navigator.clipboard.writeText(text).then(done, function () {});
      } else {
        var ta = document.createElement(&quot;textarea&quot;);
        ta.value = text; ta.style.position = &quot;fixed&quot;; ta.style.opacity = &quot;0&quot;;
        document.body.appendChild(ta); ta.select();
        try { document.execCommand(&quot;copy&quot;); done(); } catch (e) {}
        document.body.removeChild(ta);
      }
    });
  });
})();
&lt;/script&gt;
</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/7710306273686310939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2026/07/the-list-that-remembers-mutable-default.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/7710306273686310939'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/7710306273686310939'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2026/07/the-list-that-remembers-mutable-default.html' title='The list that remembers: mutable default arguments in Python'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-7243656572586644763</id><published>2026-07-28T08:12:44.403-07:00</published><updated>2026-07-28T08:12:44.403-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="closures"/><category scheme="http://www.blogger.com/atom/ns#" term="default arguments"/><category scheme="http://www.blogger.com/atom/ns#" term="late binding"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="python3"/><category scheme="http://www.blogger.com/atom/ns#" term="Ruff"/><category scheme="http://www.blogger.com/atom/ns#" term="scoping"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial"/><title type='text'>The loop variable that changed: late binding and default arguments in Python</title><content type='html'>&lt;style&gt;
/* ------------------------------------------------------------------
   study.marearts.com article body — late-binding guide.
   Every selector is scoped under #lb-guide so nothing leaks onto the
   theme chrome (post title, date header, sidebar, comments).

   Palette is derived from the blog&#39;s own Awesome Inc. dark theme so
   the post reads as native rather than as an embedded card:
     page background #2d3037   body text #cccccc
     links #f1c232 (gold)      link hover / post titles #29aae1
     date headers #8ce1f5
   There is no light variant on purpose. Blogger has no theme-toggle
   attribute, so a light default would be the only thing that ever
   rendered — which is exactly how this post shipped white the first
   time. Panels are graded around #2d3037 instead of using an absolute
   background, so the article never fights the page it sits on.
   ------------------------------------------------------------------ */
#lb-guide{
  --bg:transparent; --panel:#34383f; --panel2:#3b4048; --line:#454b54;
  --fg:#d4d7dc; --fg-strong:#eef0f3; --fg-dim:#a3a9b2; --fg-faint:#848b95;
  --accent:#f1c232; --accent-2:#29aae1; --warn:#ffb454; --danger:#ff7a84;
  --code-bg:#23262c; --code-fg:#d4d7dc;
  --kw:#c792ea; --str:#c3e88d; --com:#828a94; --num:#f78c6c;
  --dec:#ffcb6b; --fn:#82aaff; --inline-code:#e6d3ff;
  --pass:#4fd6b0; --fail:#ff7a84;
  --mono:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,&quot;JetBrains Mono&quot;,Menlo,Consolas,&quot;Liberation Mono&quot;,monospace;
  --sans:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif;
}
#lb-guide, #lb-guide *{box-sizing:border-box}
#lb-guide{
  background:var(--bg); color:var(--fg);
  font-family:var(--sans); font-size:16px; line-height:1.7;
  -webkit-font-smoothing:antialiased;
  /* No frame: the theme already pads the post column, so a border plus
     its own background would read as a widget pasted onto the page. */
  padding:2px 0 44px; border:0; border-radius:0;
}
#lb-guide .wrap{max-width:1000px;margin:0 auto;min-width:0}

/* headings */
#lb-guide h1{font-size:38px;line-height:1.18;letter-spacing:-.8px;margin:0 0 12px;color:var(--fg)}
#lb-guide .lede{font-size:18px;color:var(--fg-dim);max-width:70ch;margin:0 0 8px}
/* font-family is restated on h2/h4: the theme styles bare `h2` and `h4`
   with a `font:` shorthand, which sets Arial and beats plain inheritance
   from #lb-guide. */
#lb-guide h2{
  font-family:var(--sans);line-height:inherit;
  font-size:15px;text-transform:uppercase;letter-spacing:.1em;color:var(--accent-2);
  margin:64px 0 6px;padding-top:22px;border-top:1px solid var(--line);font-weight:700;
  scroll-margin-top:16px;
}
/* line-height is pinned to inherit rather than left undeclared: the
   site-wide tone CSS sets a heading line-height, and an undeclared
   property is the one thing an opt-out guard cannot protect if that
   guard ever fails to apply. `inherit` reproduces exactly what these
   headings render at today. */
#lb-guide h3{font-size:25px;line-height:inherit;letter-spacing:-.4px;margin:38px 0 10px;color:var(--fg-strong);scroll-margin-top:20px}
#lb-guide h4{font-family:var(--sans);font-size:16.5px;line-height:inherit;font-weight:600;margin:26px 0 8px;color:var(--fg-strong)}
#lb-guide p{max-width:74ch;margin:12px 0}
#lb-guide ul, #lb-guide ol{max-width:74ch;padding-left:22px;margin:10px 0}
/* The theme&#39;s `.main-inner .widget ul{list-style:none}` strips markers from
   every list in the post body, so the markers are put back explicitly. */
#lb-guide ul{list-style:disc}
#lb-guide ol{list-style:decimal}
#lb-guide li{margin:6px 0}
#lb-guide a{color:var(--accent)}
#lb-guide code{
  font-family:var(--mono);font-size:.875em;background:var(--panel2);
  padding:2px 6px;border-radius:4px;border:1px solid var(--line);color:var(--inline-code);
}
#lb-guide strong{color:var(--fg-strong);font-weight:650}
#lb-guide em{font-style:italic}

/* code blocks */
#lb-guide .snippet{margin:18px 0;border:1px solid var(--line);border-radius:10px;overflow:hidden;background:var(--code-bg)}
#lb-guide .snippet-head{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:7px 12px;background:var(--panel);border-bottom:1px solid var(--line);
}
#lb-guide .snippet-name{font-family:var(--mono);font-size:12px;color:var(--fg-faint)}
#lb-guide .snippet-name b{color:var(--fg-dim);font-weight:600}
#lb-guide .copy{
  background:transparent;border:1px solid var(--line);color:var(--fg-faint);
  font-size:11px;padding:3px 9px;border-radius:5px;cursor:pointer;font-family:var(--sans);line-height:1.4;
}
#lb-guide .copy:hover{color:var(--fg);border-color:var(--fg-faint)}
#lb-guide .copy.ok{color:var(--accent-2);border-color:var(--accent-2)}
#lb-guide pre{
  margin:0;padding:14px 16px;overflow-x:auto;background:var(--code-bg);
  font-family:var(--mono);font-size:13.5px;line-height:1.62;color:var(--code-fg);
  border:0;border-radius:0;
}
#lb-guide pre code{background:none;border:0;padding:0;font-size:inherit;color:inherit}
#lb-guide pre::-webkit-scrollbar{height:9px}
#lb-guide pre::-webkit-scrollbar-thumb{background:var(--line);border-radius:5px}
#lb-guide .out pre{color:var(--fg-dim)}
#lb-guide .out .snippet-name b{color:var(--warn)}

/* syntax colors */
#lb-guide .t-kw{color:var(--kw)}
#lb-guide .t-str{color:var(--str)}
#lb-guide .t-com{color:var(--com);font-style:italic}
#lb-guide .t-num{color:var(--num)}
#lb-guide .t-dec{color:var(--dec)}
#lb-guide .t-fn{color:var(--fn)}
#lb-guide .t-pass{color:var(--pass)}
#lb-guide .t-fail{color:var(--fail)}

/* callouts */
/* Info reads cyan, not gold: gold is the theme&#39;s link colour and would
   collide with .warn&#39;s amber at these low alphas. */
#lb-guide .note{
  border-left:3px solid var(--accent-2);background:rgba(41,170,225,.09);
  padding:12px 16px;margin:18px 0;border-radius:0 8px 8px 0;max-width:74ch;
}
#lb-guide .note.warn{border-color:var(--warn);background:rgba(255,180,84,.08)}
#lb-guide .note.trap{border-color:var(--danger);background:rgba(255,122,132,.08)}
#lb-guide .note .tag{
  display:block;font-size:10.5px;text-transform:uppercase;letter-spacing:.1em;
  font-weight:700;color:var(--accent-2);margin-bottom:3px;
}
#lb-guide .note.warn .tag{color:var(--warn)}
#lb-guide .note.trap .tag{color:var(--danger)}
#lb-guide .note p{margin:5px 0}
#lb-guide .note .tag code{
  background:none !important;border:0 !important;padding:0 !important;
  color:inherit !important;font-size:1em !important;
}

/* tables */
#lb-guide .table-wrap{overflow-x:auto;margin:18px 0}
#lb-guide table{border-collapse:collapse;width:100%;margin:0;font-size:14.5px;background:none}
#lb-guide th, #lb-guide td{text-align:left;padding:9px 13px;border:0;border-bottom:1px solid var(--line);vertical-align:top}
#lb-guide th{color:var(--fg-faint);font-size:11.5px;text-transform:uppercase;letter-spacing:.07em;font-weight:700}
#lb-guide td code{font-size:.9em}
#lb-guide tbody tr:hover{background:var(--panel)}

/* furniture */
#lb-guide .kicker{
  font-size:12px;font-weight:700;letter-spacing:.13em;text-transform:uppercase;
  color:var(--accent-2);margin-bottom:14px;
}
#lb-guide .rule{height:1px;background:var(--line);margin:30px 0 4px;max-width:74ch}

#lb-guide .toc{
  border:1px solid var(--line);border-radius:12px;background:var(--panel);
  padding:20px 24px;margin:34px 0 10px;max-width:74ch;
}
#lb-guide .toc h4{margin:0 0 14px;font-size:13px;text-transform:uppercase;letter-spacing:.1em;color:var(--fg-faint)}
#lb-guide .toc ol{margin:0;padding-left:20px;max-width:none}
#lb-guide .toc &gt; ol &gt; li{margin:14px 0}
#lb-guide .toc &gt; ol &gt; li &gt; a{text-decoration:none;font-weight:650;font-size:16.5px}
#lb-guide .toc a{text-decoration:none;color:var(--accent)}
#lb-guide .toc a:hover{text-decoration:underline}
#lb-guide .toc span{color:var(--fg-faint);font-weight:400;font-size:14px}
#lb-guide .toc ul{
  list-style:none;margin:7px 0 0;padding-left:0;max-width:none;
  display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:1px 18px;
}
#lb-guide .toc ul li{margin:0}
#lb-guide .toc ul a{font-size:14px;color:var(--fg-dim)}
#lb-guide .toc ul a:hover{color:var(--accent)}

#lb-guide .takeaway{
  border:1px solid var(--line);border-left:3px solid var(--accent-2);
  border-radius:0 12px 12px 0;background:var(--panel);
  padding:18px 22px;margin:26px 0;max-width:74ch;
}
#lb-guide .takeaway h4{margin:0 0 10px;font-size:14px;text-transform:uppercase;letter-spacing:.08em;color:var(--accent-2)}
#lb-guide .takeaway ul{margin:0;padding-left:20px}

/* Always stacked, never side by side: the theme&#39;s centre column is ~545px
   of content, so two code panes would each get ~265px and clip mid-token
   regardless of viewport width (the 900px media query never fires). */
#lb-guide .grid2{display:grid;grid-template-columns:1fr;gap:16px}
#lb-guide .grid2 .snippet{margin:0;min-width:0}
#lb-guide .pt-badge{
  display:inline-block;font-size:11px;padding:2px 8px;border-radius:20px;
  border:1px solid var(--line);color:var(--fg-faint);margin-left:8px;vertical-align:middle;
  letter-spacing:normal;line-height:1.4;text-align:left;background:none;
}
#lb-guide .kbd{
  font-family:var(--mono);font-size:12px;background:var(--panel2);border:1px solid var(--line);
  border-bottom-width:2px;border-radius:4px;padding:1px 6px;
}
#lb-guide .foot{
  margin-top:70px;padding-top:20px;border-top:1px solid var(--line);
  color:var(--fg-faint);font-size:13px;
}
/* ------------------------------------------------------------------
   The Blogger theme re-colours bare descendants of the post container:
   body{color:#cccccc}, .post-body ul li{color:#cccccc},
   .main-inner .widget ul li{color:#ffffff}, a:link{color:#f1c232},
   h2{color:#8ce1f5}, h4{color:#29aae1}. Re-assert the article palette
   here — #lb-guide carries an id, so it wins on specificity, and the
   !important guards cover the handful of host rules that use it too.
   Kept deliberately narrow: anything with a per-component colour of its
   own (.toc h4, .takeaway h4, .note .tag) must not be caught by these.
   ------------------------------------------------------------------ */
#lb-guide h1, #lb-guide h3{color:var(--fg-strong) !important}
#lb-guide h2{color:var(--accent-2) !important}
#lb-guide p{color:var(--fg) !important}
#lb-guide li{color:var(--fg) !important;padding:0;border:0}
#lb-guide .lede{color:var(--fg-dim) !important}
#lb-guide strong{color:var(--fg-strong) !important}
#lb-guide a, #lb-guide .toc a{color:var(--accent) !important}
#lb-guide .toc ul a{color:var(--fg-dim) !important}
#lb-guide a:hover, #lb-guide .toc ul a:hover{color:var(--accent) !important}
#lb-guide code{background:var(--panel2) !important;color:var(--inline-code) !important}
#lb-guide pre code{background:none !important;color:var(--code-fg) !important}
#lb-guide table{background:none !important;table-layout:auto !important}
#lb-guide th{background:var(--panel2) !important;color:var(--fg-faint) !important}
#lb-guide td{color:var(--fg) !important}
#lb-guide th, #lb-guide td{border-color:var(--line) !important}
#lb-guide tbody tr:hover{background:var(--panel) !important}

@media screen and (max-width:900px){
  #lb-guide{padding:2px 0 36px}
  #lb-guide table{font-size:13.5px}
}
@media screen and (max-width:640px){
  #lb-guide .toc ul{grid-template-columns:1fr}
}

/* ------------------------------------------------------------------
   Components used by this post only.
   ------------------------------------------------------------------ */

/* Annotated-signature diagram. A bare `pre` on purpose: the highlighter
   only touches `pre code`, so omitting the `code` element is what stops
   it from eating the hl- spans. The block scrolls rather than wraps —
   its callout lines are aligned by character column, so a wrap would
   scramble them. */
#lb-guide .diagram{
  margin:22px 0;padding:18px 20px;border:1px dashed var(--line);border-radius:10px;
  background:var(--code-bg);overflow-x:auto;
}
#lb-guide .diagram pre{
  margin:0;padding:0;background:none;border:0;border-radius:0;
  font-family:var(--mono);font-size:12px;line-height:1.75;
  color:var(--fg-dim);white-space:pre;overflow:visible;
}
#lb-guide .diagram .hl-a{color:var(--fn)}
#lb-guide .diagram .hl-b{color:var(--dec)}
#lb-guide .diagram .hl-c{color:var(--pass)}
#lb-guide .diagram::-webkit-scrollbar{height:9px}
#lb-guide .diagram::-webkit-scrollbar-thumb{background:var(--line);border-radius:5px}

/* Lint-rule slugs in the part-10 table. */
#lb-guide .sub{font-family:var(--mono);font-size:12px;color:var(--fg-faint)}

/* avoid / prefer labels on the paired snippets in part 5. */
#lb-guide .snippet-name.bad b{color:var(--danger)}
#lb-guide .snippet-name.good b{color:var(--pass)}
&lt;/style&gt;

&lt;div id=&quot;lb-guide&quot; data-tone=&quot;self&quot;&gt;
&lt;div class=&quot;wrap&quot;&gt;

&lt;div class=&quot;kicker&quot;&gt;Python · Language&lt;/div&gt;
&lt;p class=&quot;lede&quot;&gt;
  You define a function inside a loop, collect the functions, call them later — and every single one
  returns the last value. The usual fix is a strange-looking line where the same name appears twice.
  Here is what is actually going on, and why the fix works.
&lt;/p&gt;

&lt;div class=&quot;rule&quot;&gt;&lt;/div&gt;

&lt;p&gt;
  This bug has a particular texture. The code reads correctly, each function looks like it captured
  its own value, and nothing raises. You only find out when the results are all identical — and if the
  loop happens to have one iteration during development, you never find out at all.
&lt;/p&gt;
&lt;p&gt;
  The explanation is one sentence long: &lt;strong&gt;a closure captures the variable, not the value.&lt;/strong&gt;
  Everything else in this post is unpacking what that means and what to do about it.
&lt;/p&gt;
&lt;p&gt;
  Every snippet was run on CPython 3.10 before publishing, and the output shown is copied from those
  runs.
&lt;/p&gt;

&lt;div class=&quot;toc&quot;&gt;
  &lt;h4&gt;Contents&lt;/h4&gt;
  &lt;ol&gt;
    &lt;li&gt;&lt;a href=&quot;#lb-bug&quot;&gt;The bug&lt;/a&gt; &lt;span&gt;— three functions, one value&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#lb-why&quot;&gt;Why it happens&lt;/a&gt; &lt;span&gt;— variables, cells, and Python&#39;s missing block scope&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#lb-anatomy&quot;&gt;Anatomy of the fix&lt;/a&gt; &lt;span&gt;— reading &lt;code&gt;def f(x: T = x)&lt;/code&gt; as three parts&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#lb-once&quot;&gt;Defaults are evaluated once&lt;/a&gt; &lt;span&gt;— the rule that makes the fix work&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#lb-mutable&quot;&gt;The same rule, as a trap&lt;/a&gt; &lt;span&gt;— mutable default arguments&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#lb-alternatives&quot;&gt;Other ways to capture&lt;/a&gt; &lt;span&gt;— &lt;code&gt;partial&lt;/code&gt;, factories, and which to prefer&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#lb-where&quot;&gt;Where it bites&lt;/a&gt; &lt;span&gt;— threads, callbacks, handlers, tasks&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#lb-hints&quot;&gt;What the type hint does&lt;/a&gt; &lt;span&gt;— and when it is evaluated&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#lb-scoping&quot;&gt;Scoping rules, briefly&lt;/a&gt; &lt;span&gt;— LEGB, &lt;code&gt;nonlocal&lt;/code&gt;, comprehensions&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#lb-linters&quot;&gt;Letting a linter catch it&lt;/a&gt; &lt;span&gt;— B023 and B008&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#lb-cheatsheet&quot;&gt;Cheat sheet&lt;/a&gt;&lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;


&lt;h2&gt;Part 1 · The bug&lt;/h2&gt;

&lt;h3 id=&quot;lb-bug&quot;&gt;Three functions, one value&lt;/h3&gt;
&lt;p&gt;Build a list of functions in a loop. Each one returns the loop variable.&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;late.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;fns = []
for i in range(3):
    def show():
        return i
    fns.append(show)

print([f() for f in fns])&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python late.py&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;[2, 2, 2]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Not &lt;code&gt;[0, 1, 2]&lt;/code&gt;. All three functions return &lt;code&gt;2&lt;/code&gt;, the value &lt;code&gt;i&lt;/code&gt; had when the loop
  finished. The functions were created at three different times, but they were never looking at three
  different values — they were all looking at the same &lt;code&gt;i&lt;/code&gt;.
&lt;/p&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Why it survives review&lt;/span&gt;
  &lt;p&gt;
    Nothing about the code is unusual, and the failure is silent. It also depends on &lt;em&gt;when&lt;/em&gt; you
    call: if you call &lt;code&gt;show()&lt;/code&gt; inside the loop it returns the right thing, because &lt;code&gt;i&lt;/code&gt;
    still holds that value at that moment. Deferring the call is what exposes it.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h2&gt;Part 2 · Why it happens&lt;/h2&gt;

&lt;h3 id=&quot;lb-why&quot;&gt;Variables, cells, and the missing block scope&lt;/h3&gt;
&lt;p&gt;
  A closure is a function plus a reference to the enclosing scope&#39;s variables. Not copies of their
  values — references to the variables themselves. Python stores each captured variable in a
  &lt;em&gt;cell&lt;/em&gt;, and every closure over that variable shares the one cell.
&lt;/p&gt;
&lt;p&gt;You can look at the cell directly:&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;the cell is shared and mutable&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def make():
    n = 0
    def inc():
        nonlocal n
        n += 1
        return n
    return inc

c = make()
print(c(), c(), c())              # 1 2 3
print(c.__closure__[0].cell_contents)   # 3&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The three calls returned different numbers because they all read and wrote the same cell. That is
  the whole point of a closure — and it is exactly what goes wrong in the loop, because the loop
  variable is also just a variable in the enclosing scope.
&lt;/p&gt;

&lt;p&gt;
  There is a second ingredient. In most C-like languages, &lt;code&gt;for (int i = ...)&lt;/code&gt; creates a new
  &lt;code&gt;i&lt;/code&gt; scoped to the loop body. Python has no block scope: &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;for&lt;/code&gt; and
  &lt;code&gt;while&lt;/code&gt; do not create scopes. Only modules, functions and classes do. So there is exactly
  one &lt;code&gt;i&lt;/code&gt;, it belongs to the enclosing function, and it outlives the loop:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;the loop variable leaks&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;for i in range(3):
    pass
print(i)          # 2 — still in scope, still holding the last value&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Put the two facts together and the behaviour is inevitable:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;The loop rebinds one variable three times.&lt;/li&gt;
  &lt;li&gt;All three closures reference that one variable.&lt;/li&gt;
  &lt;li&gt;Calling them afterwards reads it once the loop has finished, so all three see the final value.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;&quot;Late binding&quot; names the timing&lt;/span&gt;
  &lt;p&gt;
    The name lookup happens when the function &lt;em&gt;runs&lt;/em&gt;, not when it is defined. That is the general
    rule for every free variable in Python, and it is usually what you want — it is why you can define
    a function that calls a helper declared later in the file.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h2&gt;Part 3 · Anatomy of the fix&lt;/h2&gt;

&lt;h3 id=&quot;lb-anatomy&quot;&gt;Reading &lt;code&gt;def f(x: T = x)&lt;/code&gt; as three parts&lt;/h3&gt;
&lt;p&gt;
  The fix is to bind the value into the function&#39;s own signature. In a typed codebase it ends up
  looking like this, which is where the confusion starts:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;the idiom&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def invoke(kernel: Kernel = kernel) -&amp;gt; None:
    ...&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Three independent things are packed into &lt;code&gt;kernel: Kernel = kernel&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;diagram&quot;&gt;
&lt;pre&gt;def invoke(&lt;span class=&quot;hl-a&quot;&gt;kernel&lt;/span&gt;&lt;span class=&quot;hl-b&quot;&gt;: Kernel&lt;/span&gt; &lt;span class=&quot;hl-c&quot;&gt;= kernel&lt;/span&gt;) -&amp;gt; None:
           &lt;span class=&quot;hl-a&quot;&gt;~~~~~~&lt;/span&gt;&lt;span class=&quot;hl-b&quot;&gt;~~~~~~~~&lt;/span&gt; &lt;span class=&quot;hl-c&quot;&gt;~~~~~~~~&lt;/span&gt;
           &lt;span class=&quot;hl-a&quot;&gt;│&lt;/span&gt;     &lt;span class=&quot;hl-b&quot;&gt;│&lt;/span&gt;        &lt;span class=&quot;hl-c&quot;&gt;│&lt;/span&gt;
           &lt;span class=&quot;hl-a&quot;&gt;│&lt;/span&gt;     &lt;span class=&quot;hl-b&quot;&gt;│&lt;/span&gt;        &lt;span class=&quot;hl-c&quot;&gt;└─ default value: the OUTER variable,&lt;/span&gt;
           &lt;span class=&quot;hl-a&quot;&gt;│&lt;/span&gt;     &lt;span class=&quot;hl-b&quot;&gt;│&lt;/span&gt;           &lt;span class=&quot;hl-c&quot;&gt;evaluated now, at def time&lt;/span&gt;
           &lt;span class=&quot;hl-a&quot;&gt;│&lt;/span&gt;     &lt;span class=&quot;hl-b&quot;&gt;└─ type hint: the Kernel class&lt;/span&gt;
           &lt;span class=&quot;hl-a&quot;&gt;└─ parameter name: a NEW local, created per call&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The name appears twice because two different things happen to share a spelling. They live in
  different scopes and are resolved at different times:
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;&lt;/th&gt;&lt;th&gt;Left &lt;code&gt;kernel&lt;/code&gt;&lt;/th&gt;&lt;th&gt;Right &lt;code&gt;kernel&lt;/code&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;What it is&lt;/td&gt;&lt;td&gt;A parameter being declared&lt;/td&gt;&lt;td&gt;An expression being evaluated&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Which scope&lt;/td&gt;&lt;td&gt;Local to &lt;code&gt;invoke&lt;/code&gt;&lt;/td&gt;&lt;td&gt;The enclosing scope — the loop variable&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;When&lt;/td&gt;&lt;td&gt;On every call to &lt;code&gt;invoke&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Once, when the &lt;code&gt;def&lt;/code&gt; statement runs&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Effect&lt;/td&gt;&lt;td&gt;Shadows the outer name inside the body&lt;/td&gt;&lt;td&gt;Snapshots the current value&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;
  That last row is the mechanism. Because the right-hand side is evaluated while the loop is on that
  iteration, the value is captured then and stored on the function object. And because the left-hand
  side introduces a local with the same name, the body reads the captured parameter instead of the
  outer variable — the closure is gone.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;fixed.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;fns = []
for i in range(3):
    def show(i=i):     # left i = new parameter; right i = this iteration&#39;s value
        return i
    fns.append(show)

print([f() for f in fns])&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python fixed.py&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;[0, 1, 2]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You can see the snapshot on the function object. Rebinding the outer name afterwards changes nothing:&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;the value is stored, not looked up&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;x = 10
def f(a=x):
    return a

x = 999
print(f.__defaults__, f(), x)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;output&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;(10,) 10 999&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;It changes the public signature&lt;/span&gt;
  &lt;p&gt;
    &lt;code&gt;show(i=i)&lt;/code&gt; is an honest fix but not a free one: &lt;code&gt;show&lt;/code&gt; now accepts an argument, and a
    caller can override the captured value. For an internal callback that is harmless. For a function
    you hand to someone else, prefer a factory (below) so the capture is not part of the API.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h2&gt;Part 4 · Defaults are evaluated once&lt;/h2&gt;

&lt;h3 id=&quot;lb-once&quot;&gt;The rule underneath&lt;/h3&gt;
&lt;p&gt;
  Default argument expressions are evaluated &lt;strong&gt;once, when the &lt;code&gt;def&lt;/code&gt; statement executes&lt;/strong&gt; —
  not on each call. This single rule explains both the fix above and the trap below.
&lt;/p&gt;
&lt;p&gt;Prove it with a default that announces itself:&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;once.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def stamp(value=print(&quot;  (default evaluated)&quot;)):
    return value

print(&quot;  function defined, not called yet&quot;)
stamp()
stamp()&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python once.py&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;  (default evaluated)
  function defined, not called yet&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The message appears &lt;em&gt;before&lt;/em&gt; &quot;function defined&quot;, and appears only once despite two calls. The
  default was computed while Python was building the function object, and the result was stored on it.
&lt;/p&gt;
&lt;p&gt;
  So &lt;code&gt;def show(i=i)&lt;/code&gt; is not a clever trick, it is the ordinary rule applied deliberately: you
  are asking for an expression to be evaluated now and remembered.
&lt;/p&gt;


&lt;h2&gt;Part 5 · The same rule, as a trap&lt;/h2&gt;

&lt;h3 id=&quot;lb-mutable&quot;&gt;Mutable default arguments&lt;/h3&gt;
&lt;p&gt;
  Evaluated once means the default object is created once and reused by every call. If it is mutable,
  every call shares it — and the sharing persists for the lifetime of the function.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;mutable.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def append_bad(item, bucket=[]):
    bucket.append(item)
    return bucket

print(append_bad(&quot;a&quot;))
print(append_bad(&quot;b&quot;))
print(append_bad.__defaults__)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python mutable.py&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;[&#39;a&#39;]
[&#39;a&#39;, &#39;b&#39;]
([&#39;a&#39;, &#39;b&#39;],)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The second call did not start from an empty list. The &lt;code&gt;[]&lt;/code&gt; in the signature is one list object,
  created once, now permanently attached to the function — you can see it grow inside
  &lt;code&gt;__defaults__&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;The fix is the &lt;code&gt;None&lt;/code&gt; sentinel. Take the default as &lt;code&gt;None&lt;/code&gt; and build the real thing inside:&lt;/p&gt;

&lt;div class=&quot;grid2&quot;&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name bad&quot;&gt;&lt;b&gt;avoid&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def f(bucket=[]):
    bucket.append(1)
    return bucket

def g(cache={}):
    ...

def h(when=datetime.now()):
    ...       # frozen at import time!&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name good&quot;&gt;&lt;b&gt;prefer&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def f(bucket=None):
    if bucket is None:
        bucket = []
    bucket.append(1)
    return bucket

def g(cache=None):
    cache = {} if cache is None else cache

def h(when=None):
    when = when or datetime.now()&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;The subtlest version of this bug&lt;/span&gt;
  &lt;p&gt;
    &lt;code&gt;def h(when=datetime.now())&lt;/code&gt; looks like &quot;default to now&quot;. It means &quot;default to the moment this
    module was imported&quot;. A long-running process will hand out the same timestamp for days, and the
    test suite will pass because it imports and calls within the same second.
  &lt;/p&gt;
&lt;/div&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;When sharing is the point&lt;/span&gt;
  &lt;p&gt;
    A mutable default is occasionally deliberate — a memo dictionary that must persist across calls.
    It works, but it is invisible to the reader. Prefer an explicit module-level variable or
    &lt;code&gt;functools.cache&lt;/code&gt;, both of which say what they mean.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h2&gt;Part 6 · Other ways to capture&lt;/h2&gt;

&lt;h3 id=&quot;lb-alternatives&quot;&gt;partial, factories, and which to prefer&lt;/h3&gt;

&lt;h4&gt;A factory function&lt;/h4&gt;
&lt;p&gt;
  Give the value a scope of its own by passing it as a parameter to an outer function. The inner
  closure then captures &lt;em&gt;that&lt;/em&gt; parameter, and each call to the factory creates a fresh one.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;factory&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def make_show(value):
    def show():
        return value       # captures the parameter, not the loop variable
    return show

fns = [make_show(i) for i in range(3)]
print([f() for f in fns])          # [0, 1, 2]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  This is the version to reach for in library code: the signature of &lt;code&gt;show&lt;/code&gt; stays clean, and the
  capture is explicit rather than a signature side effect.
&lt;/p&gt;

&lt;h4&gt;&lt;code&gt;functools.partial&lt;/code&gt;&lt;/h4&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;partial&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;from functools import partial

def show(value):
    return value

fns = [partial(show, i) for i in range(3)]
print([f() for f in fns])          # [0, 1, 2]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  &lt;code&gt;partial&lt;/code&gt; binds arguments immediately and stores them on the resulting object, so there is no
  closure to go stale. It is the cleanest option when the function already exists and takes the value
  as a parameter.
&lt;/p&gt;

&lt;h4&gt;Comparison&lt;/h4&gt;
&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Technique&lt;/th&gt;&lt;th&gt;Good&lt;/th&gt;&lt;th&gt;Cost&lt;/th&gt;&lt;th&gt;Use when&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code&gt;def f(x=x)&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;One token; no restructuring&lt;/td&gt;
      &lt;td&gt;Adds a parameter callers can override&lt;/td&gt;
      &lt;td&gt;Local callbacks, quick lambdas&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Factory function&lt;/td&gt;
      &lt;td&gt;Signature stays clean; intent explicit&lt;/td&gt;
      &lt;td&gt;An extra function&lt;/td&gt;
      &lt;td&gt;Library code, anything exported&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code&gt;partial&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;No new scope; composes well&lt;/td&gt;
      &lt;td&gt;Function must accept the value&lt;/td&gt;
      &lt;td&gt;The callable already exists&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Bind to an instance attribute&lt;/td&gt;
      &lt;td&gt;Natural when state is already an object&lt;/td&gt;
      &lt;td&gt;A class&lt;/td&gt;
      &lt;td&gt;Several values travel together&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;


&lt;h2&gt;Part 7 · Where it bites&lt;/h2&gt;

&lt;h3 id=&quot;lb-where&quot;&gt;Anything that defers the call&lt;/h3&gt;
&lt;p&gt;
  The pattern is always the same: a callable is created in a loop and invoked later. Threads make it
  vivid because the fix and the bug differ by six characters.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;threads.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import threading

results = []
threads = [
    threading.Thread(target=lambda: results.append(name))
    for name in (&quot;a&quot;, &quot;b&quot;, &quot;c&quot;)
]
for t in threads: t.start()
for t in threads: t.join()
print(&quot;buggy:&quot;, sorted(results))

results = []
threads = [
    threading.Thread(target=lambda name=name: results.append(name))
    for name in (&quot;a&quot;, &quot;b&quot;, &quot;c&quot;)
]
for t in threads: t.start()
for t in threads: t.join()
print(&quot;fixed:&quot;, sorted(results))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; python threads.py&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;buggy: [&#39;c&#39;, &#39;c&#39;, &#39;c&#39;]
fixed: [&#39;a&#39;, &#39;b&#39;, &#39;c&#39;]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The same shape shows up in:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Event handlers.&lt;/strong&gt; Buttons built in a loop that all act on the last item.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Async tasks.&lt;/strong&gt; &lt;code&gt;asyncio.create_task&lt;/code&gt; over a coroutine closing on a loop variable.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Handler dictionaries.&lt;/strong&gt; &lt;code&gt;{name: lambda: dispatch(name) for name in names}&lt;/code&gt; —
      the dict comprehension has its own scope, but the lambdas still close over its variable.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Retry and timing wrappers.&lt;/strong&gt; A benchmark harness that builds one thunk per case and
      runs them afterwards ends up measuring the last case repeatedly.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Deferred logging.&lt;/strong&gt; &lt;code&gt;log.debug(lambda: f&quot;{item}&quot;)&lt;/code&gt; style lazy messages.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;The measurement version is the nastiest&lt;/span&gt;
  &lt;p&gt;
    When the deferred callables are benchmarks, nothing crashes and every number looks plausible —
    you simply publish the same case&#39;s timing under several names. There is no error to notice, only
    a conclusion that is wrong.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h2&gt;Part 8 · What the type hint does&lt;/h2&gt;

&lt;h3 id=&quot;lb-hints&quot;&gt;The middle part, and when it runs&lt;/h3&gt;
&lt;p&gt;
  In &lt;code&gt;kernel: Kernel = kernel&lt;/code&gt;, the annotation is the only part with no effect on behaviour.
  Python does not check it, coerce with it, or consult it when binding arguments. It is metadata for
  readers and for tools such as mypy or pyright.
&lt;/p&gt;
&lt;p&gt;But it &lt;em&gt;is&lt;/em&gt; an expression, and by default it is evaluated at definition time:&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;annotations are evaluated eagerly&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def side_effect():
    print(&quot;  (annotation evaluated)&quot;)
    return int

def g(a: side_effect() = 1):
    return a

print(g.__annotations__)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;output&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;  (annotation evaluated)
{&#39;a&#39;: &amp;lt;class &#39;int&#39;&amp;gt;}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Add &lt;code&gt;from __future__ import annotations&lt;/code&gt; and they are kept as strings instead, never evaluated
  unless something asks for them:
&lt;/p&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;output&lt;/b&gt; with the future import&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;out&quot;&gt;{&#39;a&#39;: &#39;side_effect()&#39;}          # note: no &quot;(annotation evaluated)&quot; line
(1,)                            # __defaults__ — still evaluated eagerly&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Two things worth carrying away. First, deferring annotations lets you reference a class before it is
  defined, which is why the future import is common in typed code. Second, it changes
  &lt;em&gt;nothing&lt;/em&gt; about defaults — those are always evaluated immediately, which is exactly what the
  capture idiom relies on.
&lt;/p&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Hints do not narrow the capture&lt;/span&gt;
  &lt;p&gt;
    Writing &lt;code&gt;kernel: Kernel = kernel&lt;/code&gt; rather than &lt;code&gt;kernel=kernel&lt;/code&gt; documents the parameter
    and gives a type checker something to verify. The value that gets captured, and when, is identical
    either way.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h2&gt;Part 9 · Scoping rules, briefly&lt;/h2&gt;

&lt;h3 id=&quot;lb-scoping&quot;&gt;LEGB, nonlocal, and comprehensions&lt;/h3&gt;
&lt;p&gt;Python resolves a name by searching four scopes in order:&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Scope&lt;/th&gt;&lt;th&gt;Is&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;strong&gt;L&lt;/strong&gt;ocal&lt;/td&gt;&lt;td&gt;Names assigned in the current function&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;strong&gt;E&lt;/strong&gt;nclosing&lt;/td&gt;&lt;td&gt;Locals of any lexically enclosing function — this is where closures read from&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;strong&gt;G&lt;/strong&gt;lobal&lt;/td&gt;&lt;td&gt;Module level&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;strong&gt;B&lt;/strong&gt;uilt-in&lt;/td&gt;&lt;td&gt;&lt;code&gt;len&lt;/code&gt;, &lt;code&gt;print&lt;/code&gt;, and friends&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;
  Assigning to a name makes it local for the &lt;em&gt;whole&lt;/em&gt; function, which is why reading it before the
  assignment raises rather than falling through to an outer scope. To assign to an outer name instead,
  declare the intent:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;nonlocal vs global&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;count = 0

def outer():
    total = 0
    def bump():
        nonlocal total     # assign to outer()&#39;s local
        global count       # assign to the module-level name
        total += 1
        count += 1
    bump(); bump()
    return total

print(outer(), count)      # 2 2&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Comprehensions are the one construct that looks like a loop but is not: each has its own scope, so
  its variable does not leak. That is a small blessing and a common source of surprise:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;comprehension scope&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;py&quot;&gt;squares = [j * j for j in range(3)]
print(squares)             # [0, 1, 4]
print(j)                   # NameError: name &#39;j&#39; is not defined&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;But it does not save you&lt;/span&gt;
  &lt;p&gt;
    The comprehension&#39;s variable is scoped, yet a lambda created inside still closes over it and still
    reads it late. &lt;code&gt;[lambda: j for j in range(3)]&lt;/code&gt; gives three functions that all return
    &lt;code&gt;2&lt;/code&gt;. Scoping the variable is not the same as snapshotting it.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h2&gt;Part 10 · Letting a linter catch it&lt;/h2&gt;

&lt;h3 id=&quot;lb-linters&quot;&gt;B023 and B008&lt;/h3&gt;
&lt;p&gt;
  You should not have to spot this by eye. &lt;code&gt;flake8-bugbear&lt;/code&gt; and Ruff both ship the checks; enable
  them once and the class of bug stops reaching review.
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Rule&lt;/th&gt;&lt;th&gt;Catches&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code&gt;B023&lt;/code&gt;&lt;br&gt;&lt;span class=&quot;sub&quot;&gt;function-uses-loop-variable&lt;/span&gt;&lt;/td&gt;
      &lt;td&gt;A function defined in a loop that references the loop variable — the bug in part 1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code&gt;B006&lt;/code&gt;&lt;br&gt;&lt;span class=&quot;sub&quot;&gt;mutable-argument-default&lt;/span&gt;&lt;/td&gt;
      &lt;td&gt;&lt;code&gt;def f(x=[])&lt;/code&gt; and friends — the trap in part 5&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code&gt;B008&lt;/code&gt;&lt;br&gt;&lt;span class=&quot;sub&quot;&gt;function-call-in-default-argument&lt;/span&gt;&lt;/td&gt;
      &lt;td&gt;&lt;code&gt;def f(when=datetime.now())&lt;/code&gt; — a call evaluated once at import&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;pyproject.toml&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;toml&quot;&gt;[tool.ruff.lint]
extend-select = [&quot;B&quot;]      # all of flake8-bugbear, including B006/B008/B023&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;what it looks like&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
  &lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;$ ruff check --select B023,B006,B008 --output-format concise .
b008.py:3:12: B008 Do not perform function call `datetime.now` in argument defaults;
              instead, perform the call within the function, or read the default from
              a module-level singleton variable
late.py:4:16: B023 Function definition does not bind loop variable `i`
mutable.py:1:29: B006 Do not use mutable data structures for argument defaults
Found 3 errors.&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;B008 has legitimate exceptions&lt;/span&gt;
  &lt;p&gt;
    Some frameworks make a call in the default meaningful — FastAPI&#39;s &lt;code&gt;Depends()&lt;/code&gt; is the usual
    example. Ruff has &lt;code&gt;extend-immutable-calls&lt;/code&gt; for exactly this; add the specific callable rather
    than switching the rule off.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h2&gt;Wrapping up&lt;/h2&gt;

&lt;h3 id=&quot;lb-cheatsheet&quot;&gt;Cheat sheet&lt;/h3&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Expression&lt;/th&gt;&lt;th&gt;Evaluated&lt;/th&gt;&lt;th&gt;Consequence&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;Function body&lt;/td&gt;&lt;td&gt;On every call&lt;/td&gt;&lt;td&gt;Free variables are read late&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Default argument&lt;/td&gt;&lt;td&gt;Once, at &lt;code&gt;def&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Snapshots values; shares mutables&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Annotation&lt;/td&gt;&lt;td&gt;Once, at &lt;code&gt;def&lt;/code&gt; — or never, with the future import&lt;/td&gt;&lt;td&gt;No runtime effect either way&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Decorator&lt;/td&gt;&lt;td&gt;Once, at &lt;code&gt;def&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Wrapping happens at definition time&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;div class=&quot;takeaway&quot;&gt;
  &lt;h4&gt;The short list&lt;/h4&gt;
  &lt;ul&gt;
    &lt;li&gt;
      &lt;strong&gt;A closure captures the variable, not the value.&lt;/strong&gt; If a function outlives the loop
      that made it, it will see the loop&#39;s final state.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;&lt;code&gt;def f(x=x)&lt;/code&gt; works because defaults are evaluated once, at definition.&lt;/strong&gt;
      Left is a new local, right is the outer variable read right now. Same word, different things.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;That same rule is the mutable-default trap.&lt;/strong&gt; One &lt;code&gt;[]&lt;/code&gt;, created once, shared
      by every call. Use &lt;code&gt;None&lt;/code&gt; and build inside.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Turn on bugbear (&lt;code&gt;B&lt;/code&gt;) in Ruff.&lt;/strong&gt; B023, B006 and B008 cover all three
      failure modes above, and none of them announce themselves at runtime.
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;

&lt;h3 id=&quot;lb-further&quot;&gt;Further reading&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.python.org/3/reference/compound_stmts.html#function-definitions&quot;&gt;Python reference — function definitions&lt;/a&gt;: the paragraph stating defaults are evaluated once, left to right&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.python.org/3/faq/programming.html#why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result&quot;&gt;Official FAQ&lt;/a&gt;: the loop-lambda question, answered in four lines&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0563/&quot;&gt;PEP 563&lt;/a&gt; and &lt;a href=&quot;https://peps.python.org/pep-0649/&quot;&gt;PEP 649&lt;/a&gt;: how and when annotations get evaluated&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.astral.sh/ruff/rules/#flake8-bugbear-b&quot;&gt;Ruff — flake8-bugbear rules&lt;/a&gt;: B006, B008, B023 and the rest&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;foot&quot;&gt;
  Every runnable snippet verified against CPython 3.10.
&lt;/div&gt;

&lt;/div&gt;
&lt;/div&gt;

&lt;script&gt;
(function () {
  var root = document.getElementById(&#39;lb-guide&#39;);
  if (!root || root.dataset.lbInit) return;
  root.dataset.lbInit = &#39;1&#39;;

  var PY_KW = (&quot;False|None|True|and|as|assert|async|await|break|class|continue|def|del|elif|&quot;
             + &quot;else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|&quot;
             + &quot;pass|raise|return|try|while|with|yield|self|match|case&quot;).split(&quot;|&quot;);

  var pyRe = new RegExp(
      &quot;(#[^\\n]*)&quot;                                        /* 1 comment */
    + &quot;|(\&quot;\&quot;\&quot;[\\s\\S]*?\&quot;\&quot;\&quot;|&#39;&#39;&#39;[\\s\\S]*?&#39;&#39;&#39;&quot;          /* 2 triple strings */
    +   &quot;|\&quot;(?:\\\\.|[^\&quot;\\\\\\n])*\&quot;|&#39;(?:\\\\.|[^&#39;\\\\\\n])*&#39;)&quot;
    + &quot;|(@[\\w.]+)&quot;                                        /* 3 decorator */
    + &quot;|\\b(&quot; + PY_KW.join(&quot;|&quot;) + &quot;)\\b&quot;                   /* 4 keyword */
    + &quot;|\\b(\\d[\\w.]*)\\b&quot;                                /* 5 number */
    + &quot;|\\b([a-zA-Z_]\\w*)(?=\\()&quot;                         /* 6 call */
    , &quot;g&quot;);

  var shRe = /(#[^\n]*)|(&quot;(?:\\.|[^&quot;\\])*&quot;|&#39;(?:\\.|[^&#39;\\])*&#39;)|(^|\s)(--?[\w-]+)/g;

  function esc(s) {
    return s.replace(/&amp;/g, &quot;&amp;amp;&quot;).replace(/&lt;/g, &quot;&amp;lt;&quot;).replace(/&gt;/g, &quot;&amp;gt;&quot;);
  }

  function highlightPy(text) {
    return esc(text).replace(pyRe, function (m, com, str, dec, kw, num, fn) {
      if (com) return &#39;&lt;span class=&quot;t-com&quot;&gt;&#39; + com + &quot;&lt;/span&gt;&quot;;
      if (str) return &#39;&lt;span class=&quot;t-str&quot;&gt;&#39; + str + &quot;&lt;/span&gt;&quot;;
      if (dec) return &#39;&lt;span class=&quot;t-dec&quot;&gt;&#39; + dec + &quot;&lt;/span&gt;&quot;;
      if (kw)  return &#39;&lt;span class=&quot;t-kw&quot;&gt;&#39;  + kw  + &quot;&lt;/span&gt;&quot;;
      if (num) return &#39;&lt;span class=&quot;t-num&quot;&gt;&#39; + num + &quot;&lt;/span&gt;&quot;;
      if (fn)  return &#39;&lt;span class=&quot;t-fn&quot;&gt;&#39;  + fn  + &quot;&lt;/span&gt;&quot;;
      return m;
    });
  }

  function highlightSh(text) {
    return esc(text).replace(shRe, function (m, com, str, pre, flag) {
      if (com)  return &#39;&lt;span class=&quot;t-com&quot;&gt;&#39; + com + &quot;&lt;/span&gt;&quot;;
      if (str)  return &#39;&lt;span class=&quot;t-str&quot;&gt;&#39; + str + &quot;&lt;/span&gt;&quot;;
      if (flag) return pre + &#39;&lt;span class=&quot;t-dec&quot;&gt;&#39; + flag + &quot;&lt;/span&gt;&quot;;
      return m;
    });
  }

  function highlightOut(text) {
    return esc(text)
      .replace(/\b(\d+ passed)\b/g, &#39;&lt;span class=&quot;t-pass&quot;&gt;$1&lt;/span&gt;&#39;)
      .replace(/\b(\d+ (?:failed|error[s]?))\b/g, &#39;&lt;span class=&quot;t-fail&quot;&gt;$1&lt;/span&gt;&#39;)
      .replace(/^(E .*)$/gm, &#39;&lt;span class=&quot;t-fail&quot;&gt;$1&lt;/span&gt;&#39;)
      .replace(/\b(PASSED)\b/g, &#39;&lt;span class=&quot;t-pass&quot;&gt;$1&lt;/span&gt;&#39;)
      .replace(/\b(FAILED|ERROR)\b/g, &#39;&lt;span class=&quot;t-fail&quot;&gt;$1&lt;/span&gt;&#39;);
  }

  root.querySelectorAll(&quot;pre code&quot;).forEach(function (el) {
    var raw = el.textContent;
    el.dataset.raw = raw;
    if (el.classList.contains(&quot;py&quot;))        el.innerHTML = highlightPy(raw);
    else if (el.classList.contains(&quot;out&quot;))  el.innerHTML = highlightOut(raw);
    else                                    el.innerHTML = highlightSh(raw);
  });

  root.querySelectorAll(&quot;.copy&quot;).forEach(function (btn) {
    btn.addEventListener(&quot;click&quot;, function (ev) {
      ev.preventDefault();
      var code = btn.closest(&quot;.snippet&quot;).querySelector(&quot;code&quot;);
      var text = code.dataset.raw || code.textContent;
      var done = function () {
        btn.textContent = &quot;copied&quot;;
        btn.classList.add(&quot;ok&quot;);
        setTimeout(function () { btn.textContent = &quot;copy&quot;; btn.classList.remove(&quot;ok&quot;); }, 1200);
      };
      if (navigator.clipboard &amp;&amp; navigator.clipboard.writeText) {
        navigator.clipboard.writeText(text).then(done, function () {});
      } else {
        var ta = document.createElement(&quot;textarea&quot;);
        ta.value = text; ta.style.position = &quot;fixed&quot;; ta.style.opacity = &quot;0&quot;;
        document.body.appendChild(ta); ta.select();
        try { document.execCommand(&quot;copy&quot;); done(); } catch (e) {}
        document.body.removeChild(ta);
      }
    });
  });
})();
&lt;/script&gt;
</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/7243656572586644763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2026/07/the-loop-variable-that-changed-late.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/7243656572586644763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/7243656572586644763'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2026/07/the-loop-variable-that-changed-late.html' title='The loop variable that changed: late binding and default arguments in Python'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-7204518010433143826</id><published>2026-07-28T07:01:40.443-07:00</published><updated>2026-07-28T07:37:49.077-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="fixtures"/><category scheme="http://www.blogger.com/atom/ns#" term="parametrize"/><category scheme="http://www.blogger.com/atom/ns#" term="pytest"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="python3"/><category scheme="http://www.blogger.com/atom/ns#" term="Testing"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial"/><title type='text'>pytest, from your first test to your own plugin</title><content type='html'>&lt;style&gt;
/* ------------------------------------------------------------------
   study.marearts.com article body — pytest guide.
   Every selector is scoped under #pt-guide so nothing leaks onto the
   theme chrome (post title, date header, sidebar, comments).

   Palette is derived from the blog&#39;s own Awesome Inc. dark theme so
   the post reads as native rather than as an embedded card:
     page background #2d3037   body text #cccccc
     links #f1c232 (gold)      link hover / post titles #29aae1
     date headers #8ce1f5
   There is no light variant on purpose. Blogger has no theme-toggle
   attribute, so a light default would be the only thing that ever
   rendered — which is exactly how this post shipped white the first
   time. Panels are graded around #2d3037 instead of using an absolute
   background, so the article never fights the page it sits on.
   ------------------------------------------------------------------ */
#pt-guide{
  --bg:transparent; --panel:#34383f; --panel2:#3b4048; --line:#454b54;
  --fg:#d4d7dc; --fg-strong:#eef0f3; --fg-dim:#a3a9b2; --fg-faint:#848b95;
  --accent:#f1c232; --accent-2:#29aae1; --warn:#ffb454; --danger:#ff7a84;
  --code-bg:#23262c; --code-fg:#d4d7dc;
  --kw:#c792ea; --str:#c3e88d; --com:#828a94; --num:#f78c6c;
  --dec:#ffcb6b; --fn:#82aaff; --inline-code:#e6d3ff;
  --pass:#4fd6b0; --fail:#ff7a84;
  --mono:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,&quot;JetBrains Mono&quot;,Menlo,Consolas,&quot;Liberation Mono&quot;,monospace;
  --sans:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif;
}
#pt-guide, #pt-guide *{box-sizing:border-box}
#pt-guide{
  background:var(--bg); color:var(--fg);
  font-family:var(--sans); font-size:16px; line-height:1.7;
  -webkit-font-smoothing:antialiased;
  /* No frame: the theme already pads the post column, so a border plus
     its own background would read as a widget pasted onto the page. */
  padding:2px 0 44px; border:0; border-radius:0;
}
#pt-guide .wrap{max-width:1000px;margin:0 auto;min-width:0}

/* headings */
#pt-guide h1{font-size:38px;line-height:1.18;letter-spacing:-.8px;margin:0 0 12px;color:var(--fg)}
#pt-guide .lede{font-size:18px;color:var(--fg-dim);max-width:70ch;margin:0 0 8px}
/* font-family is restated on h2/h4: the theme styles bare `h2` and `h4`
   with a `font:` shorthand, which sets Arial and beats plain inheritance
   from #pt-guide. */
#pt-guide h2{
  font-family:var(--sans);line-height:inherit;
  font-size:15px;text-transform:uppercase;letter-spacing:.1em;color:var(--accent-2);
  margin:64px 0 6px;padding-top:22px;border-top:1px solid var(--line);font-weight:700;
  scroll-margin-top:16px;
}
/* line-height is pinned to inherit rather than left undeclared: the
   site-wide tone CSS sets a heading line-height, and an undeclared
   property is the one thing an opt-out guard cannot protect if that
   guard ever fails to apply. `inherit` reproduces exactly what these
   headings render at today. */
#pt-guide h3{font-size:25px;line-height:inherit;letter-spacing:-.4px;margin:38px 0 10px;color:var(--fg-strong);scroll-margin-top:20px}
#pt-guide h4{font-family:var(--sans);font-size:16.5px;line-height:inherit;font-weight:600;margin:26px 0 8px;color:var(--fg-strong)}
#pt-guide p{max-width:74ch;margin:12px 0}
#pt-guide ul, #pt-guide ol{max-width:74ch;padding-left:22px;margin:10px 0}
/* The theme&#39;s `.main-inner .widget ul{list-style:none}` strips markers from
   every list in the post body, so the markers are put back explicitly. */
#pt-guide ul{list-style:disc}
#pt-guide ol{list-style:decimal}
#pt-guide li{margin:6px 0}
#pt-guide a{color:var(--accent)}
#pt-guide code{
  font-family:var(--mono);font-size:.875em;background:var(--panel2);
  padding:2px 6px;border-radius:4px;border:1px solid var(--line);color:var(--inline-code);
}
#pt-guide strong{color:var(--fg-strong);font-weight:650}
#pt-guide em{font-style:italic}

/* code blocks */
#pt-guide .snippet{margin:18px 0;border:1px solid var(--line);border-radius:10px;overflow:hidden;background:var(--code-bg)}
#pt-guide .snippet-head{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:7px 12px;background:var(--panel);border-bottom:1px solid var(--line);
}
#pt-guide .snippet-name{font-family:var(--mono);font-size:12px;color:var(--fg-faint)}
#pt-guide .snippet-name b{color:var(--fg-dim);font-weight:600}
#pt-guide .copy{
  background:transparent;border:1px solid var(--line);color:var(--fg-faint);
  font-size:11px;padding:3px 9px;border-radius:5px;cursor:pointer;font-family:var(--sans);line-height:1.4;
}
#pt-guide .copy:hover{color:var(--fg);border-color:var(--fg-faint)}
#pt-guide .copy.ok{color:var(--accent-2);border-color:var(--accent-2)}
#pt-guide pre{
  margin:0;padding:14px 16px;overflow-x:auto;background:var(--code-bg);
  font-family:var(--mono);font-size:13.5px;line-height:1.62;color:var(--code-fg);
  border:0;border-radius:0;
}
#pt-guide pre code{background:none;border:0;padding:0;font-size:inherit;color:inherit}
#pt-guide pre::-webkit-scrollbar{height:9px}
#pt-guide pre::-webkit-scrollbar-thumb{background:var(--line);border-radius:5px}
#pt-guide .out pre{color:var(--fg-dim)}
#pt-guide .out .snippet-name b{color:var(--warn)}

/* syntax colors */
#pt-guide .t-kw{color:var(--kw)}
#pt-guide .t-str{color:var(--str)}
#pt-guide .t-com{color:var(--com);font-style:italic}
#pt-guide .t-num{color:var(--num)}
#pt-guide .t-dec{color:var(--dec)}
#pt-guide .t-fn{color:var(--fn)}
#pt-guide .t-pass{color:var(--pass)}
#pt-guide .t-fail{color:var(--fail)}

/* callouts */
/* Info reads cyan, not gold: gold is the theme&#39;s link colour and would
   collide with .warn&#39;s amber at these low alphas. */
#pt-guide .note{
  border-left:3px solid var(--accent-2);background:rgba(41,170,225,.09);
  padding:12px 16px;margin:18px 0;border-radius:0 8px 8px 0;max-width:74ch;
}
#pt-guide .note.warn{border-color:var(--warn);background:rgba(255,180,84,.08)}
#pt-guide .note.trap{border-color:var(--danger);background:rgba(255,122,132,.08)}
#pt-guide .note .tag{
  display:block;font-size:10.5px;text-transform:uppercase;letter-spacing:.1em;
  font-weight:700;color:var(--accent-2);margin-bottom:3px;
}
#pt-guide .note.warn .tag{color:var(--warn)}
#pt-guide .note.trap .tag{color:var(--danger)}
#pt-guide .note p{margin:5px 0}
#pt-guide .note .tag code{
  background:none !important;border:0 !important;padding:0 !important;
  color:inherit !important;font-size:1em !important;
}

/* tables */
#pt-guide .table-wrap{overflow-x:auto;margin:18px 0}
#pt-guide table{border-collapse:collapse;width:100%;margin:0;font-size:14.5px;background:none}
#pt-guide th, #pt-guide td{text-align:left;padding:9px 13px;border:0;border-bottom:1px solid var(--line);vertical-align:top}
#pt-guide th{color:var(--fg-faint);font-size:11.5px;text-transform:uppercase;letter-spacing:.07em;font-weight:700}
#pt-guide td code{font-size:.9em}
#pt-guide tbody tr:hover{background:var(--panel)}

/* furniture */
#pt-guide .kicker{
  font-size:12px;font-weight:700;letter-spacing:.13em;text-transform:uppercase;
  color:var(--accent-2);margin-bottom:14px;
}
#pt-guide .rule{height:1px;background:var(--line);margin:30px 0 4px;max-width:74ch}

#pt-guide .toc{
  border:1px solid var(--line);border-radius:12px;background:var(--panel);
  padding:20px 24px;margin:34px 0 10px;max-width:74ch;
}
#pt-guide .toc h4{margin:0 0 14px;font-size:13px;text-transform:uppercase;letter-spacing:.1em;color:var(--fg-faint)}
#pt-guide .toc ol{margin:0;padding-left:20px;max-width:none}
#pt-guide .toc &gt; ol &gt; li{margin:14px 0}
#pt-guide .toc &gt; ol &gt; li &gt; a{text-decoration:none;font-weight:650;font-size:16.5px}
#pt-guide .toc a{text-decoration:none;color:var(--accent)}
#pt-guide .toc a:hover{text-decoration:underline}
#pt-guide .toc span{color:var(--fg-faint);font-weight:400;font-size:14px}
#pt-guide .toc ul{
  list-style:none;margin:7px 0 0;padding-left:0;max-width:none;
  display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:1px 18px;
}
#pt-guide .toc ul li{margin:0}
#pt-guide .toc ul a{font-size:14px;color:var(--fg-dim)}
#pt-guide .toc ul a:hover{color:var(--accent)}

#pt-guide .takeaway{
  border:1px solid var(--line);border-left:3px solid var(--accent-2);
  border-radius:0 12px 12px 0;background:var(--panel);
  padding:18px 22px;margin:26px 0;max-width:74ch;
}
#pt-guide .takeaway h4{margin:0 0 10px;font-size:14px;text-transform:uppercase;letter-spacing:.08em;color:var(--accent-2)}
#pt-guide .takeaway ul{margin:0;padding-left:20px}

/* Always stacked, never side by side: the theme&#39;s centre column is ~545px
   of content, so two code panes would each get ~265px and clip mid-token
   regardless of viewport width (the 900px media query never fires). */
#pt-guide .grid2{display:grid;grid-template-columns:1fr;gap:16px}
#pt-guide .grid2 .snippet{margin:0;min-width:0}
#pt-guide .pt-badge{
  display:inline-block;font-size:11px;padding:2px 8px;border-radius:20px;
  border:1px solid var(--line);color:var(--fg-faint);margin-left:8px;vertical-align:middle;
  letter-spacing:normal;line-height:1.4;text-align:left;background:none;
}
#pt-guide .kbd{
  font-family:var(--mono);font-size:12px;background:var(--panel2);border:1px solid var(--line);
  border-bottom-width:2px;border-radius:4px;padding:1px 6px;
}
#pt-guide .foot{
  margin-top:70px;padding-top:20px;border-top:1px solid var(--line);
  color:var(--fg-faint);font-size:13px;
}
/* ------------------------------------------------------------------
   The Blogger theme re-colours bare descendants of the post container:
   body{color:#cccccc}, .post-body ul li{color:#cccccc},
   .main-inner .widget ul li{color:#ffffff}, a:link{color:#f1c232},
   h2{color:#8ce1f5}, h4{color:#29aae1}. Re-assert the article palette
   here — #pt-guide carries an id, so it wins on specificity, and the
   !important guards cover the handful of host rules that use it too.
   Kept deliberately narrow: anything with a per-component colour of its
   own (.toc h4, .takeaway h4, .note .tag) must not be caught by these.
   ------------------------------------------------------------------ */
#pt-guide h1, #pt-guide h3{color:var(--fg-strong) !important}
#pt-guide h2{color:var(--accent-2) !important}
#pt-guide p{color:var(--fg) !important}
#pt-guide li{color:var(--fg) !important;padding:0;border:0}
#pt-guide .lede{color:var(--fg-dim) !important}
#pt-guide strong{color:var(--fg-strong) !important}
#pt-guide a, #pt-guide .toc a{color:var(--accent) !important}
#pt-guide .toc ul a{color:var(--fg-dim) !important}
#pt-guide a:hover, #pt-guide .toc ul a:hover{color:var(--accent) !important}
#pt-guide code{background:var(--panel2) !important;color:var(--inline-code) !important}
#pt-guide pre code{background:none !important;color:var(--code-fg) !important}
#pt-guide table{background:none !important;table-layout:auto !important}
#pt-guide th{background:var(--panel2) !important;color:var(--fg-faint) !important}
#pt-guide td{color:var(--fg) !important}
#pt-guide th, #pt-guide td{border-color:var(--line) !important}
#pt-guide tbody tr:hover{background:var(--panel) !important}

@media screen and (max-width:900px){
  #pt-guide{padding:2px 0 36px}
  #pt-guide table{font-size:13.5px}
}
@media screen and (max-width:640px){
  #pt-guide .toc ul{grid-template-columns:1fr}
}
&lt;/style&gt;

&lt;div id=&quot;pt-guide&quot; data-tone=&quot;self&quot;&gt;
&lt;div class=&quot;wrap&quot;&gt;

&lt;div class=&quot;kicker&quot;&gt;Python · Testing&lt;/div&gt;
&lt;p class=&quot;lede&quot;&gt;
  Most pytest tutorials stop right after &lt;code&gt;assert 1 + 1 == 2&lt;/code&gt;, which is roughly where the
  interesting part begins. This one keeps going — through fixtures, parametrization and the
  configuration that makes a suite pleasant to live with, and out the other side into hooks and
  plugins.
&lt;/p&gt;

&lt;div class=&quot;rule&quot;&gt;&lt;/div&gt;

&lt;p&gt;
  There is a moment in most Python projects where the test suite stops helping. It takes four minutes
  to run, three tests fail intermittently, and nobody remembers what &lt;code&gt;conftest.py&lt;/code&gt; is for. The
  tool is rarely the problem — pytest has an answer for each of those, and the answers are small.
&lt;/p&gt;
&lt;p&gt;
  So this is written as a path rather than a reference. Part 1 gets you productive with nothing but
  functions and &lt;code&gt;assert&lt;/code&gt;. Parts 2 and 3 cover fixtures and parametrization, which is where
  pytest stops being &quot;unittest with less typing&quot; and starts being a different tool. Part 4 is the
  boring, high-leverage material: layout, configuration, mocking, CI. Part 5 opens the hood.
&lt;/p&gt;
&lt;p&gt;
  Every runnable snippet here was executed against pytest 9.1.1 before publishing, and the terminal
  output is copied from real runs. Anything version-sensitive is flagged inline.
&lt;/p&gt;

&lt;div class=&quot;toc&quot;&gt;
  &lt;h4&gt;Contents&lt;/h4&gt;
  &lt;ol&gt;
    &lt;li&gt;
      &lt;a href=&quot;#pt-why&quot;&gt;Basics&lt;/a&gt;
      &lt;span&gt;— why pytest, then the mechanics you use every day&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-why&quot;&gt;Why pytest&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-first&quot;&gt;Your first test&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-discovery&quot;&gt;How tests are found&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-assert&quot;&gt;The assert statement&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-raises&quot;&gt;Exceptions and warnings&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-approx&quot;&gt;Comparing floats&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-running&quot;&gt;Running and selecting tests&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;#pt-fixture-basics&quot;&gt;Fixtures&lt;/a&gt;
      &lt;span&gt;— the feature that makes pytest a different tool&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-fixture-basics&quot;&gt;Fixture basics&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-teardown&quot;&gt;Setup and teardown&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-scope&quot;&gt;Scopes&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-conftest&quot;&gt;conftest.py&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-builtin&quot;&gt;Built-in fixtures&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-factory&quot;&gt;Factory fixtures&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;#pt-param&quot;&gt;Parametrizing&lt;/a&gt;
      &lt;span&gt;— one function, many independently reported cases&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-param&quot;&gt;parametrize&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-param-ids&quot;&gt;Readable IDs&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-param-marks&quot;&gt;Per-case marks&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-param-fixture&quot;&gt;Parametrized fixtures&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-indirect&quot;&gt;Indirect parametrization&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;#pt-layout&quot;&gt;Practical&lt;/a&gt;
      &lt;span&gt;— the unglamorous, high-leverage material&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-layout&quot;&gt;Project layout&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-config&quot;&gt;Configuration&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-markers&quot;&gt;Markers, skip and xfail&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-mocking&quot;&gt;Mocking&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-output&quot;&gt;Output and logging&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-coverage&quot;&gt;Coverage&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-speed&quot;&gt;Speed&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-debug&quot;&gt;Debugging a failure&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-ci&quot;&gt;CI recipe&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;#pt-hooks&quot;&gt;Advanced&lt;/a&gt;
      &lt;span&gt;— under the hood, and how to extend it&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-hooks&quot;&gt;Hooks&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-addoption&quot;&gt;Custom CLI options&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-generate&quot;&gt;pytest_generate_tests&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-plugin&quot;&gt;Writing a plugin&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-helpers&quot;&gt;Custom assertion helpers&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-rewriting&quot;&gt;Why plain assert works&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-async&quot;&gt;Async tests&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-hypothesis&quot;&gt;Property-based testing&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-flaky&quot;&gt;Flaky tests and isolation&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;#pt-antipatterns&quot;&gt;Reference&lt;/a&gt;
      &lt;span&gt;— what to avoid, and a one-screen summary&lt;/span&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-antipatterns&quot;&gt;Anti-patterns&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-cheatsheet&quot;&gt;Cheat sheet&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-closing&quot;&gt;Wrapping up&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#pt-further&quot;&gt;Further reading&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;


&lt;!-- ==================== PART 1 ==================== --&gt;
&lt;h2&gt;Part 1 · Basics&lt;/h2&gt;

&lt;h3 id=&quot;pt-why&quot;&gt;Why pytest&lt;/h3&gt;
&lt;p&gt;
  Python ships with &lt;code&gt;unittest&lt;/code&gt;, a port of Java&#39;s JUnit. It works, but it makes you inherit from a
  base class, remember a different assert method for every comparison, and wrap setup logic in
  &lt;code&gt;setUp&lt;/code&gt; methods that run for every test whether you need them or not.
&lt;/p&gt;
&lt;p&gt;pytest replaces all of that with plain functions and the plain &lt;code&gt;assert&lt;/code&gt; keyword.&lt;/p&gt;

&lt;div class=&quot;grid2&quot;&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;unittest&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import unittest

class TestMath(unittest.TestCase):
    def setUp(self):
        self.values = [1, 2, 3]

    def test_sum(self):
        self.assertEqual(sum(self.values), 6)

    def test_membership(self):
        self.assertIn(2, self.values)
        self.assertNotIn(9, self.values)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;pytest&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import pytest

@pytest.fixture
def values():
    return [1, 2, 3]

def test_sum(values):
    assert sum(values) == 6

def test_membership(values):
    assert 2 in values
    assert 9 not in values&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;
  The pytest version has no class, no inheritance, and no assertion vocabulary to memorise. It is also
  strictly more capable: &lt;code&gt;values&lt;/code&gt; is a &lt;em&gt;fixture&lt;/em&gt;, and unlike &lt;code&gt;setUp&lt;/code&gt; it only runs for tests
  that actually ask for it.
&lt;/p&gt;
&lt;p&gt;
  pytest also runs &lt;code&gt;unittest&lt;/code&gt; test cases as-is, so adopting it never requires a big-bang migration.
&lt;/p&gt;


&lt;h3 id=&quot;pt-first&quot;&gt;Your first test&lt;/h3&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;install&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;python -m pip install pytest&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Create two files side by side.&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;slugify.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import re

def slugify(title: str) -&gt; str:
    &quot;&quot;&quot;Turn a human title into a URL-safe slug.&quot;&quot;&quot;
    cleaned = re.sub(r&quot;[^\w\s-]&quot;, &quot;&quot;, title.lower())
    return re.sub(r&quot;[\s_]+&quot;, &quot;-&quot;, cleaned).strip(&quot;-&quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;test_slugify.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;from slugify import slugify

def test_lowercases_and_joins_words():
    assert slugify(&quot;Hello World&quot;) == &quot;hello-world&quot;

def test_strips_punctuation():
    assert slugify(&quot;What&#39;s new?!&quot;) == &quot;whats-new&quot;

def test_collapses_whitespace():
    assert slugify(&quot;too    many   spaces&quot;) == &quot;too-many-spaces&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; pytest -q&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;...                                                            [100%]
3 passed in 0.01s&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Three dots, three passing tests. There is no registration step, no test suite object, no
  &lt;code&gt;if __name__ == &quot;__main__&quot;&lt;/code&gt;. pytest found the file, found the functions, and ran them.
&lt;/p&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Run it from the right place&lt;/span&gt;
  &lt;p&gt;
    pytest inserts the test file&#39;s directory (technically its &lt;em&gt;rootdir&lt;/em&gt; for that file) into
    &lt;code&gt;sys.path&lt;/code&gt;, which is why &lt;code&gt;from slugify import slugify&lt;/code&gt; works here. For real projects use
    the layout in &lt;a href=&quot;#pt-layout&quot;&gt;Project layout&lt;/a&gt; instead of relying on this.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-discovery&quot;&gt;How tests are found&lt;/h3&gt;
&lt;p&gt;Discovery is convention-driven. pytest walks the directories you give it (or the current one) and collects:&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Level&lt;/th&gt;&lt;th&gt;Default rule&lt;/th&gt;&lt;th&gt;Config key&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;Files&lt;/td&gt;&lt;td&gt;&lt;code&gt;test_*.py&lt;/code&gt; or &lt;code&gt;*_test.py&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;python_files&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Classes&lt;/td&gt;&lt;td&gt;&lt;code&gt;Test*&lt;/code&gt;, and it must not define &lt;code&gt;__init__&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;python_classes&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Functions&lt;/td&gt;&lt;td&gt;&lt;code&gt;test*&lt;/code&gt;, at module level or inside a collected class&lt;/td&gt;&lt;td&gt;&lt;code&gt;python_functions&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;
  Ask pytest what it would run without running anything. This is the single most useful command when
  a test &quot;isn&#39;t running&quot;:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;dry run&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;pytest --collect-only -q&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Common trap&lt;/span&gt;
  &lt;p&gt;
    A test class with an &lt;code&gt;__init__&lt;/code&gt; method is silently skipped — pytest cannot instantiate it, so
    it warns and moves on. If a whole class mysteriously vanishes, that is almost always why.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-assert&quot;&gt;The assert statement&lt;/h3&gt;
&lt;p&gt;
  pytest rewrites the bytecode of your test modules at import time so that a failing &lt;code&gt;assert&lt;/code&gt;
  reports the value of every subexpression. You get JUnit-grade diagnostics from the plain keyword.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;test_report.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def build_report():
    return {&quot;rows&quot;: 41, &quot;status&quot;: &quot;ok&quot;, &quot;tags&quot;: [&quot;a&quot;, &quot;b&quot;]}

def test_report_shape():
    report = build_report()
    assert report == {&quot;rows&quot;: 42, &quot;status&quot;: &quot;ok&quot;, &quot;tags&quot;: [&quot;a&quot;, &quot;c&quot;]}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; pytest -q&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;    def test_report_shape():
        report = build_report()
&amp;gt;       assert report == {&quot;rows&quot;: 42, &quot;status&quot;: &quot;ok&quot;, &quot;tags&quot;: [&quot;a&quot;, &quot;c&quot;]}
E       AssertionError: assert {&#39;rows&#39;: 41, ...&#39;: [&#39;a&#39;, &#39;b&#39;]} == {&#39;rows&#39;: 42, ...&#39;: [&#39;a&#39;, &#39;c&#39;]}
E
E         Omitting 1 identical items, use -vv to show
E         Differing items:
E         {&#39;rows&#39;: 41} != {&#39;rows&#39;: 42}
E         {&#39;tags&#39;: [&#39;a&#39;, &#39;b&#39;]} != {&#39;tags&#39;: [&#39;a&#39;, &#39;c&#39;]}
E         Use -v to get more diff

test_report.py:6: AssertionError
1 failed in 0.02s&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  pytest knows how to diff dicts, lists, sets, strings and dataclasses. Add &lt;code&gt;-vv&lt;/code&gt; when the diff is
  truncated — it disables the shortening.
&lt;/p&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Add a message only when it adds information&lt;/span&gt;
  &lt;p&gt;
    &lt;code&gt;assert x == y, &quot;x should equal y&quot;&lt;/code&gt; is noise; the rewriting already showed you that.
    A good message supplies context the values cannot: &lt;code&gt;assert resp.ok, f&quot;upstream said {resp.text}&quot;&lt;/code&gt;.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-raises&quot;&gt;Exceptions and warnings&lt;/h3&gt;
&lt;p&gt;
  Use &lt;code&gt;pytest.raises&lt;/code&gt; as a context manager. The test fails if the block does &lt;em&gt;not&lt;/em&gt; raise.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;test_errors.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import pytest

def withdraw(balance, amount):
    if amount &amp;lt;= 0:
        raise ValueError(f&quot;amount must be positive, got {amount}&quot;)
    if amount &amp;gt; balance:
        raise ValueError(&quot;insufficient funds&quot;)
    return balance - amount

def test_rejects_negative_amount():
    with pytest.raises(ValueError):
        withdraw(100, -5)

def test_error_message_names_the_amount():
    # match= is a regex applied with re.search against str(exception)
    with pytest.raises(ValueError, match=r&quot;must be positive, got -5&quot;):
        withdraw(100, -5)

def test_inspect_the_exception_object():
    with pytest.raises(ValueError) as excinfo:
        withdraw(100, 500)
    assert &quot;insufficient&quot; in str(excinfo.value)
    assert excinfo.type is ValueError&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Assert after the block, not inside it&lt;/span&gt;
  &lt;p&gt;
    Code placed after the raising line inside a &lt;code&gt;with pytest.raises(...)&lt;/code&gt; block never executes.
    Anything you want to check about the exception goes &lt;em&gt;after&lt;/em&gt; the block using
    &lt;code&gt;excinfo.value&lt;/code&gt;.
  &lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;Warnings have a mirror-image API:&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;warnings&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import warnings, pytest

def legacy_api():
    warnings.warn(&quot;use new_api() instead&quot;, DeprecationWarning, stacklevel=2)
    return 42

def test_warns():
    with pytest.warns(DeprecationWarning, match=&quot;new_api&quot;):
        assert legacy_api() == 42&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-approx&quot;&gt;Comparing floats&lt;/h3&gt;
&lt;p&gt;
  &lt;code&gt;0.1 + 0.2 == 0.3&lt;/code&gt; is &lt;code&gt;False&lt;/code&gt; in binary floating point. &lt;code&gt;pytest.approx&lt;/code&gt; wraps a value
  with a tolerance and works on scalars, sequences, dicts and numpy arrays.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;approx&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;from pytest import approx

def test_scalar():
    assert 0.1 + 0.2 == approx(0.3)

def test_explicit_tolerance():
    assert 4.7 == approx(4.7005, abs=1e-3)     # absolute
    assert 1_000_100 == approx(1_000_000, rel=1e-3)  # relative

def test_containers():
    assert [0.1 + 0.2, 1 / 3] == approx([0.3, 0.33333333])
    assert {&quot;loss&quot;: 0.1 + 0.2} == approx({&quot;loss&quot;: 0.3})&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  The default is a relative tolerance of 1e-6 with a small absolute floor, which is the right default
  for most numeric code. Say what you mean when precision actually matters.
&lt;/p&gt;


&lt;h3 id=&quot;pt-running&quot;&gt;Running and selecting tests&lt;/h3&gt;
&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Command&lt;/th&gt;&lt;th&gt;What it does&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Everything under the current directory&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest tests/unit&lt;/code&gt;&lt;/td&gt;&lt;td&gt;One directory&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest tests/test_api.py&lt;/code&gt;&lt;/td&gt;&lt;td&gt;One file&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest tests/test_api.py::test_login&lt;/code&gt;&lt;/td&gt;&lt;td&gt;One test — this is a &lt;em&gt;node id&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest &quot;tests/test_api.py::test_login[admin]&quot;&lt;/code&gt;&lt;/td&gt;&lt;td&gt;One parametrized case&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest -k &quot;login and not slow&quot;&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Substring/boolean match on names&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest -m integration&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Match a marker&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest -x&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Stop at the first failure&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest --maxfail=3&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Stop after three failures&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest -q&lt;/code&gt; / &lt;code&gt;-v&lt;/code&gt; / &lt;code&gt;-vv&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Quieter / one line per test / no truncated diffs&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest -rA&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Summary lines for every outcome, including passes&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest -s&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Don&#39;t capture stdout (see your &lt;code&gt;print&lt;/code&gt; calls live)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest --lf&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Only the tests that failed last run&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest --ff&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Everything, but last run&#39;s failures first&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest --sw&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Stepwise: stop at a failure, resume there next time&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;
  Node ids are copy-pasteable. When a test fails, the id in the output is exactly the argument you
  need to re-run just that case.
&lt;/p&gt;


&lt;!-- ==================== PART 2 ==================== --&gt;
&lt;h2&gt;Part 2 · Fixtures&lt;/h2&gt;

&lt;h3 id=&quot;pt-fixture-basics&quot;&gt;Fixture basics&lt;/h3&gt;
&lt;p&gt;
  A fixture is a function that produces something a test needs. Tests request fixtures by naming them
  as parameters, and pytest supplies them. That is the entire mental model — it is dependency
  injection with a decorator.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;request by name&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import pytest

@pytest.fixture
def inventory():
    return {&quot;apple&quot;: 3, &quot;pear&quot;: 0}

def test_has_apples(inventory):        # ← the parameter name is the fixture name
    assert inventory[&quot;apple&quot;] == 3

def test_pears_are_out_of_stock(inventory):
    assert inventory[&quot;pear&quot;] == 0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Each test gets a &lt;strong&gt;fresh&lt;/strong&gt; &lt;code&gt;inventory&lt;/code&gt; by default, so one test mutating the dict cannot
  affect another. That isolation is the reason fixtures beat module-level constants.
&lt;/p&gt;

&lt;p&gt;Fixtures can request other fixtures, forming a graph that pytest resolves for you:&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;composition&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;@pytest.fixture
def config():
    return {&quot;currency&quot;: &quot;EUR&quot;, &quot;vat&quot;: 0.21}

@pytest.fixture
def cart(config):                       # fixtures compose
    return {&quot;config&quot;: config, &quot;items&quot;: []}

def test_cart_uses_config(cart):
    assert cart[&quot;config&quot;][&quot;vat&quot;] == 0.21&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-teardown&quot;&gt;Setup and teardown&lt;/h3&gt;
&lt;p&gt;
  Replace &lt;code&gt;return&lt;/code&gt; with &lt;code&gt;yield&lt;/code&gt; and everything after the &lt;code&gt;yield&lt;/code&gt; becomes teardown. It runs
  even if the test fails, because pytest wraps it in a finalizer.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;yield fixture&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import sqlite3
import pytest

@pytest.fixture
def db():
    conn = sqlite3.connect(&quot;:memory:&quot;)
    conn.execute(&quot;CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)&quot;)
    yield conn                          # ← the test runs here
    conn.close()                        # ← always runs afterwards

def test_insert_and_read_back(db):
    db.execute(&quot;INSERT INTO users (name) VALUES (?)&quot;, (&quot;ada&quot;,))
    assert db.execute(&quot;SELECT name FROM users&quot;).fetchone() == (&quot;ada&quot;,)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Setup failures are errors, not failures&lt;/span&gt;
  &lt;p&gt;
    If the code &lt;em&gt;before&lt;/em&gt; &lt;code&gt;yield&lt;/code&gt; raises, pytest reports the test as an &lt;strong&gt;error&lt;/strong&gt; rather
    than a failure, and the test body never runs. That distinction in the summary line tells you
    instantly whether your production code or your scaffolding broke.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-scope&quot;&gt;Scopes&lt;/h3&gt;
&lt;p&gt;
  Expensive setup should not repeat per test. &lt;code&gt;scope&lt;/code&gt; controls how long one instance is cached and
  shared.
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Scope&lt;/th&gt;&lt;th&gt;Created once per&lt;/th&gt;&lt;th&gt;Typical use&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;function&lt;/code&gt; &lt;span class=&quot;pt-badge&quot;&gt;default&lt;/span&gt;&lt;/td&gt;&lt;td&gt;Test&lt;/td&gt;&lt;td&gt;Anything mutable&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;class&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Test class&lt;/td&gt;&lt;td&gt;Shared object for a group of methods&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;module&lt;/code&gt;&lt;/td&gt;&lt;td&gt;File&lt;/td&gt;&lt;td&gt;A parsed file, a compiled artifact&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;package&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Directory&lt;/td&gt;&lt;td&gt;Rare; a shared subsystem&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;session&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Whole run&lt;/td&gt;&lt;td&gt;Docker container, server process, big download&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;session scope&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;@pytest.fixture(scope=&quot;session&quot;)
def http_server():
    proc = start_server()               # slow: do it once for the whole run
    yield proc
    proc.terminate()

@pytest.fixture
def client(http_server):                # cheap per-test wrapper over the shared server
    return Client(http_server.url)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;The scope rule you will hit eventually&lt;/span&gt;
  &lt;p&gt;
    A fixture may only depend on fixtures of &lt;strong&gt;equal or wider&lt;/strong&gt; scope. A
    &lt;code&gt;session&lt;/code&gt; fixture requesting a &lt;code&gt;function&lt;/code&gt; fixture is an error, because the narrow one
    would be destroyed while the wide one still holds it.
  &lt;/p&gt;
  &lt;p&gt;
    And never let a widely scoped fixture hand out something mutable. One test appending to a
    &lt;code&gt;session&lt;/code&gt;-scoped list poisons every later test, producing failures that depend on run order.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-conftest&quot;&gt;conftest.py&lt;/h3&gt;
&lt;p&gt;
  Fixtures defined in &lt;code&gt;conftest.py&lt;/code&gt; are visible to every test in that directory and below, with no
  import needed. Nested &lt;code&gt;conftest.py&lt;/code&gt; files stack, and the closest definition wins.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;tree&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;tests/
├── conftest.py            # fixtures for everything below
├── unit/
│   └── test_parser.py
└── integration/
    ├── conftest.py        # extra fixtures, only for integration tests
    └── test_api.py&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;tests/conftest.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import pytest

@pytest.fixture(scope=&quot;session&quot;)
def sample_data():
    return {&quot;users&quot;: [&quot;ada&quot;, &quot;grace&quot;], &quot;version&quot;: 3}

@pytest.fixture
def frozen_clock(monkeypatch):
    &quot;&quot;&quot;Pin time.time() so timestamp assertions are deterministic.&quot;&quot;&quot;
    import time
    monkeypatch.setattr(time, &quot;time&quot;, lambda: 1_700_000_000.0)
    return 1_700_000_000.0&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;conftest.py is more than a fixture bucket&lt;/span&gt;
  &lt;p&gt;
    It is also where hooks, custom CLI options and plugin registration live. pytest imports it
    automatically — it must never be imported by hand, and it needs no &lt;code&gt;__init__.py&lt;/code&gt;.
  &lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;Where does a fixture come from? Ask:&lt;/p&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;list available fixtures&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;pytest --fixtures            # every fixture visible here, with docstrings
pytest --fixtures-per-test tests/test_api.py::test_login&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-builtin&quot;&gt;Built-in fixtures&lt;/h3&gt;
&lt;p&gt;These ship with pytest. Reach for them before writing your own.&lt;/p&gt;

&lt;h4&gt;&lt;code&gt;tmp_path&lt;/code&gt; — a real, empty directory per test&lt;/h4&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;tmp_path&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def test_writes_a_csv(tmp_path):
    target = tmp_path / &quot;out.csv&quot;       # tmp_path is a pathlib.Path
    target.write_text(&quot;id,name\n1,ada\n&quot;)

    assert target.exists()
    assert target.read_text().splitlines()[0] == &quot;id,name&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  pytest keeps the last few runs&#39; directories on disk for post-mortem inspection and cleans up older
  ones. Use &lt;code&gt;tmp_path_factory&lt;/code&gt; for a directory shared across a session.
&lt;/p&gt;

&lt;h4&gt;&lt;code&gt;monkeypatch&lt;/code&gt; — scoped, auto-undone patching&lt;/h4&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;monkeypatch&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def test_reads_token_from_environment(monkeypatch):
    monkeypatch.setenv(&quot;API_TOKEN&quot;, &quot;secret&quot;)
    monkeypatch.delenv(&quot;HTTP_PROXY&quot;, raising=False)
    assert load_config().token == &quot;secret&quot;

def test_patch_an_attribute(monkeypatch):
    monkeypatch.setattr(&quot;myapp.net.fetch&quot;, lambda url: {&quot;ok&quot;: True})
    assert myapp.summarize(&quot;http://x&quot;) == &quot;ok&quot;

def test_run_from_another_directory(monkeypatch, tmp_path):
    monkeypatch.chdir(tmp_path)         # undone automatically
    assert Path.cwd() == tmp_path&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  Every change is reverted when the test ends, including failures. That is the whole point: hand-rolled
  &lt;code&gt;os.environ[...] = ...&lt;/code&gt; leaks into subsequent tests.
&lt;/p&gt;

&lt;h4&gt;&lt;code&gt;capsys&lt;/code&gt; and &lt;code&gt;caplog&lt;/code&gt; — captured output&lt;/h4&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;capsys / caplog&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import logging

def test_prints_a_banner(capsys):
    print(&quot;READY&quot;)
    captured = capsys.readouterr()      # consumes the buffer
    assert captured.out == &quot;READY\n&quot;
    assert captured.err == &quot;&quot;

def test_logs_a_warning(caplog):
    with caplog.at_level(logging.WARNING):
        logging.getLogger(&quot;app&quot;).warning(&quot;disk almost full&quot;)
    assert &quot;disk almost full&quot; in caplog.text
    assert caplog.records[0].levelno == logging.WARNING&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Use &lt;code&gt;capfd&lt;/code&gt; instead of &lt;code&gt;capsys&lt;/code&gt; when the output comes from a subprocess or a C extension.&lt;/p&gt;

&lt;h4&gt;&lt;code&gt;request&lt;/code&gt; — introspection&lt;/h4&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;request&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;@pytest.fixture
def workspace(request, tmp_path):
    &quot;&quot;&quot;Name the directory after the test that asked for it.&quot;&quot;&quot;
    d = tmp_path / request.node.name
    d.mkdir()
    return d&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-factory&quot;&gt;Factory fixtures&lt;/h3&gt;
&lt;p&gt;
  When a test needs &lt;em&gt;several&lt;/em&gt; of a thing, or needs to choose parameters, return a function instead
  of a value. Track what you create so teardown stays correct.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;factory-as-fixture&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import pytest

@pytest.fixture
def make_user(db):
    created = []

    def _make(name, admin=False):
        cur = db.execute(
            &quot;INSERT INTO users (name, admin) VALUES (?, ?)&quot;, (name, admin)
        )
        created.append(cur.lastrowid)
        return {&quot;id&quot;: cur.lastrowid, &quot;name&quot;: name, &quot;admin&quot;: admin}

    yield _make

    for user_id in created:             # clean up exactly what this test made
        db.execute(&quot;DELETE FROM users WHERE id = ?&quot;, (user_id,))

def test_admins_can_see_everyone(make_user):
    admin = make_user(&quot;ada&quot;, admin=True)
    make_user(&quot;grace&quot;)
    make_user(&quot;alan&quot;)
    assert len(visible_users(admin)) == 3&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;!-- ==================== PART 3 ==================== --&gt;
&lt;h2&gt;Part 3 · Parametrizing&lt;/h2&gt;

&lt;h3 id=&quot;pt-param&quot;&gt;parametrize&lt;/h3&gt;
&lt;p&gt;
  One test function, many cases. Each case is a separate test: it gets its own node id, its own
  pass/fail, and one failing case does not hide the others.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;basic&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import pytest

@pytest.mark.parametrize(
    (&quot;title&quot;, &quot;expected&quot;),
    [
        (&quot;Hello World&quot;, &quot;hello-world&quot;),
        (&quot;What&#39;s new?!&quot;, &quot;whats-new&quot;),
        (&quot;  padded  &quot;, &quot;padded&quot;),
        (&quot;&quot;, &quot;&quot;),
    ],
)
def test_slugify(title, expected):
    assert slugify(title) == expected&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet out&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;$&lt;/b&gt; pytest -v&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;out&quot;&gt;test_slug.py::test_slugify[Hello World-hello-world] PASSED
test_slug.py::test_slugify[What&#39;s new?!-whats-new]   PASSED
test_slug.py::test_slugify[  padded  -padded]        PASSED
test_slug.py::test_slugify[-]                        PASSED&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Stacking decorators produces the cartesian product:&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;3 × 2 = 6 tests&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;@pytest.mark.parametrize(&quot;codec&quot;, [&quot;gzip&quot;, &quot;zstd&quot;, &quot;none&quot;])
@pytest.mark.parametrize(&quot;size&quot;, [0, 1_000_000])
def test_roundtrip(codec, size):
    payload = b&quot;x&quot; * size
    assert decompress(compress(payload, codec), codec) == payload&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Combinatorics grow fast&lt;/span&gt;
  &lt;p&gt;
    Stacking is convenient and dangerous. Three stacked decorators of five values each is 125 tests.
    Prefer an explicit list of meaningful tuples once the product stops being all-interesting.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-param-ids&quot;&gt;Readable IDs&lt;/h3&gt;
&lt;p&gt;
  Auto-generated ids come from the values, which is unreadable for objects and awkward for long
  strings. Name your cases — the id is what you will read in CI output and paste on the command line.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;ids=&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;@pytest.mark.parametrize(
    (&quot;payload&quot;, &quot;expected&quot;),
    [
        ({&quot;v&quot;: 1}, True),
        ({&quot;v&quot;: 1, &quot;extra&quot;: None}, True),
        ({}, False),
    ],
    ids=[&quot;minimal&quot;, &quot;with-nulls&quot;, &quot;empty&quot;],
)
def test_validate(payload, expected):
    assert validate(payload) is expected&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;A dict keeps the name and the data in one place, which stops them drifting apart:&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;dict-driven cases&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;CASES = {
    &quot;empty-input&quot;:     (&quot;&quot;,        []),
    &quot;single-token&quot;:    (&quot;a&quot;,       [&quot;a&quot;]),
    &quot;trailing-comma&quot;:  (&quot;a,b,&quot;,    [&quot;a&quot;, &quot;b&quot;]),
    &quot;quoted-comma&quot;:    (&#39;&quot;a,b&quot;,c&#39;, [&quot;a,b&quot;, &quot;c&quot;]),
}

@pytest.mark.parametrize(
    (&quot;raw&quot;, &quot;expected&quot;), list(CASES.values()), ids=list(CASES.keys())
)
def test_parse_csv_line(raw, expected):
    assert parse_csv_line(raw) == expected&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-param-marks&quot;&gt;Per-case marks&lt;/h3&gt;
&lt;p&gt;
  &lt;code&gt;pytest.param&lt;/code&gt; attaches a mark or an id to a single case, so one known-broken input does not force
  you to skip the whole function.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;pytest.param&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;@pytest.mark.parametrize(
    (&quot;raw&quot;, &quot;expected&quot;),
    [
        (&quot;2024-01-01&quot;, date(2024, 1, 1)),
        pytest.param(&quot;01/01/2024&quot;, date(2024, 1, 1), id=&quot;us-format&quot;),
        pytest.param(
            &quot;2024-W01-1&quot;, date(2024, 1, 1),
            marks=pytest.mark.xfail(reason=&quot;ISO week dates not supported yet&quot;),
        ),
        pytest.param(
            &quot;yesterday&quot;, date(2024, 1, 1),
            marks=pytest.mark.skipif(sys.platform == &quot;win32&quot;, reason=&quot;needs GNU date&quot;),
        ),
    ],
)
def test_parse_date(raw, expected):
    assert parse_date(raw) == expected&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-param-fixture&quot;&gt;Parametrized fixtures&lt;/h3&gt;
&lt;p&gt;
  Put &lt;code&gt;params&lt;/code&gt; on the fixture and every test using it runs once per value. This is how you sweep a
  whole suite across backends without touching a single test body.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;fixture params&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;@pytest.fixture(params=[&quot;sqlite&quot;, &quot;postgres&quot;], ids=[&quot;sqlite&quot;, &quot;pg&quot;])
def store(request):
    backend = request.param             # ← the current value
    s = open_store(backend)
    yield s
    s.close()

# both of these now run twice, once per backend
def test_put_then_get(store):
    store.put(&quot;k&quot;, &quot;v&quot;)
    assert store.get(&quot;k&quot;) == &quot;v&quot;

def test_missing_key_returns_none(store):
    assert store.get(&quot;nope&quot;) is None&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-indirect&quot;&gt;Indirect parametrization&lt;/h3&gt;
&lt;p&gt;
  &lt;code&gt;indirect=True&lt;/code&gt; routes the parameter &lt;em&gt;through&lt;/em&gt; a fixture rather than into the test. Use it when
  the value needs setup before the test can see it.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;indirect&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;@pytest.fixture
def user(request):
    role = request.param                # comes from parametrize, not from the test
    return create_user(role=role)

@pytest.mark.parametrize(&quot;user&quot;, [&quot;admin&quot;, &quot;viewer&quot;], indirect=True)
def test_dashboard_access(user):
    assert user.can_open_dashboard() is (user.role == &quot;admin&quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Mix direct and indirect by naming which arguments are indirect:&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;partial indirect&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;@pytest.mark.parametrize(
    (&quot;user&quot;, &quot;expected&quot;),
    [(&quot;admin&quot;, True), (&quot;viewer&quot;, False)],
    indirect=[&quot;user&quot;],                  # only `user` goes through the fixture
)
def test_dashboard_access(user, expected):
    assert user.can_open_dashboard() is expected&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;!-- ==================== PART 4 ==================== --&gt;
&lt;h2&gt;Part 4 · Practical&lt;/h2&gt;

&lt;h3 id=&quot;pt-layout&quot;&gt;Project layout&lt;/h3&gt;
&lt;p&gt;
  The &lt;code&gt;src&lt;/code&gt; layout is the one that avoids import surprises: your package is not importable from the
  repository root, so tests are forced to import the &lt;em&gt;installed&lt;/em&gt; package — the same thing your users get.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;recommended&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;myproject/
├── pyproject.toml
├── src/
│   └── myproject/
│       ├── __init__.py
│       └── core.py
└── tests/
    ├── conftest.py
    ├── unit/
    │   └── test_core.py
    └── integration/
        └── test_end_to_end.py&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;install once, then test&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;python -m pip install -e &quot;.[dev]&quot;
pytest&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Do not put &lt;code&gt;__init__.py&lt;/code&gt; in tests/&lt;/span&gt;
  &lt;p&gt;
    Without it, test modules are imported as top-level modules — which means two files named
    &lt;code&gt;test_utils.py&lt;/code&gt; in different directories will collide. Either give them distinct names, or add
    &lt;code&gt;__init__.py&lt;/code&gt; files and accept package semantics. The distinct-names route is simpler.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-config&quot;&gt;Configuration&lt;/h3&gt;
&lt;p&gt;
  One config block removes a lot of repeated typing and makes local runs match CI. &lt;code&gt;pyproject.toml&lt;/code&gt;
  is the modern home; &lt;code&gt;pytest.ini&lt;/code&gt; and &lt;code&gt;setup.cfg&lt;/code&gt; still work.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;pyproject.toml&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;toml&quot;&gt;[tool.pytest.ini_options]
minversion = &quot;8.0&quot;
testpaths = [&quot;tests&quot;]
addopts = [
    &quot;-ra&quot;,                 # summary for all non-passing outcomes
    &quot;--strict-markers&quot;,    # unknown @pytest.mark.* becomes an error
    &quot;--strict-config&quot;,     # typos in this very section become an error
    &quot;--import-mode=importlib&quot;,
]
markers = [
    &quot;slow: takes more than a second&quot;,
    &quot;integration: needs external services&quot;,
]
filterwarnings = [
    &quot;error&quot;,                                   # warnings fail the suite ...
    &quot;ignore::DeprecationWarning:third_party.*&quot; # ... except from code you don&#39;t own
]&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Option&lt;/th&gt;&lt;th&gt;Why you want it&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--strict-markers&lt;/code&gt;&lt;/td&gt;&lt;td&gt;A typo like &lt;code&gt;@pytest.mark.slwo&lt;/code&gt; silently does nothing otherwise&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;filterwarnings = [&quot;error&quot;]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Catches deprecations while they are cheap to fix&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;testpaths&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Bare &lt;code&gt;pytest&lt;/code&gt; stops walking &lt;code&gt;.venv&lt;/code&gt;, &lt;code&gt;build&lt;/code&gt;, docs&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--import-mode=importlib&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Modern import semantics; avoids &lt;code&gt;sys.path&lt;/code&gt; surgery&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-markers&quot;&gt;Markers, skip and xfail&lt;/h3&gt;
&lt;p&gt;Markers are labels. You attach them to tests and select on them later.&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;marking&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import pytest

@pytest.mark.slow
def test_full_reindex():
    ...

@pytest.mark.integration
class TestPaymentGateway:          # applies to every method in the class
    def test_charge(self): ...
    def test_refund(self): ...

pytestmark = pytest.mark.integration   # module-level: applies to the whole file&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;selecting&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;pytest -m slow                  # only slow
pytest -m &quot;not slow&quot;            # everything else
pytest -m &quot;integration and not slow&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h4&gt;skip vs xfail&lt;/h4&gt;
&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Construct&lt;/th&gt;&lt;th&gt;Meaning&lt;/th&gt;&lt;th&gt;When&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;@pytest.mark.skip(reason=…)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Never run it&lt;/td&gt;&lt;td&gt;Temporarily irrelevant&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;@pytest.mark.skipif(cond, reason=…)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Run only if the condition is false&lt;/td&gt;&lt;td&gt;Platform / version / optional dependency&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest.skip(reason)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Skip from inside the test&lt;/td&gt;&lt;td&gt;Decision needs runtime information&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest.importorskip(&quot;numpy&quot;)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Skip if the import fails&lt;/td&gt;&lt;td&gt;Optional dependency&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;@pytest.mark.xfail(reason=…)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Run it; a failure is expected&lt;/td&gt;&lt;td&gt;Known bug, with a test that proves it&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;the useful forms&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import sys, pytest

@pytest.mark.skipif(sys.version_info &amp;lt; (3, 12), reason=&quot;uses PEP 695 syntax&quot;)
def test_new_generics(): ...

def test_needs_a_gpu():
    if not gpu_present():
        pytest.skip(&quot;no GPU on this runner&quot;)
    ...

pandas = pytest.importorskip(&quot;pandas&quot;, minversion=&quot;2.0&quot;)

@pytest.mark.xfail(strict=True, reason=&quot;bug #482: rounds half-down&quot;)
def test_rounds_half_up():
    assert round_half_up(0.5) == 1&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Prefer &lt;code&gt;xfail(strict=True)&lt;/code&gt; over &lt;code&gt;skip&lt;/code&gt; for known bugs&lt;/span&gt;
  &lt;p&gt;
    A strict xfail that starts passing becomes a &lt;strong&gt;failure&lt;/strong&gt;. That is the feature: the day someone
    fixes the bug, the suite tells you to delete the marker. A skipped test just rots.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-mocking&quot;&gt;Mocking&lt;/h3&gt;
&lt;p&gt;
  Two tools, two jobs. &lt;code&gt;monkeypatch&lt;/code&gt; replaces an attribute for the duration of a test.
  &lt;code&gt;unittest.mock&lt;/code&gt; additionally &lt;em&gt;records&lt;/em&gt; how the replacement was used.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;monkeypatch: substitute behaviour&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def test_retries_on_timeout(monkeypatch):
    calls = []

    def flaky_get(url):
        calls.append(url)
        if len(calls) &amp;lt; 3:
            raise TimeoutError
        return {&quot;status&quot;: &quot;ok&quot;}

    monkeypatch.setattr(&quot;myapp.client.get&quot;, flaky_get)
    assert fetch_with_retry(&quot;http://x&quot;)[&quot;status&quot;] == &quot;ok&quot;
    assert len(calls) == 3&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;mock: assert on the interaction&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;from unittest.mock import patch, MagicMock

def test_sends_exactly_one_email():
    with patch(&quot;myapp.mailer.send&quot;) as send:
        send.return_value = MagicMock(status=202)
        register_user(&quot;ada@example.com&quot;)

    send.assert_called_once_with(
        to=&quot;ada@example.com&quot;, template=&quot;welcome&quot;
    )&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Patch where it is looked up&lt;/span&gt;
  &lt;p&gt;
    If &lt;code&gt;myapp/service.py&lt;/code&gt; does &lt;code&gt;from myapp.mailer import send&lt;/code&gt;, then patching
    &lt;code&gt;&quot;myapp.mailer.send&quot;&lt;/code&gt; has no effect — &lt;code&gt;service&lt;/code&gt; already holds its own reference.
    Patch &lt;code&gt;&quot;myapp.service.send&quot;&lt;/code&gt;, the name in the module &lt;em&gt;using&lt;/em&gt; it.
  &lt;/p&gt;
&lt;/div&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Mocking is a smell in proportion to its depth&lt;/span&gt;
  &lt;p&gt;
    Mocking a network boundary is good. Mocking five internal collaborators means the test now asserts
    your implementation&#39;s shape rather than its behaviour, and it will break on every refactor while
    catching no bugs. Consider a fake object or a real in-memory implementation instead.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-output&quot;&gt;Output and logging&lt;/h3&gt;
&lt;p&gt;
  pytest captures stdout, stderr and logging, then prints them &lt;em&gt;only for failing tests&lt;/em&gt;. That is why
  your &lt;code&gt;print&lt;/code&gt; statements seem to vanish on success.
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Flag&lt;/th&gt;&lt;th&gt;Effect&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;-s&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Disable capture entirely — output streams live&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--capture=no&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Same as &lt;code&gt;-s&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--log-cli-level=DEBUG&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Stream log records to the terminal as they happen&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--show-capture=no&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Hide captured output even on failures&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-coverage&quot;&gt;Coverage&lt;/h3&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;pytest-cov&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;python -m pip install pytest-cov

pytest --cov=myproject --cov-report=term-missing
pytest --cov=myproject --cov-report=html      # then open htmlcov/index.html
pytest --cov=myproject --cov-fail-under=85    # gate in CI&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Coverage measures execution, not verification&lt;/span&gt;
  &lt;p&gt;
    A test that calls a function and asserts nothing still counts as full coverage of it. Treat the
    number as a way to &lt;em&gt;find untested code&lt;/em&gt;, never as evidence that tested code is correct.
    Branch coverage (&lt;code&gt;--cov-branch&lt;/code&gt;) is a strictly better signal than line coverage.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-speed&quot;&gt;Speed&lt;/h3&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;find and fix slowness&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;pytest --durations=10          # the 10 slowest tests, with setup/teardown split out

python -m pip install pytest-xdist
pytest -n auto                 # one worker per CPU
pytest -n 4 --dist loadfile    # keep each file on a single worker&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  Parallelism exposes hidden coupling: tests that only pass in a particular order will start failing.
  That is a bug being surfaced, not a bug being introduced.
&lt;/p&gt;


&lt;h3 id=&quot;pt-debug&quot;&gt;Debugging a failure&lt;/h3&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;the loop&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;pytest -x -q                   # 1. stop at the first failure
pytest --lf -x                 # 2. iterate on just that one
pytest --lf -x --pdb           # 3. drop into a debugger at the failure point
pytest --lf -x -vv --tb=long   # 4. full diffs and full traceback
pytest -q                      # 5. confirm the whole suite is green again&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Flag&lt;/th&gt;&lt;th&gt;Traceback style&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--tb=long&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Every frame, fully expanded &lt;span class=&quot;pt-badge&quot;&gt;default&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--tb=short&lt;/code&gt;&lt;/td&gt;&lt;td&gt;One line per frame — best for CI logs&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--tb=line&lt;/code&gt;&lt;/td&gt;&lt;td&gt;One line per failure&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--tb=no&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Names only&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;
  &lt;code&gt;breakpoint()&lt;/code&gt; works inside tests as long as capture is off (&lt;code&gt;-s&lt;/code&gt;), and &lt;code&gt;--pdb&lt;/code&gt; opens a
  debugger &lt;em&gt;at the moment of failure&lt;/em&gt; with the whole frame still alive — usually faster than
  guessing where to put the breakpoint.
&lt;/p&gt;


&lt;h3 id=&quot;pt-ci&quot;&gt;CI recipe&lt;/h3&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;GitHub Actions&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;yaml&quot;&gt;name: tests
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: [&quot;3.10&quot;, &quot;3.11&quot;, &quot;3.12&quot;, &quot;3.13&quot;]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
          cache: pip
      - run: python -m pip install -e &quot;.[dev]&quot;
      - run: pytest -ra --tb=short --durations=10 --cov --cov-report=xml -n auto&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  &lt;code&gt;fail-fast: false&lt;/code&gt; matters: without it, one failing Python version cancels the others and hides
  whether the problem is version-specific.
&lt;/p&gt;


&lt;!-- ==================== PART 5 ==================== --&gt;
&lt;h2&gt;Part 5 · Advanced&lt;/h2&gt;

&lt;h3 id=&quot;pt-hooks&quot;&gt;Hooks&lt;/h3&gt;
&lt;p&gt;
  pytest is a plugin system with a test runner attached. Every phase — collection, setup, running,
  reporting — publishes hooks, and &lt;code&gt;conftest.py&lt;/code&gt; is a plugin that is loaded automatically. Implement
  a hook by defining a function with the right name.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;conftest.py&lt;/b&gt; — auto-mark by location&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def pytest_collection_modifyitems(config, items):
    &quot;&quot;&quot;Everything under tests/integration/ gets @pytest.mark.integration.&quot;&quot;&quot;
    import pytest
    for item in items:
        if &quot;/integration/&quot; in str(item.path):
            item.add_marker(pytest.mark.integration)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;conftest.py&lt;/b&gt; — expose the outcome to fixtures&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import pytest

@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
    outcome = yield
    report = outcome.get_result()
    # stash &quot;rep_setup&quot; / &quot;rep_call&quot; / &quot;rep_teardown&quot; on the test item
    setattr(item, f&quot;rep_{report.when}&quot;, report)

@pytest.fixture
def browser(request):
    driver = start_browser()
    yield driver
    if getattr(request.node, &quot;rep_call&quot;, None) and request.node.rep_call.failed:
        driver.save_screenshot(f&quot;/tmp/{request.node.name}.png&quot;)
    driver.quit()&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  That pattern — capture an artifact only when the test failed — is the standard answer for browser
  screenshots, server logs and database dumps.
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Hook&lt;/th&gt;&lt;th&gt;Fires&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest_addoption&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Once at startup, to register CLI flags&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest_configure&lt;/code&gt;&lt;/td&gt;&lt;td&gt;After config is read; register markers here&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest_collection_modifyitems&lt;/code&gt;&lt;/td&gt;&lt;td&gt;After collection — reorder, filter, mark&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest_generate_tests&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Per test function, to generate parameters&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest_runtest_setup&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Before each test&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest_runtest_makereport&lt;/code&gt;&lt;/td&gt;&lt;td&gt;After each phase, with the result&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest_sessionfinish&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Once, at the very end&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-addoption&quot;&gt;Custom CLI options&lt;/h3&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;conftest.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import pytest

def pytest_addoption(parser):
    parser.addoption(
        &quot;--runslow&quot;, action=&quot;store_true&quot;, default=False,
        help=&quot;run tests marked slow&quot;,
    )
    parser.addoption(
        &quot;--env&quot;, action=&quot;store&quot;, default=&quot;staging&quot;,
        choices=(&quot;staging&quot;, &quot;prod&quot;), help=&quot;target environment&quot;,
    )

def pytest_configure(config):
    config.addinivalue_line(&quot;markers&quot;, &quot;slow: takes more than a second&quot;)

def pytest_collection_modifyitems(config, items):
    if config.getoption(&quot;--runslow&quot;):
        return
    skip = pytest.mark.skip(reason=&quot;needs --runslow&quot;)
    for item in items:
        if &quot;slow&quot; in item.keywords:
            item.add_marker(skip)

@pytest.fixture(scope=&quot;session&quot;)
def env(request):
    return request.config.getoption(&quot;--env&quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;usage&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;pytest                      # slow tests are skipped
pytest --runslow            # everything
pytest --env prod&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-generate&quot;&gt;pytest_generate_tests&lt;/h3&gt;
&lt;p&gt;
  When the set of cases is only known at runtime — read from a directory, a manifest, a database —
  generate them in this hook. Each generated case is still a first-class test.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;golden files as test cases&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;# conftest.py
from pathlib import Path

CASES = Path(__file__).parent / &quot;cases&quot;

def pytest_generate_tests(metafunc):
    if &quot;case_file&quot; in metafunc.fixturenames:
        files = sorted(CASES.glob(&quot;*.input&quot;))
        metafunc.parametrize(
            &quot;case_file&quot;, files, ids=[f.stem for f in files]
        )

# test_render.py
def test_render_matches_golden(case_file):
    expected = case_file.with_suffix(&quot;.expected&quot;).read_text()
    assert render(case_file.read_text()) == expected&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  Dropping a new pair of files into &lt;code&gt;cases/&lt;/code&gt; adds a test. No code change, and the id is the file
  name so failures point straight at the data.
&lt;/p&gt;


&lt;h3 id=&quot;pt-plugin&quot;&gt;Writing a plugin&lt;/h3&gt;
&lt;p&gt;
  A plugin is a module of hooks and fixtures. Once it lives in a package with the
  &lt;code&gt;pytest11&lt;/code&gt; entry point, installing the package is enough — no imports, no &lt;code&gt;conftest.py&lt;/code&gt;.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;pytest_timer/plugin.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import time
import pytest

@pytest.fixture
def timer():
    &quot;&quot;&quot;Yield an object whose .elapsed is the time spent inside the block.&quot;&quot;&quot;
    class _Timer:
        start = time.perf_counter()
        @property
        def elapsed(self):
            return time.perf_counter() - self.start
    return _Timer()

def pytest_addoption(parser):
    parser.addoption(&quot;--warn-slower-than&quot;, type=float, default=None)

@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_call(item):
    started = time.perf_counter()
    yield
    limit = item.config.getoption(&quot;--warn-slower-than&quot;)
    took = time.perf_counter() - started
    if limit is not None and took &amp;gt; limit:
        item.warn(pytest.PytestWarning(f&quot;{item.name} took {took:.2f}s&quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;pyproject.toml&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;toml&quot;&gt;[project.entry-points.pytest11]
timer = &quot;pytest_timer.plugin&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  Test your plugin with pytest&#39;s own &lt;code&gt;pytester&lt;/code&gt; fixture, which runs a nested pytest session in a
  temporary directory:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;pytester&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;pytest_plugins = [&quot;pytester&quot;]

def test_warns_about_slow_tests(pytester):
    pytester.makepyfile(&quot;&quot;&quot;
        import time
        def test_slow():
            time.sleep(0.05)
    &quot;&quot;&quot;)
    result = pytester.runpytest(&quot;--warn-slower-than=0.01&quot;)
    result.assert_outcomes(passed=1, warnings=1)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-helpers&quot;&gt;Custom assertion helpers&lt;/h3&gt;
&lt;p&gt;
  Shared assertion functions clutter tracebacks with frames nobody cares about. Set
  &lt;code&gt;__tracebackhide__&lt;/code&gt; and the failure points at the caller instead.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;__tracebackhide__&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import pytest

def assert_valid_invoice(invoice):
    __tracebackhide__ = True            # hide this frame in the report
    if invoice.total &amp;lt; 0:
        pytest.fail(f&quot;negative total: {invoice.total}&quot;)
    if invoice.lines and invoice.total != sum(l.amount for l in invoice.lines):
        pytest.fail(
            f&quot;total {invoice.total} != sum of lines &quot;
            f&quot;{sum(l.amount for l in invoice.lines)}&quot;
        )

def test_generated_invoice(order):
    assert_valid_invoice(build_invoice(order))   # ← failure is reported here&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  To keep pytest&#39;s value-introspection inside a helper module, register it for rewriting &lt;em&gt;before&lt;/em&gt;
  it is imported:
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;&lt;b&gt;conftest.py&lt;/b&gt;&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;import pytest
pytest.register_assert_rewrite(&quot;mypackage.testing.helpers&quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-rewriting&quot;&gt;Why plain &lt;code&gt;assert&lt;/code&gt; works&lt;/h3&gt;
&lt;p&gt;
  Python&#39;s &lt;code&gt;assert&lt;/code&gt; throws away everything but the boolean. pytest installs an import hook that
  rewrites the AST of test modules before they are compiled, replacing each &lt;code&gt;assert&lt;/code&gt; with code that
  stores intermediate values and builds an explanation on failure.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;conceptually&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;# what you write
assert compute(x) == expected

# roughly what gets compiled
@py_left  = compute(x)
@py_right = expected
if not (@py_left == @py_right):
    raise AssertionError(explain(&quot;==&quot;, @py_left, @py_right))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Three consequences worth knowing:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Rewriting applies to test modules, &lt;code&gt;conftest.py&lt;/code&gt;, and modules you explicitly register. A plain
      library module keeps bare &lt;code&gt;AssertionError&lt;/code&gt;s with no detail.&lt;/li&gt;
  &lt;li&gt;Running Python with &lt;code&gt;-O&lt;/code&gt; strips &lt;code&gt;assert&lt;/code&gt; statements entirely, so never run a suite optimised.&lt;/li&gt;
  &lt;li&gt;Stale &lt;code&gt;__pycache__&lt;/code&gt; from a non-pytest run can shadow rewritten bytecode; &lt;code&gt;pytest --cache-clear&lt;/code&gt;
      or deleting the caches fixes the &quot;my assertions lost their detail&quot; mystery.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3 id=&quot;pt-async&quot;&gt;Async tests&lt;/h3&gt;
&lt;p&gt;
  pytest cannot await a coroutine on its own — an &lt;code&gt;async def&lt;/code&gt; test without a plugin is
  &lt;em&gt;skipped with a warning&lt;/em&gt;, which looks like a pass in a hurry. Install one of the two plugins.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;pytest-asyncio&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;# pyproject.toml
# [tool.pytest.ini_options]
# asyncio_mode = &quot;auto&quot;        # no per-test marker needed

import asyncio, pytest

@pytest.fixture
async def client():
    c = await open_client()
    yield c
    await c.aclose()

async def test_fetches_concurrently(client):
    a, b = await asyncio.gather(client.get(&quot;/a&quot;), client.get(&quot;/b&quot;))
    assert a.status == b.status == 200&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  &lt;code&gt;anyio&lt;/code&gt; is the alternative when you need the same tests to run on both asyncio and trio.
&lt;/p&gt;


&lt;h3 id=&quot;pt-hypothesis&quot;&gt;Property-based testing&lt;/h3&gt;
&lt;p&gt;
  Instead of listing examples, describe the &lt;em&gt;shape&lt;/em&gt; of valid input and assert a property that must
  hold for all of them. Hypothesis generates cases, and on failure shrinks them to the smallest
  reproducer.
&lt;/p&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;hypothesis&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;from hypothesis import given, strategies as st

@given(st.text())
def test_slugify_is_idempotent(s):
    once = slugify(s)
    assert slugify(once) == once

@given(st.lists(st.integers()))
def test_sort_is_a_permutation(xs):
    out = my_sort(xs)
    assert len(out) == len(xs)
    assert sorted(out) == sorted(xs)
    assert all(a &amp;lt;= b for a, b in zip(out, out[1:]))&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
  It composes with pytest normally — &lt;code&gt;@given&lt;/code&gt; functions are collected like any other test. Good
  properties are round-trips (&lt;code&gt;decode(encode(x)) == x&lt;/code&gt;), invariants (length, ordering) and
  equivalence to a slow reference implementation.
&lt;/p&gt;

&lt;div class=&quot;note warn&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Don&#39;t mix &lt;code&gt;@given&lt;/code&gt; with function-scoped fixtures&lt;/span&gt;
  &lt;p&gt;
    Hypothesis calls the test body many times, but a function-scoped fixture is created once for the
    whole thing. Shared mutable state leaks between generated examples. Build what you need inside the
    test, or use a factory fixture.
  &lt;/p&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-flaky&quot;&gt;Flaky tests and isolation&lt;/h3&gt;
&lt;p&gt;
  A flaky test is worse than no test: it trains people to re-run CI instead of reading it. The usual
  causes are few, and each has a direct fix.
&lt;/p&gt;

&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Cause&lt;/th&gt;&lt;th&gt;Fix&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;Shared mutable state across tests&lt;/td&gt;&lt;td&gt;Narrow the fixture scope; return copies&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Order dependence&lt;/td&gt;&lt;td&gt;&lt;code&gt;pytest -p no:randomly&lt;/code&gt; to confirm, then fix the coupling&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Real clock / real timezone&lt;/td&gt;&lt;td&gt;Freeze time (&lt;code&gt;monkeypatch&lt;/code&gt;, &lt;code&gt;freezegun&lt;/code&gt;, &lt;code&gt;time-machine&lt;/code&gt;)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Unseeded randomness&lt;/td&gt;&lt;td&gt;Seed it, and log the seed&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;sleep()&lt;/code&gt;-based waiting&lt;/td&gt;&lt;td&gt;Poll for the condition with a timeout&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Dict/set iteration order assumptions&lt;/td&gt;&lt;td&gt;Compare sets, or sort before comparing&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Leftover files or env vars&lt;/td&gt;&lt;td&gt;&lt;code&gt;tmp_path&lt;/code&gt; and &lt;code&gt;monkeypatch&lt;/code&gt;, never manual mutation&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot;&gt;prove isolation&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;python -m pip install pytest-randomly
pytest                       # shuffles order every run, prints the seed
pytest -p no:randomly        # reproduce the deterministic order
pytest -p randomly --randomly-seed=12345   # reproduce a specific shuffle&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;note trap&quot;&gt;
  &lt;span class=&quot;tag&quot;&gt;Retry plugins are anaesthetic, not treatment&lt;/span&gt;
  &lt;p&gt;
    &lt;code&gt;pytest-rerunfailures&lt;/code&gt; can keep a pipeline moving, but a test that passes on the second attempt is
    telling you something real about your system. Retry only at genuinely non-deterministic boundaries
    (a live network), and never on unit tests.
  &lt;/p&gt;
&lt;/div&gt;


&lt;!-- ==================== REFERENCE ==================== --&gt;
&lt;h2&gt;Reference&lt;/h2&gt;

&lt;h3 id=&quot;pt-antipatterns&quot;&gt;Anti-patterns&lt;/h3&gt;

&lt;h4&gt;Logic in the test&lt;/h4&gt;
&lt;p&gt;
  A test with branching needs its own tests. Split it into parametrized cases so each path is visible
  in the report.
&lt;/p&gt;
&lt;div class=&quot;grid2&quot;&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot; style=&quot;color:var(--danger)&quot;&gt;avoid&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def test_prices():
    for currency in (&quot;EUR&quot;, &quot;USD&quot;):
        if currency == &quot;EUR&quot;:
            assert fmt(1, currency) == &quot;1,00 €&quot;
        else:
            assert fmt(1, currency) == &quot;$1.00&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot; style=&quot;color:var(--accent-2)&quot;&gt;prefer&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;@pytest.mark.parametrize(
    (&quot;currency&quot;, &quot;expected&quot;),
    [(&quot;EUR&quot;, &quot;1,00 €&quot;), (&quot;USD&quot;, &quot;$1.00&quot;)],
)
def test_prices(currency, expected):
    assert fmt(1, currency) == expected&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;h4&gt;Asserting the implementation&lt;/h4&gt;
&lt;p&gt;
  &lt;code&gt;mock.assert_called_once_with(...)&lt;/code&gt; on an internal helper locks in today&#39;s call graph. Rename the
  helper and the test fails while the behaviour is unchanged. Assert on the observable result instead.
&lt;/p&gt;

&lt;h4&gt;One test, many concerns&lt;/h4&gt;
&lt;p&gt;
  When a 40-line test fails you learn &quot;something in registration is broken&quot;. Several focused tests tell
  you &lt;em&gt;which&lt;/em&gt; part, and the names double as documentation.
&lt;/p&gt;

&lt;h4&gt;Depending on execution order&lt;/h4&gt;
&lt;p&gt;
  A test that only passes after another one ran is not a test, it is half of one. Each test must set up
  everything it needs.
&lt;/p&gt;

&lt;h4&gt;Sleeping&lt;/h4&gt;
&lt;div class=&quot;grid2&quot;&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot; style=&quot;color:var(--danger)&quot;&gt;avoid&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;start_worker()
time.sleep(2)          # slow AND flaky
assert job_done()&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;snippet&quot;&gt;
  &lt;div class=&quot;snippet-head&quot;&gt;&lt;span class=&quot;snippet-name&quot; style=&quot;color:var(--accent-2)&quot;&gt;prefer&lt;/span&gt;&lt;button class=&quot;copy&quot; type=&quot;button&quot;&gt;copy&lt;/button&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code class=&quot;py&quot;&gt;def wait_until(pred, timeout=5, interval=0.05):
    __tracebackhide__ = True
    deadline = time.monotonic() + timeout
    while time.monotonic() &amp;lt; deadline:
        if pred():
            return
        time.sleep(interval)
    pytest.fail(f&quot;condition not met in {timeout}s&quot;)

start_worker()
wait_until(job_done)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;


&lt;h3 id=&quot;pt-cheatsheet&quot;&gt;Cheat sheet&lt;/h3&gt;

&lt;h4&gt;Command line&lt;/h4&gt;
&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest path::test_name&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Run one test&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;-k &quot;expr&quot;&lt;/code&gt; / &lt;code&gt;-m &quot;expr&quot;&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Select by name / by marker&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;-x&lt;/code&gt; / &lt;code&gt;--maxfail=N&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Stop early&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--lf&lt;/code&gt; / &lt;code&gt;--ff&lt;/code&gt; / &lt;code&gt;--sw&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Last-failed / failures-first / stepwise&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;-q&lt;/code&gt; / &lt;code&gt;-v&lt;/code&gt; / &lt;code&gt;-vv&lt;/code&gt; / &lt;code&gt;-ra&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Verbosity and outcome summary&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;-s&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Show output live&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--pdb&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Debugger at the failure&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--tb=short&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Compact tracebacks&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--collect-only&lt;/code&gt;&lt;/td&gt;&lt;td&gt;List tests without running&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--fixtures&lt;/code&gt;&lt;/td&gt;&lt;td&gt;List available fixtures&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;--durations=10&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Slowest tests&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;-n auto&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Parallel (xdist)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;-W error&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Turn warnings into failures&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;h4&gt;API&lt;/h4&gt;
&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest.fixture(scope=, params=, autouse=, ids=)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Define a fixture&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest.mark.parametrize(argnames, argvalues, ids=, indirect=)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Generate cases&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest.param(*values, id=, marks=)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;One case with metadata&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest.raises(Exc, match=)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Expect an exception&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest.warns(W, match=)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Expect a warning&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest.approx(value, rel=, abs=)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Float comparison&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest.skip(reason)&lt;/code&gt; / &lt;code&gt;pytest.fail(msg)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Skip / fail imperatively&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest.importorskip(name, minversion=)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Optional dependency&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytest.register_assert_rewrite(module)&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Rewrite asserts in a helper module&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;h4&gt;Built-in fixtures&lt;/h4&gt;
&lt;div class=&quot;table-wrap&quot;&gt;
&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;tmp_path&lt;/code&gt;, &lt;code&gt;tmp_path_factory&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Temporary directories&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;monkeypatch&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Patch attributes, env vars, cwd — auto-undone&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;capsys&lt;/code&gt;, &lt;code&gt;capfd&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Captured stdout/stderr (Python level / fd level)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;caplog&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Captured log records&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;request&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Test metadata, &lt;code&gt;request.param&lt;/code&gt;, config access&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;pytester&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Run a nested pytest — for testing plugins&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;recwarn&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Record all warnings raised&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;h2&gt;Wrapping up&lt;/h2&gt;

&lt;h3 id=&quot;pt-closing&quot;&gt;What actually moves the needle&lt;/h3&gt;
&lt;p&gt;
  Reading a tool&#39;s full feature list rarely changes how anyone works. If you adopt three things from
  this post, make them these.
&lt;/p&gt;

&lt;div class=&quot;takeaway&quot;&gt;
  &lt;h4&gt;The short list&lt;/h4&gt;
  &lt;ul&gt;
    &lt;li&gt;
      &lt;strong&gt;Turn on &lt;code&gt;--strict-markers&lt;/code&gt; and &lt;code&gt;filterwarnings = [&quot;error&quot;]&lt;/code&gt;.&lt;/strong&gt;
      Two lines of config that convert a class of silent failures into loud ones, today, in an existing
      project.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Replace your ad-hoc setup with fixtures, and keep them function-scoped until proven slow.&lt;/strong&gt;
      Almost every order-dependent flake traces back to state shared more widely than it needed to be.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Reach for &lt;code&gt;parametrize&lt;/code&gt; the moment a test grows a loop or an &lt;code&gt;if&lt;/code&gt;.&lt;/strong&gt;
      Each case gets its own name and its own verdict, which is the difference between &quot;billing is
      broken&quot; and &quot;billing is broken for zero-quantity line items&quot;.
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;
  The advanced material matters less often, but it is worth knowing it exists. The day you find
  yourself copying the same &lt;code&gt;conftest.py&lt;/code&gt; into a fourth repository, that is the signal to turn it
  into a plugin — and by then the entry point is a two-line change.
&lt;/p&gt;

&lt;h3 id=&quot;pt-further&quot;&gt;Further reading&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.pytest.org/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;docs.pytest.org&lt;/a&gt; — the reference; the &quot;How-to guides&quot; section is better than its name suggests&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.pytest.org/en/stable/reference/plugin_list.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Plugin list&lt;/a&gt; — around 1,500 plugins, and the one you need probably exists&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://hypothesis.readthedocs.io/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Hypothesis&lt;/a&gt; — property-based testing, covered briefly above&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://coverage.readthedocs.io/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;coverage.py&lt;/a&gt; — what &lt;code&gt;pytest-cov&lt;/code&gt; wraps, worth reading directly for branch coverage&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;foot&quot;&gt;
  Every runnable snippet verified against pytest 9.1.1.
&lt;/div&gt;

&lt;/div&gt;
&lt;/div&gt;

&lt;script&gt;
(function () {
  var root = document.getElementById(&#39;pt-guide&#39;);
  if (!root || root.dataset.ptInit) return;
  root.dataset.ptInit = &#39;1&#39;;

  var PY_KW = (&quot;False|None|True|and|as|assert|async|await|break|class|continue|def|del|elif|&quot;
             + &quot;else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|&quot;
             + &quot;pass|raise|return|try|while|with|yield|self|match|case&quot;).split(&quot;|&quot;);

  var pyRe = new RegExp(
      &quot;(#[^\\n]*)&quot;                                        /* 1 comment */
    + &quot;|(\&quot;\&quot;\&quot;[\\s\\S]*?\&quot;\&quot;\&quot;|&#39;&#39;&#39;[\\s\\S]*?&#39;&#39;&#39;&quot;          /* 2 triple strings */
    +   &quot;|\&quot;(?:\\\\.|[^\&quot;\\\\\\n])*\&quot;|&#39;(?:\\\\.|[^&#39;\\\\\\n])*&#39;)&quot;
    + &quot;|(@[\\w.]+)&quot;                                        /* 3 decorator */
    + &quot;|\\b(&quot; + PY_KW.join(&quot;|&quot;) + &quot;)\\b&quot;                   /* 4 keyword */
    + &quot;|\\b(\\d[\\w.]*)\\b&quot;                                /* 5 number */
    + &quot;|\\b([a-zA-Z_]\\w*)(?=\\()&quot;                         /* 6 call */
    , &quot;g&quot;);

  var shRe = /(#[^\n]*)|(&quot;(?:\\.|[^&quot;\\])*&quot;|&#39;(?:\\.|[^&#39;\\])*&#39;)|(^|\s)(--?[\w-]+)/g;

  function esc(s) {
    return s.replace(/&amp;/g, &quot;&amp;amp;&quot;).replace(/&lt;/g, &quot;&amp;lt;&quot;).replace(/&gt;/g, &quot;&amp;gt;&quot;);
  }

  function highlightPy(text) {
    return esc(text).replace(pyRe, function (m, com, str, dec, kw, num, fn) {
      if (com) return &#39;&lt;span class=&quot;t-com&quot;&gt;&#39; + com + &quot;&lt;/span&gt;&quot;;
      if (str) return &#39;&lt;span class=&quot;t-str&quot;&gt;&#39; + str + &quot;&lt;/span&gt;&quot;;
      if (dec) return &#39;&lt;span class=&quot;t-dec&quot;&gt;&#39; + dec + &quot;&lt;/span&gt;&quot;;
      if (kw)  return &#39;&lt;span class=&quot;t-kw&quot;&gt;&#39;  + kw  + &quot;&lt;/span&gt;&quot;;
      if (num) return &#39;&lt;span class=&quot;t-num&quot;&gt;&#39; + num + &quot;&lt;/span&gt;&quot;;
      if (fn)  return &#39;&lt;span class=&quot;t-fn&quot;&gt;&#39;  + fn  + &quot;&lt;/span&gt;&quot;;
      return m;
    });
  }

  function highlightSh(text) {
    return esc(text).replace(shRe, function (m, com, str, pre, flag) {
      if (com)  return &#39;&lt;span class=&quot;t-com&quot;&gt;&#39; + com + &quot;&lt;/span&gt;&quot;;
      if (str)  return &#39;&lt;span class=&quot;t-str&quot;&gt;&#39; + str + &quot;&lt;/span&gt;&quot;;
      if (flag) return pre + &#39;&lt;span class=&quot;t-dec&quot;&gt;&#39; + flag + &quot;&lt;/span&gt;&quot;;
      return m;
    });
  }

  function highlightOut(text) {
    return esc(text)
      .replace(/\b(\d+ passed)\b/g, &#39;&lt;span class=&quot;t-pass&quot;&gt;$1&lt;/span&gt;&#39;)
      .replace(/\b(\d+ (?:failed|error[s]?))\b/g, &#39;&lt;span class=&quot;t-fail&quot;&gt;$1&lt;/span&gt;&#39;)
      .replace(/^(E .*)$/gm, &#39;&lt;span class=&quot;t-fail&quot;&gt;$1&lt;/span&gt;&#39;)
      .replace(/\b(PASSED)\b/g, &#39;&lt;span class=&quot;t-pass&quot;&gt;$1&lt;/span&gt;&#39;)
      .replace(/\b(FAILED|ERROR)\b/g, &#39;&lt;span class=&quot;t-fail&quot;&gt;$1&lt;/span&gt;&#39;);
  }

  root.querySelectorAll(&quot;pre code&quot;).forEach(function (el) {
    var raw = el.textContent;
    el.dataset.raw = raw;
    if (el.classList.contains(&quot;py&quot;))        el.innerHTML = highlightPy(raw);
    else if (el.classList.contains(&quot;out&quot;))  el.innerHTML = highlightOut(raw);
    else                                    el.innerHTML = highlightSh(raw);
  });

  root.querySelectorAll(&quot;.copy&quot;).forEach(function (btn) {
    btn.addEventListener(&quot;click&quot;, function (ev) {
      ev.preventDefault();
      var code = btn.closest(&quot;.snippet&quot;).querySelector(&quot;code&quot;);
      var text = code.dataset.raw || code.textContent;
      var done = function () {
        btn.textContent = &quot;copied&quot;;
        btn.classList.add(&quot;ok&quot;);
        setTimeout(function () { btn.textContent = &quot;copy&quot;; btn.classList.remove(&quot;ok&quot;); }, 1200);
      };
      if (navigator.clipboard &amp;&amp; navigator.clipboard.writeText) {
        navigator.clipboard.writeText(text).then(done, function () {});
      } else {
        var ta = document.createElement(&quot;textarea&quot;);
        ta.value = text; ta.style.position = &quot;fixed&quot;; ta.style.opacity = &quot;0&quot;;
        document.body.appendChild(ta); ta.select();
        try { document.execCommand(&quot;copy&quot;); done(); } catch (e) {}
        document.body.removeChild(ta);
      }
    });
  });
})();
&lt;/script&gt;
</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/7204518010433143826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2026/07/pytest-from-your-first-test-to-your-own.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/7204518010433143826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/7204518010433143826'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2026/07/pytest-from-your-first-test-to-your-own.html' title='pytest, from your first test to your own plugin'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-5928722289191846808</id><published>2026-07-13T01:17:52.686-07:00</published><updated>2026-07-13T01:19:55.826-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginners"/><category scheme="http://www.blogger.com/atom/ns#" term="dict"/><category scheme="http://www.blogger.com/atom/ns#" term="mypy"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="python3"/><category scheme="http://www.blogger.com/atom/ns#" term="static typing"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><category scheme="http://www.blogger.com/atom/ns#" term="type hints"/><category scheme="http://www.blogger.com/atom/ns#" term="typing"/><title type='text'>Understanding Python variable type hints (Dict, dict, and mypy)</title><content type='html'>&lt;!--
  Blog-ready HTML FRAGMENT (paste into a blog post body).
  - All styles are scoped under `.pw-root` so they won&#39;t clash with the blog theme.
  - Prose = semantic tags; code = &lt;pre&gt;&lt;code&gt;.
  - Covers pystudy_01 + pystudy_02 only (pure Python; no project code).
--&gt;
&lt;div class=&quot;pw-root&quot;&gt;
  &lt;style&gt;
    /* Self-contained light &quot;card&quot; so it stays readable on ANY blog background
       (light or dark). All colors are set explicitly; nothing inherits from
       the parent theme. Scoped under .pw-root so it never leaks out. */
    .pw-root{max-width:760px;margin:1.2em auto;line-height:1.7;
             font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,sans-serif;
             color:#24292f !important;background:#ffffff;padding:24px 28px;
             border:1px solid #d0d7de;border-radius:10px;}
    .pw-root *{color:#24292f;}                 /* force dark text inside the card */
    .pw-root h2{font-size:1.5em;margin:1.6em 0 .5em;border-bottom:2px solid #eaecef;
                padding-bottom:.2em;color:#1f2328;}
    .pw-root h3{font-size:1.15em;margin:1.3em 0 .4em;color:#1f2328;}
    .pw-root p{margin:.7em 0;color:#24292f;}
    .pw-root ul{margin:.6em 0;padding-left:1.4em;}
    .pw-root li{margin:.3em 0;color:#24292f;}
    .pw-root code{background:#eef1f4;color:#24292f;padding:.1em .35em;border-radius:4px;
                  font-family:&quot;SF Mono&quot;,ui-monospace,Menlo,Consolas,monospace;font-size:.92em;}
    /* code blocks stay dark-on-light-card: light text on dark box, explicit */
    .pw-root pre{background:#0d1117;padding:14px 16px;border-radius:8px;
                 overflow-x:auto;margin:.8em 0;}
    .pw-root pre code{background:none !important;padding:0;color:#e6edf3 !important;
                      font-size:.88em;line-height:1.5;}
    .pw-root .pw-note{background:#eef6ff;border-left:4px solid #4c8dff;padding:.7em 1em;
                      border-radius:6px;margin:1em 0;color:#1a2b4a;}
    .pw-root .pw-out{background:#f6f8fa;border:1px solid #eaecef;border-radius:6px;
                     padding:.6em 1em;margin:.5em 0;font-family:ui-monospace,Menlo,Consolas,monospace;
                     font-size:.86em;white-space:pre-wrap;color:#333;}
    .pw-root .pw-key{background:#fff8e1;border-left:4px solid #d29922;padding:.7em 1em;
                     border-radius:6px;margin:1em 0;color:#4a3b00;}
    .pw-root table{border-collapse:collapse;width:100%;margin:.8em 0;font-size:.92em;
                   background:#ffffff;}
    .pw-root th,.pw-root td{border:1px solid #d0d7de;padding:.45em .7em;text-align:left;color:#24292f;}
    .pw-root th{background:#f6f8fa;}
  &lt;/style&gt;

  &lt;p&gt;When you read Python code, sooner or later you hit a line like this:&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;data: Dict[str, int] = {}&lt;/code&gt;&lt;/pre&gt;
  &lt;p&gt;The &lt;code&gt;: Dict[str, int]&lt;/code&gt; part looks strange the first time. In this post we&#39;ll
     figure out exactly what that one line means — and whether a &quot;type hint&quot; is actually
     enforced — using tiny runnable examples.&lt;/p&gt;

  &lt;h2&gt;1. One line, three things at once&lt;/h2&gt;
  &lt;p&gt;That single line is really &lt;strong&gt;three pieces&lt;/strong&gt; glued together.&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;data  :  Dict[str, int]  =  {}
 │            │              │
name       type hint       actual
            (a note)        value&lt;/code&gt;&lt;/pre&gt;
  &lt;table&gt;
    &lt;tr&gt;&lt;th&gt;Piece&lt;/th&gt;&lt;th&gt;Meaning&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;data&lt;/code&gt;&lt;/td&gt;&lt;td&gt;the variable name&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;: Dict[str, int]&lt;/code&gt;&lt;/td&gt;&lt;td&gt;a &lt;strong&gt;type hint&lt;/strong&gt; — &quot;keys are str, values are int&quot;. Just a &lt;em&gt;note&lt;/em&gt; for humans/editors&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;= {}&lt;/code&gt;&lt;/td&gt;&lt;td&gt;the actual value = an empty dict&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;p&gt;At runtime it is &lt;strong&gt;exactly the same&lt;/strong&gt; as:&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;data = {}   # drop the hint and this is all that&#39;s left&lt;/code&gt;&lt;/pre&gt;

  &lt;h2&gt;2. &lt;code&gt;= {}&lt;/code&gt; is just a dict&lt;/h2&gt;
  &lt;p&gt;A dict is a &quot;key → value&quot; store. It has nothing to do with type hints — it&#39;s a basic
     built-in type that has always existed.&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;data = {}                 # empty dict
data[&quot;gemm&quot;]   = &quot;A&quot;      # key (str) -&gt; value
data[&quot;conv2d&quot;] = &quot;B&quot;
print(data)               # {&#39;gemm&#39;: &#39;A&#39;, &#39;conv2d&#39;: &#39;B&#39;}
print(data[&quot;gemm&quot;])       # A
print(list(data))         # [&#39;gemm&#39;, &#39;conv2d&#39;]&lt;/code&gt;&lt;/pre&gt;

  &lt;h2&gt;3. &lt;code&gt;: Dict[str, int]&lt;/code&gt; is a &quot;type hint&quot;&lt;/h2&gt;
  &lt;p&gt;&lt;code&gt;Dict[str, int]&lt;/code&gt; is a &lt;em&gt;note&lt;/em&gt; saying &quot;a dict whose keys are strings and values
     are integers&quot;. Python does &lt;strong&gt;not&lt;/strong&gt; enforce that note when it runs.&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;from typing import Dict

ages: Dict[str, int] = {}   # at runtime this is just ages = {}
ages[&quot;alice&quot;] = 30
ages[&quot;bob&quot;]   = 25
print(ages)                 # {&#39;alice&#39;: 30, &#39;bob&#39;: 25}&lt;/code&gt;&lt;/pre&gt;

  &lt;h2&gt;4. Is it really not enforced? — break it on purpose&lt;/h2&gt;
  &lt;p&gt;Violating the hint does &lt;strong&gt;not&lt;/strong&gt; raise an error. Let&#39;s prove it.&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;from typing import Dict

ages: Dict[str, int] = {}   # promise: &quot;str keys, int values&quot;
ages[&quot;alice&quot;] = 30          # keeps the promise
ages[&quot;oops&quot;]  = &quot;not-int&quot;   # value is a string -&gt; breaks it
ages[123]     = 99          # key is an int      -&gt; breaks it
print(ages)&lt;/code&gt;&lt;/pre&gt;
  &lt;p&gt;Output:&lt;/p&gt;
  &lt;div class=&quot;pw-out&quot;&gt;{&#39;alice&#39;: 30, &#39;oops&#39;: &#39;not-int&#39;, 123: 99}&lt;/div&gt;
  &lt;div class=&quot;pw-key&quot;&gt;
    &lt;strong&gt;Key point:&lt;/strong&gt; a type hint is &lt;strong&gt;not enforced&lt;/strong&gt;. The Python
    interpreter simply ignores it at runtime, so breaking it still runs fine.
  &lt;/div&gt;

  &lt;h2&gt;5. So why write hints at all?&lt;/h2&gt;
  &lt;p&gt;If they&#39;re not enforced, why bother? Because they&#39;re a &quot;quality tool&quot;, not a rule.&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;strong&gt;Humans&lt;/strong&gt; — reading the code, you instantly see &quot;this is a str→int dict&quot;.&lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;Editors (IDEs)&lt;/strong&gt; — autocomplete, and a red squiggle when you misuse it.&lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;Static checkers (mypy)&lt;/strong&gt; — run &lt;code&gt;mypy file.py&lt;/code&gt; separately and it catches
        violations &lt;em&gt;before&lt;/em&gt; you run the code.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;div class=&quot;pw-note&quot;&gt;
    A hint is &quot;a promise + documentation&quot;, not a check. To actually catch violations,
    run a tool like &lt;code&gt;mypy&lt;/code&gt; yourself — the interpreter won&#39;t.
  &lt;/div&gt;

  &lt;h2&gt;6. &lt;code&gt;Dict&lt;/code&gt; vs &lt;code&gt;dict&lt;/code&gt; — and when did this syntax appear?&lt;/h2&gt;
  &lt;p&gt;The dict itself is old; the &lt;strong&gt;type-hint syntax&lt;/strong&gt; is the newer part.&lt;/p&gt;
  &lt;table&gt;
    &lt;tr&gt;&lt;th&gt;Syntax&lt;/th&gt;&lt;th&gt;Import needed?&lt;/th&gt;&lt;th&gt;Introduced&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;Dict[str, int]&lt;/code&gt; (capital)&lt;/td&gt;&lt;td&gt;&lt;code&gt;from typing import Dict&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Python 3.5 (2015)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;dict[str, int]&lt;/code&gt; (lowercase)&lt;/td&gt;&lt;td&gt;none (built-in)&lt;/td&gt;&lt;td&gt;Python 3.9 (2020)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;dict&lt;/code&gt; (plain)&lt;/td&gt;&lt;td&gt;none&lt;/td&gt;&lt;td&gt;always&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;p&gt;Annotating a variable with &lt;code&gt;x: int = 0&lt;/code&gt; has been possible since Python 3.6 (2016).
     Both forms mean the same thing, so new code usually prefers the lowercase &lt;code&gt;dict[...]&lt;/code&gt;.&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;scores: dict[str, float] = {}   # 3.9+ : lowercase, no import&lt;/code&gt;&lt;/pre&gt;

  &lt;h2&gt;Summary&lt;/h2&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;code&gt;name: Type = value&lt;/code&gt; == &lt;code&gt;name = value&lt;/code&gt; + (a type note)&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;= {}&lt;/code&gt; is just an empty dict (old, ordinary syntax)&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;: Dict[str, int]&lt;/code&gt; is a &lt;strong&gt;hint that is not enforced&lt;/strong&gt; — breaking it still runs&lt;/li&gt;
    &lt;li&gt;hints are documentation for humans / editors / &lt;code&gt;mypy&lt;/code&gt;; the checking is done by &lt;code&gt;mypy&lt;/code&gt;, separately&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/5928722289191846808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2026/07/understanding-python-variable-type.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/5928722289191846808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/5928722289191846808'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2026/07/understanding-python-variable-type.html' title='Understanding Python variable type hints (Dict, dict, and mypy)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-6558500671975904949</id><published>2026-05-06T10:02:00.000-07:00</published><updated>2026-05-06T10:02:04.425-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="amd"/><category scheme="http://www.blogger.com/atom/ns#" term="GPU"/><category scheme="http://www.blogger.com/atom/ns#" term="GPU programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><title type='text'>AMD GPU Programming Primer — Threads, Waves, Tiles &amp; Vector Loads</title><content type='html'>&lt;style&gt;
  .gpu-primer, .gpu-primer *{box-sizing:border-box}
  .gpu-primer{
    --bg:#ffffff;--panel:#f7f8fa;--panel2:#eef0f3;--border:#dfe3e8;
    --fg:#2d333a;--muted:#7a8290;--accent:#2563eb;--accent2:#0ea5e9;
    --green:#16a34a;--orange:#ea580c;--red:#dc2626;--purple:#7c3aed;
    --code-bg:#f4f6f8;--code-fg:#2d333a;--inline-code:#7c3aed;
    background:var(--bg);color:var(--fg);
    font-family:-apple-system,BlinkMacSystemFont,&quot;SF Pro Text&quot;,&quot;Segoe UI&quot;,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;
    line-height:1.55;font-size:15px;
    width:100%;max-width:1080px;margin:0 auto;padding:24px 16px 64px;border-radius:8px;
  }
  .gpu-primer header{margin-bottom:24px;border-bottom:1px solid var(--border);padding-bottom:14px;
    display:flex;justify-content:space-between;align-items:flex-end;gap:14px;flex-wrap:wrap}
  .gpu-primer .title-block{flex:1;min-width:240px}
  .gpu-primer h1{margin:0 0 6px;font-size:28px;font-weight:700;letter-spacing:-0.5px;color:#0f172a}
  .gpu-primer .sub{color:var(--muted);font-size:14px}
  .gpu-primer h2{margin:36px 0 12px;font-size:21px;font-weight:700;color:var(--accent);
    border-bottom:1px solid var(--border);padding-bottom:6px;word-break:break-word}
  .gpu-primer h3{margin:24px 0 8px;font-size:17px;font-weight:600;color:#0f172a}
  .gpu-primer p{margin:8px 0 12px}
  .gpu-primer ul,.gpu-primer ol{padding-left:22px}
  .gpu-primer code,.gpu-primer pre,.gpu-primer .mono{
    font-family:&quot;JetBrains Mono&quot;,&quot;SF Mono&quot;,Menlo,Consolas,monospace;font-size:12px}
  .gpu-primer code{background:var(--panel2);padding:2px 6px;border-radius:4px;color:var(--inline-code);
    word-break:break-word;overflow-wrap:anywhere}
  .gpu-primer pre{background:var(--code-bg);border:1px solid var(--border);border-radius:6px;
    padding:12px 14px;color:var(--code-fg);font-size:12px;line-height:1.5;
    white-space:pre-wrap;word-wrap:break-word;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
  .gpu-primer pre.diagram{white-space:pre;font-size:11px;overflow-x:auto;-webkit-overflow-scrolling:touch}
  .gpu-primer pre.diagram code{white-space:pre;background:transparent;color:inherit;padding:0}
  .gpu-primer .table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;margin:14px 0}
  .gpu-primer table{border-collapse:collapse;width:100%;font-size:14px;background:#ffffff}
  .gpu-primer th,.gpu-primer td{border:1px solid var(--border);padding:8px 10px;text-align:left;vertical-align:top}
  .gpu-primer th{background:var(--panel2);font-weight:600;color:#0f172a}
  .gpu-primer tr:nth-child(even) td{background:#fafbfc}
  .gpu-primer .ok{color:var(--green);font-weight:600}
  .gpu-primer .bad{color:var(--red);font-weight:600}
  .gpu-primer .warn{color:var(--orange);font-weight:600}
  .gpu-primer .note{background:#eff6ff;border:1px solid #bfdbfe;border-left:3px solid var(--accent);
    padding:10px 14px;border-radius:4px;margin:10px 0;color:#1e40af}
  .gpu-primer .ok-box{background:#f0fdf4;border:1px solid #bbf7d0;border-left:3px solid var(--green);
    padding:10px 14px;border-radius:4px;margin:10px 0;color:#166534}
  .gpu-primer .key-box{background:#faf5ff;border:1px solid #e9d5ff;border-left:3px solid var(--purple);
    padding:10px 14px;border-radius:4px;margin:10px 0;color:#5b21b6}
  .gpu-primer nav.toc{background:var(--panel);border:1px solid var(--border);
    border-radius:8px;padding:12px 18px;margin:8px 0 24px}
  .gpu-primer nav.toc ol{margin:0;padding-left:20px}
  .gpu-primer nav.toc li{margin:4px 0}
  .gpu-primer nav.toc a{color:var(--accent);text-decoration:none}
  .gpu-primer nav.toc a:hover{text-decoration:underline}
  .gpu-primer .gpu-diagram{margin:18px 0;display:flex;flex-direction:column;align-items:center;gap:8px}
  .gpu-primer .grid-box{background:#eff6ff;border:2px solid #bfdbfe;border-radius:8px;
    padding:14px;width:100%;text-align:center;color:var(--accent)}
  .gpu-primer .grid-label{font-weight:700;color:var(--accent);margin-bottom:10px;font-size:14px;letter-spacing:0.5px}
  .gpu-primer .wg-row{display:flex;gap:10px;justify-content:center;flex-wrap:wrap}
  .gpu-primer .wg-box{background:#f7f8fa;border:2px solid #cbd5e1;border-radius:6px;
    padding:10px;flex:1 1 200px;min-width:0;color:#334155}
  .gpu-primer .wg-label{font-size:13px;color:var(--orange);font-weight:600;margin-bottom:8px}
  .gpu-primer .wave-row{display:flex;gap:6px;flex-direction:column}
  .gpu-primer .wave-box{background:#ffffff;border:1px solid #cbd5e1;border-radius:4px;
    padding:6px;text-align:center;font-size:12px;color:#334155}
  .gpu-primer .wave-box .threads{color:var(--muted);font-size:11px}

  @media (max-width:640px){
    .gpu-primer{padding:18px 12px 48px;font-size:14px}
    .gpu-primer h1{font-size:22px}
    .gpu-primer h2{font-size:18px;margin-top:28px}
    .gpu-primer h3{font-size:15px}
    .gpu-primer pre{font-size:11px;padding:10px}
    .gpu-primer pre.diagram{font-size:10px}
    .gpu-primer table{font-size:13px}
    .gpu-primer th,.gpu-primer td{padding:6px 8px}
    .gpu-primer .wg-box{flex:1 1 100%}
  }
&lt;/style&gt;

&lt;div class=&quot;gpu-primer&quot;&gt;

  &lt;header&gt;
    &lt;div class=&quot;title-block&quot;&gt;
      &lt;h1&gt;AMD GPU Programming Primer&lt;/h1&gt;
      &lt;div class=&quot;sub&quot;&gt;Threads · Waves · Memory · Tile Distribution · Vector Loads · MFMA&lt;/div&gt;
    &lt;/div&gt;
  &lt;/header&gt;

  &lt;nav class=&quot;toc&quot;&gt;
    &lt;ol&gt;
      &lt;li&gt;&lt;a href=&quot;#h1&quot;&gt;1. The execution hierarchy: grid → workgroup → wave → thread&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#h2&quot;&gt;2. Lane vs thread&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#h3&quot;&gt;3. Hardware: GPU → CU → SIMD → lane&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#h4&quot;&gt;4. Registers, VGPRs &amp;amp; occupancy&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#h5&quot;&gt;5. Memory hierarchy: registers → LDS → cache → HBM&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#h6&quot;&gt;6. Kernel launch &amp;lt;&amp;lt;&amp;lt; grid, block &amp;gt;&amp;gt;&amp;gt;&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#h7&quot;&gt;7. Vector loads &amp;amp; the 16-byte rule&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#h8&quot;&gt;8. Walking through a simple kernel&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#h9&quot;&gt;9. MFMA: cooperative matrix multiply&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#h10&quot;&gt;10. Tiles &amp;amp; how a wave fills a tile (X0, Y0, X1, Y1)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#h11&quot;&gt;11. Tile distribution patterns: thread / warp / block raked&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#h12&quot;&gt;12. Cheat sheet&lt;/a&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/nav&gt;

  &lt;h2 id=&quot;h1&quot;&gt;1. The execution hierarchy: grid → workgroup → wave → thread&lt;/h2&gt;
  &lt;p&gt;A GPU kernel launch is a hierarchy of work units. Bigger units contain smaller ones.&lt;/p&gt;

  &lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
    &lt;tr&gt;&lt;th&gt;AMD term&lt;/th&gt;&lt;th&gt;NVIDIA term&lt;/th&gt;&lt;th&gt;What it is&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Grid&lt;/td&gt;&lt;td&gt;Grid&lt;/td&gt;&lt;td&gt;The whole kernel launch — covers the entire problem.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Workgroup&lt;/td&gt;&lt;td&gt;Block / threadblock&lt;/td&gt;&lt;td&gt;A group of threads on one Compute Unit (CU). Shares LDS (shared memory). Can synchronize via &lt;code&gt;__syncthreads()&lt;/code&gt;.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Wavefront (wave)&lt;/td&gt;&lt;td&gt;Warp&lt;/td&gt;&lt;td&gt;64 threads (AMD CDNA) executing the same instruction simultaneously (SIMT).&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Thread (work-item)&lt;/td&gt;&lt;td&gt;Thread&lt;/td&gt;&lt;td&gt;One lane in a wave. Has its own thread ID and register state.&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;&lt;/div&gt;

  &lt;div class=&quot;gpu-diagram&quot;&gt;
    &lt;div class=&quot;grid-box&quot;&gt;
      &lt;div class=&quot;grid-label&quot;&gt;GRID (kernel launch — covers the whole problem)&lt;/div&gt;
      &lt;div class=&quot;wg-row&quot;&gt;
        &lt;div class=&quot;wg-box&quot;&gt;
          &lt;div class=&quot;wg-label&quot;&gt;Workgroup 0 (256 threads)&lt;/div&gt;
          &lt;div class=&quot;wave-row&quot;&gt;
            &lt;div class=&quot;wave-box&quot;&gt;Wave 0 &lt;span class=&quot;threads&quot;&gt;(T0..T63)&lt;/span&gt;&lt;/div&gt;
            &lt;div class=&quot;wave-box&quot;&gt;Wave 1 &lt;span class=&quot;threads&quot;&gt;(T64..T127)&lt;/span&gt;&lt;/div&gt;
            &lt;div class=&quot;wave-box&quot;&gt;Wave 2 &lt;span class=&quot;threads&quot;&gt;(T128..T191)&lt;/span&gt;&lt;/div&gt;
            &lt;div class=&quot;wave-box&quot;&gt;Wave 3 &lt;span class=&quot;threads&quot;&gt;(T192..T255)&lt;/span&gt;&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;wg-box&quot;&gt;
          &lt;div class=&quot;wg-label&quot;&gt;Workgroup 1 (256 threads)&lt;/div&gt;
          &lt;div class=&quot;wave-row&quot;&gt;
            &lt;div class=&quot;wave-box&quot;&gt;Wave 0..3 &lt;span class=&quot;threads&quot;&gt;(64 threads each)&lt;/span&gt;&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;wg-box&quot;&gt;
          &lt;div class=&quot;wg-label&quot;&gt;Workgroup N−1&lt;/div&gt;
          &lt;div class=&quot;wave-row&quot;&gt;
            &lt;div class=&quot;wave-box&quot;&gt;Wave 0..3&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;div class=&quot;key-box&quot;&gt;
    &lt;b&gt;Key:&lt;/b&gt; 64 threads in a wave always execute the &lt;i&gt;same instruction&lt;/i&gt; in lock-step.
    That is the essence of SIMT (Single Instruction Multiple Threads).
  &lt;/div&gt;

  &lt;h2 id=&quot;h2&quot;&gt;2. Lane vs thread&lt;/h2&gt;
  &lt;p&gt;&quot;Lane&quot; and &quot;thread&quot; are two views of the same physical execution slot.&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;b&gt;Lane&lt;/b&gt; = a hardware ALU slot inside a SIMD unit. There are exactly 64 lanes per SIMD on AMD CDNA.&lt;/li&gt;
    &lt;li&gt;&lt;b&gt;Thread&lt;/b&gt; = the software view of one lane. Has its own thread ID and private registers.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;One lane runs one thread at a time. They are 1:1 within an executing wave.&lt;/p&gt;

&lt;pre class=&quot;diagram&quot;&gt;
1 wave (= 64 threads) running on 1 SIMD:

   Lane 0  ↔  Thread 0    (running my_function with tid=0)
   Lane 1  ↔  Thread 1    (running my_function with tid=1)
   Lane 2  ↔  Thread 2
    ...
   Lane 63 ↔  Thread 63

All 64 lanes execute the same instruction at the same cycle.
&lt;/pre&gt;

  &lt;h2 id=&quot;h3&quot;&gt;3. Hardware: GPU → CU → SIMD → lane&lt;/h2&gt;
  &lt;p&gt;Below the software hierarchy is the physical hardware:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;b&gt;GPU&lt;/b&gt; contains many &lt;b&gt;CUs&lt;/b&gt; (Compute Units). Example: MI300X has 304 CUs.&lt;/li&gt;
    &lt;li&gt;&lt;b&gt;CU&lt;/b&gt; contains 4 &lt;b&gt;SIMD&lt;/b&gt; units. The 4 SIMDs in a CU operate &lt;b&gt;in parallel&lt;/b&gt;.&lt;/li&gt;
    &lt;li&gt;&lt;b&gt;SIMD&lt;/b&gt; contains 64 &lt;b&gt;lanes&lt;/b&gt; (ALUs) and a register file that can hold up to 8 resident waves.&lt;/li&gt;
  &lt;/ul&gt;

&lt;pre class=&quot;diagram&quot;&gt;
GPU
├─ CU 0
│   ├─ SIMD 0  (64 lanes, ≤ 8 resident waves)
│   ├─ SIMD 1  (64 lanes, ≤ 8 resident waves)
│   ├─ SIMD 2  (64 lanes, ≤ 8 resident waves)
│   ├─ SIMD 3  (64 lanes, ≤ 8 resident waves)
│   └─ LDS (shared memory, 64 KB)
├─ CU 1
├─ ...
└─ CU 303      ← total 304 CUs on MI300X
&lt;/pre&gt;

  &lt;div class=&quot;key-box&quot;&gt;
    &lt;b&gt;SIMD ≠ instant execution.&lt;/b&gt; A SIMD &lt;i&gt;holds&lt;/i&gt; up to 8 waves in its register file but
    &lt;i&gt;executes&lt;/i&gt; only one wave per cycle. With multiple waves resident, when one wave waits
    for memory, the SIMD switches to another. This is &lt;b&gt;latency hiding&lt;/b&gt;.
  &lt;/div&gt;

  &lt;h2 id=&quot;h4&quot;&gt;4. Registers, VGPRs &amp;amp; occupancy&lt;/h2&gt;
  &lt;h3&gt;Register types&lt;/h3&gt;
  &lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
    &lt;tr&gt;&lt;th&gt;Type&lt;/th&gt;&lt;th&gt;Size&lt;/th&gt;&lt;th&gt;Scope&lt;/th&gt;&lt;th&gt;Notes&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;b&gt;VGPR&lt;/b&gt; (vector GPR)&lt;/td&gt;&lt;td&gt;32-bit (4 B)&lt;/td&gt;&lt;td&gt;Private per lane&lt;/td&gt;&lt;td&gt;Up to 256 per lane per wave. Each lane sees its own VGPR.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;b&gt;SGPR&lt;/b&gt; (scalar GPR)&lt;/td&gt;&lt;td&gt;32-bit (4 B)&lt;/td&gt;&lt;td&gt;Shared by 64 lanes&lt;/td&gt;&lt;td&gt;Used for scalar values like loop counters, addresses.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;b&gt;AGPR&lt;/b&gt; (accumulator GPR)&lt;/td&gt;&lt;td&gt;32-bit (4 B)&lt;/td&gt;&lt;td&gt;Private per lane&lt;/td&gt;&lt;td&gt;CDNA-only. Used as MFMA accumulators.&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;&lt;/div&gt;

  &lt;h3&gt;How much register memory does one lane have?&lt;/h3&gt;
&lt;pre class=&quot;diagram&quot;&gt;
1 lane × 256 VGPRs × 4 bytes = 1 KB per lane
1 wave (64 lanes) × 1 KB = 64 KB total register file used by one wave
&lt;/pre&gt;

  &lt;h3&gt;Occupancy&lt;/h3&gt;
  &lt;p&gt;&lt;b&gt;Occupancy&lt;/b&gt; = number of waves resident on a SIMD (1 to 8). Higher occupancy enables better latency hiding.&lt;/p&gt;
&lt;pre class=&quot;diagram&quot;&gt;
If a wave uses 256 VGPRs/lane → only 1 wave fits in SIMD → occupancy 1
If a wave uses 128 VGPRs/lane → 2 waves fit                → occupancy 2
If a wave uses  32 VGPRs/lane → 8 waves fit                → occupancy 8 (max)

More resident waves = SIMD can switch when one wave stalls on memory.
&lt;/pre&gt;
  &lt;div class=&quot;key-box&quot;&gt;
    &lt;b&gt;Trade-off:&lt;/b&gt; using more VGPRs per thread means each thread can hold more
    data, but fewer waves can be resident, reducing latency hiding.
  &lt;/div&gt;

  &lt;h2 id=&quot;h5&quot;&gt;5. Memory hierarchy: registers → LDS → cache → HBM&lt;/h2&gt;
  &lt;p&gt;GPU memory has multiple levels, similar to CPU cache hierarchy:&lt;/p&gt;
  &lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
    &lt;tr&gt;&lt;th&gt;Level&lt;/th&gt;&lt;th&gt;Size (per CU / total)&lt;/th&gt;&lt;th&gt;Latency (cycles)&lt;/th&gt;&lt;th&gt;Managed by&lt;/th&gt;&lt;th&gt;CPU analogue&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;b&gt;Registers (VGPR/SGPR)&lt;/b&gt;&lt;/td&gt;&lt;td&gt;~256 KB / CU&lt;/td&gt;&lt;td&gt;~1&lt;/td&gt;&lt;td&gt;Compiler&lt;/td&gt;&lt;td&gt;CPU registers&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;b&gt;LDS&lt;/b&gt; (shared memory)&lt;/td&gt;&lt;td&gt;64 KB / CU&lt;/td&gt;&lt;td&gt;~10–30&lt;/td&gt;&lt;td&gt;Software (explicit loads/stores)&lt;/td&gt;&lt;td&gt;Scratchpad / fast SRAM&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;b&gt;L1 cache&lt;/b&gt;&lt;/td&gt;&lt;td&gt;16 KB / CU&lt;/td&gt;&lt;td&gt;~30&lt;/td&gt;&lt;td&gt;Hardware (transparent)&lt;/td&gt;&lt;td&gt;L1 cache&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;b&gt;L2 cache&lt;/b&gt;&lt;/td&gt;&lt;td&gt;~16 MB total&lt;/td&gt;&lt;td&gt;~150&lt;/td&gt;&lt;td&gt;Hardware&lt;/td&gt;&lt;td&gt;L2 cache&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;b&gt;Infinity / L3&lt;/b&gt;&lt;/td&gt;&lt;td&gt;~256 MB&lt;/td&gt;&lt;td&gt;~300&lt;/td&gt;&lt;td&gt;Hardware&lt;/td&gt;&lt;td&gt;L3 cache&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;b&gt;HBM&lt;/b&gt; (global memory)&lt;/td&gt;&lt;td&gt;192 GB&lt;/td&gt;&lt;td&gt;~500–1000&lt;/td&gt;&lt;td&gt;HW + software&lt;/td&gt;&lt;td&gt;DRAM&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;&lt;/div&gt;
  &lt;div class=&quot;note&quot;&gt;
    &lt;b&gt;Key insight:&lt;/b&gt; registers are basically free (~1 cycle), HBM is very expensive (~500+ cycles).
    Performance comes from staging data through LDS and registers, and from
    hiding HBM latency with high occupancy.
  &lt;/div&gt;

  &lt;h2 id=&quot;h6&quot;&gt;6. Kernel launch &lt;code&gt;&amp;lt;&amp;lt;&amp;lt; grid, block &amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;&lt;/h2&gt;
  &lt;p&gt;HIP/CUDA kernel launch syntax:&lt;/p&gt;
&lt;pre&gt;add_kernel&amp;lt;&amp;lt;&amp;lt; grid, block &amp;gt;&amp;gt;&amp;gt;(A, B, C, N);&lt;/pre&gt;
  &lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
    &lt;tr&gt;&lt;th&gt;Parameter&lt;/th&gt;&lt;th&gt;Meaning&lt;/th&gt;&lt;th&gt;Example&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;block&lt;/code&gt; (a.k.a. blockSize)&lt;/td&gt;&lt;td&gt;Threads per workgroup&lt;/td&gt;&lt;td&gt;256 → 4 waves per workgroup&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;grid&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Number of workgroups&lt;/td&gt;&lt;td&gt;4 → 4 workgroups total&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;(implicit)&lt;/td&gt;&lt;td&gt;Wave count = blockSize / 64&lt;/td&gt;&lt;td&gt;256 / 64 = 4 waves per workgroup&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;&lt;/div&gt;
  &lt;p&gt;&lt;b&gt;You don&#39;t pick the wave count directly&lt;/b&gt; — it is derived from blockSize. The hardware always groups threads into waves of 64 on CDNA.&lt;/p&gt;

&lt;pre class=&quot;diagram&quot;&gt;
add_kernel&amp;lt;&amp;lt;&amp;lt; grid=4, block=256 &amp;gt;&amp;gt;&amp;gt;(...)

Total threads = 4 × 256 = 1024
Total waves   = 1024 / 64 = 16
Total workgroups = 4

Each workgroup → one CU
Each wave → one SIMD inside that CU
&lt;/pre&gt;

  &lt;h2 id=&quot;h7&quot;&gt;7. Vector loads &amp;amp; the 16-byte rule&lt;/h2&gt;
  &lt;p&gt;A single load instruction can pull &lt;b&gt;up to 16 bytes&lt;/b&gt; into a thread&#39;s registers. This is the hardware limit on AMD CDNA.&lt;/p&gt;
  &lt;p&gt;The number of &lt;i&gt;elements&lt;/i&gt; per load (called &lt;b&gt;vec size&lt;/b&gt;) depends on the data type:&lt;/p&gt;
  &lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
    &lt;tr&gt;&lt;th&gt;Data type&lt;/th&gt;&lt;th&gt;Size (B)&lt;/th&gt;&lt;th&gt;vec=1&lt;/th&gt;&lt;th&gt;vec=2&lt;/th&gt;&lt;th&gt;vec=4&lt;/th&gt;&lt;th&gt;vec=8&lt;/th&gt;&lt;th&gt;vec=16&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;fp16 / bf16&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;2 B&lt;/td&gt;&lt;td&gt;4 B&lt;/td&gt;&lt;td&gt;8 B&lt;/td&gt;&lt;td&gt;&lt;b class=&quot;ok&quot;&gt;16 B (max)&lt;/b&gt;&lt;/td&gt;&lt;td&gt;—&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;fp32&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;4 B&lt;/td&gt;&lt;td&gt;8 B&lt;/td&gt;&lt;td&gt;&lt;b class=&quot;ok&quot;&gt;16 B (max)&lt;/b&gt;&lt;/td&gt;&lt;td&gt;—&lt;/td&gt;&lt;td&gt;—&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;int8&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;1 B&lt;/td&gt;&lt;td&gt;2 B&lt;/td&gt;&lt;td&gt;4 B&lt;/td&gt;&lt;td&gt;8 B&lt;/td&gt;&lt;td&gt;&lt;b class=&quot;ok&quot;&gt;16 B (max)&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;&lt;/div&gt;
  &lt;div class=&quot;key-box&quot;&gt;
    &lt;b&gt;Rule:&lt;/b&gt; &lt;code&gt;vec × sizeof(dtype) ≤ 16 byte&lt;/code&gt;. Larger vec means fewer load instructions to move the same amount of data — faster.
  &lt;/div&gt;

  &lt;h3&gt;Example GPU instructions&lt;/h3&gt;
&lt;pre&gt;fp16, vec=1 (2 B):
   global_load_ushort  v0,    v[1:2]    ; load 2 bytes (1 fp16)
fp16, vec=4 (8 B):
   global_load_dwordx2 v[0:1], v[2:3]   ; load 8 bytes (4 fp16)
fp16, vec=8 (16 B):
   global_load_dwordx4 v[0:3], v[4:5]   ; load 16 bytes (8 fp16) - MAX
fp32, vec=4 (16 B):
   global_load_dwordx4 v[0:3], v[4:5]   ; load 16 bytes (4 fp32) - MAX
&lt;/pre&gt;

  &lt;h2 id=&quot;h8&quot;&gt;8. Walking through a simple kernel&lt;/h2&gt;
&lt;pre&gt;__global__ void add_kernel(float* A, float* B, float* C, int N) {
    int tid = blockIdx.x * blockDim.x + threadIdx.x;  // global thread ID
    if (tid &amp;lt; N) {
        float a = A[tid];        // load (HBM → register)
        float b = B[tid];        // load (HBM → register)
        float c = a + b;         // ALU (register-to-register, ~1 cycle)
        C[tid] = c;              // store (register → HBM)
    }
}

add_kernel&amp;lt;&amp;lt;&amp;lt; 4, 256 &amp;gt;&amp;gt;&amp;gt;(A, B, C, 1024);
&lt;/pre&gt;
  &lt;p&gt;What happens per cycle (assuming occupancy 1, the worst case):&lt;/p&gt;
&lt;pre class=&quot;diagram&quot;&gt;
cycle:  1     2..99    100   101..199   200    201
        ----  ------   ----  --------   ----   -----
inst:   load   wait    load    wait     add    store
        A     (idle)   B      (idle)
                                                  ↓
                                          ALU only busy 2 cycles out of 200.
&lt;/pre&gt;
  &lt;p&gt;Instructions in this kernel: 4. &lt;b&gt;Actual cycles: ~200.&lt;/b&gt; The reason: each HBM load takes ~100 cycles to complete, even though issuing it takes 1 cycle. With occupancy 1, the SIMD has nothing else to do but wait.&lt;/p&gt;
  &lt;div class=&quot;note&quot;&gt;
    &lt;b&gt;If occupancy were 4&lt;/b&gt;, the SIMD would switch to other waves during the wait, keeping the ALU busy on every cycle. This is why high occupancy matters.
  &lt;/div&gt;

  &lt;h2 id=&quot;h9&quot;&gt;9. MFMA: cooperative matrix multiply&lt;/h2&gt;
  &lt;p&gt;MFMA (Matrix Fused Multiply-Add) instructions are &lt;b&gt;wave-cooperative&lt;/b&gt;: all 64 lanes work together to compute a small matrix multiply (e.g., 16×16).&lt;/p&gt;
&lt;pre class=&quot;diagram&quot;&gt;
v_mfma_f32_16x16x16_f16   acc, a_frag, b_frag, c_frag

  64 lanes cooperatively compute D = A × B + C
  where A is 16×16 fp16, B is 16×16 fp16, D is 16×16 fp32

  Each lane holds a small piece of A, B, and accumulates a small piece of D.
  The hardware exchanges data between lanes during execution.

  Latency: ~8–32 cycles (NOT 1 cycle), but throughput is enormous:
    16×16×16 = 4,096 multiply-adds per instruction per wave
&lt;/pre&gt;
  &lt;div class=&quot;key-box&quot;&gt;
    &lt;b&gt;Important:&lt;/b&gt; MFMA is a wave-level instruction. It cannot be split across waves — one wave executes one MFMA. To compute a larger matrix multiply, multiple waves issue multiple MFMAs (covering different tiles).
  &lt;/div&gt;

  &lt;h3&gt;CDNA vs RDNA&lt;/h3&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;b&gt;CDNA&lt;/b&gt; (data-center: gfx90a, gfx942, gfx950): MFMA available.&lt;/li&gt;
    &lt;li&gt;&lt;b&gt;RDNA&lt;/b&gt; (consumer: gfx11, gfx12): no MFMA. Has WMMA (Wave Matrix Multiply-Accumulate) instead with similar idea.&lt;/li&gt;
  &lt;/ul&gt;

  &lt;h2 id=&quot;h10&quot;&gt;10. Tiles &amp;amp; how a wave fills a tile (X0, Y0, X1, Y1)&lt;/h2&gt;

  &lt;h3&gt;What is a tile?&lt;/h3&gt;
  &lt;p&gt;A &lt;b&gt;tile&lt;/b&gt; is a 2D chunk of a matrix that one workgroup (or one wave) processes. GPU kernels divide a big problem into many small tiles.&lt;/p&gt;

&lt;pre class=&quot;diagram&quot;&gt;
Big matrix (e.g., 1024 × 1024)
divided into tiles of 64 × 64:

       X →
       ┌────────────────────────┐
   Y   │ t0  t1  t2  ...  t15   │
   ↓   │ t16 t17 ...            │   16 × 16 = 256 tiles
       │ ...                    │   each handled by one workgroup
       │ t240 ...          t255 │
       └────────────────────────┘
&lt;/pre&gt;

  &lt;h3&gt;How does a 64-thread wave fill a 64×64 tile?&lt;/h3&gt;
  &lt;p&gt;One 64×64 tile = 4,096 elements. One wave = 64 threads. Each thread is responsible for 4096/64 = &lt;b&gt;64 elements&lt;/b&gt;.&lt;/p&gt;
  &lt;p&gt;Those 64 elements per thread are split between two axes:&lt;/p&gt;

  &lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
    &lt;tr&gt;&lt;th&gt;Symbol&lt;/th&gt;&lt;th&gt;Meaning&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;b&gt;X1&lt;/b&gt; (= vec)&lt;/td&gt;&lt;td&gt;Number of elements one thread loads in one instruction (X direction).&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;b&gt;X0&lt;/b&gt;&lt;/td&gt;&lt;td&gt;Number of threads placed along the X axis.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;b&gt;Y0&lt;/b&gt;&lt;/td&gt;&lt;td&gt;Number of threads placed along the Y axis.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;b&gt;Y1&lt;/b&gt;&lt;/td&gt;&lt;td&gt;Number of times each thread iterates along the Y axis.&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;&lt;/div&gt;

  &lt;p&gt;Constraints:&lt;/p&gt;
&lt;pre class=&quot;diagram&quot;&gt;
X0 × Y0     = 64           ← total threads (wave size)
X0 × X1     = XPerTile     ← X axis fully covered
Y0 × Y1     = YPerTile     ← Y axis fully covered (with iteration)
X1 × sizeof ≤ 16 byte      ← hardware load limit
&lt;/pre&gt;

  &lt;h3&gt;Why the X axis can use vec loads&lt;/h3&gt;
  &lt;p&gt;Memory is 1D, but we view it as 2D (row-major):&lt;/p&gt;
&lt;pre class=&quot;diagram&quot;&gt;
memory:  [a][b][c][d] [e][f][g][h] [i][j][k][l] [m][n][o][p]
         ─────────── ─────────── ─────────── ───────────
            row 0       row 1       row 2       row 3

X direction: addresses +1 (contiguous)  → one instruction can load 4/8/16 bytes
Y direction: addresses +width (strided) → needs separate instructions per row
&lt;/pre&gt;

  &lt;h3&gt;Worked example: 64×64 tile, fp16, vec=4&lt;/h3&gt;
&lt;pre&gt;X1 = 4 (vec)
X0 = XPerTile / X1 = 64 / 4 = 16
Y0 = wave / X0     = 64 / 16 = 4
Y1 = YPerTile / Y0 = 64 / 4  = 16

Per thread:    X1 × Y1 = 4 × 16 = 64 elements
Per wave:      64 threads × 64 elements = 4,096 elements ✓
Load count:    16 (per thread) → 1024 total vec loads → 4,096 elements
&lt;/pre&gt;

&lt;pre class=&quot;diagram&quot;&gt;
                X axis (16 threads × 4 vec = 64 cols)
              ┌─────────────────────────────────────┐
   row 0..3   │ T0  T1  T2  T3  T4  T5 ... T14 T15  │   ← Y0=0, Y1=0..3
   row 4..7   │ T0  T1  T2  T3  ...                 │   ← Y0=0, Y1=4..7
   ...                                                  Y1 iterates 16 times
   row 16..   │ T16 T17 ...                         │   ← Y0=1
   row 32..   │ T32 T33 ...                         │   ← Y0=2
   row 48..63 │ T48 T49 ... T63                     │   ← Y0=3
              └─────────────────────────────────────┘
&lt;/pre&gt;

  &lt;h3&gt;Choosing vec size&lt;/h3&gt;
  &lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
    &lt;tr&gt;&lt;th&gt;vec&lt;/th&gt;&lt;th&gt;X0&lt;/th&gt;&lt;th&gt;Y0&lt;/th&gt;&lt;th&gt;Y1&lt;/th&gt;&lt;th&gt;Loads / thread&lt;/th&gt;&lt;th&gt;Quality&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;64&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;64&lt;/td&gt;&lt;td&gt;64&lt;/td&gt;&lt;td&gt;worst (no vec)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;32&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;32&lt;/td&gt;&lt;td&gt;32&lt;/td&gt;&lt;td&gt;poor&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;16&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;16&lt;/td&gt;&lt;td&gt;16&lt;/td&gt;&lt;td&gt;good&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;&lt;b class=&quot;ok&quot;&gt;best (fp16 max)&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;&lt;/div&gt;

  &lt;div class=&quot;key-box&quot;&gt;
    &lt;b&gt;Larger vec → fewer load instructions → faster&lt;/b&gt;, up to the 16-byte hardware limit.
  &lt;/div&gt;

  &lt;h2 id=&quot;h11&quot;&gt;11. Tile distribution patterns: thread / warp / block raked&lt;/h2&gt;
  &lt;p&gt;The same tile can be distributed across threads in several ways. The choice depends on the algorithm, the data layout, and the matrix instruction (MFMA) shape.&lt;/p&gt;

  &lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
    &lt;tr&gt;&lt;th&gt;Pattern&lt;/th&gt;&lt;th&gt;Who covers one tile&lt;/th&gt;&lt;th&gt;Wave layout inside tile&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;thread_raked&lt;/code&gt;&lt;/td&gt;&lt;td&gt;1 wave (64 threads)&lt;/td&gt;&lt;td&gt;n/a (single wave)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;warp_raked&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Multiple waves cooperate&lt;/td&gt;&lt;td&gt;1D stack (waves stripe along one axis)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;&lt;code&gt;block_raked&lt;/code&gt;&lt;/td&gt;&lt;td&gt;All waves of the workgroup&lt;/td&gt;&lt;td&gt;2D grid (waves arranged in a grid)&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;&lt;/div&gt;

  &lt;h3&gt;warp_raked — 1D wave layout (4 waves stacked along Y)&lt;/h3&gt;
&lt;pre class=&quot;diagram&quot;&gt;
                X axis (XPerTile)
              ┌─────────────────────────────────┐
              │          Wave 0                 │   each wave covers full X width
              ├─────────────────────────────────┤
              │          Wave 1                 │   1/4 of Y
              ├─────────────────────────────────┤
              │          Wave 2                 │
              ├─────────────────────────────────┤
              │          Wave 3                 │
              └─────────────────────────────────┘
&lt;/pre&gt;

  &lt;h3&gt;block_raked — 2D wave layout (4 waves in 2×2 grid)&lt;/h3&gt;
&lt;pre class=&quot;diagram&quot;&gt;
                X axis
              ┌───────────────┬─────────────┐
              │  Wave 0       │  Wave 1     │
              │ (X 0..63)     │ (X 64..127) │
              ├───────────────┼─────────────┤
              │  Wave 2       │  Wave 3     │
              │ (X 0..63)     │ (X 64..127) │
              └───────────────┴─────────────┘
&lt;/pre&gt;

  &lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
    &lt;tr&gt;&lt;th&gt;&lt;/th&gt;&lt;th&gt;warp_raked (1D)&lt;/th&gt;&lt;th&gt;block_raked (2D)&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Wave layout&lt;/td&gt;&lt;td&gt;1 axis (Y)&lt;/td&gt;&lt;td&gt;2 axes (X × Y)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Sub-tile per wave&lt;/td&gt;&lt;td&gt;XPerTile × (YPerTile/N)&lt;/td&gt;&lt;td&gt;(XPerTile/M) × (YPerTile/M)&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;X coverage by one wave&lt;/td&gt;&lt;td&gt;full&lt;/td&gt;&lt;td&gt;partial&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;&lt;/div&gt;

  &lt;div class=&quot;note&quot;&gt;
    The choice of pattern affects memory access patterns, MFMA fragment alignment, and register tile shapes. Each is best suited to different scenarios.
  &lt;/div&gt;

  &lt;h2 id=&quot;h12&quot;&gt;12. Cheat sheet&lt;/h2&gt;
  &lt;div class=&quot;table-wrap&quot;&gt;&lt;table&gt;
    &lt;tr&gt;&lt;th&gt;Concept&lt;/th&gt;&lt;th&gt;Definition&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Grid&lt;/td&gt;&lt;td&gt;The whole kernel launch.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Workgroup (block)&lt;/td&gt;&lt;td&gt;Group of threads on one CU. Shares LDS.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Wave (warp)&lt;/td&gt;&lt;td&gt;64 threads (CDNA) executing in lockstep (SIMT).&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Thread (work-item)&lt;/td&gt;&lt;td&gt;One software unit; runs on one lane.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Lane&lt;/td&gt;&lt;td&gt;One hardware ALU slot in a SIMD. 64 per SIMD.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;SIMD&lt;/td&gt;&lt;td&gt;Hardware execution unit. 4 per CU. Can hold up to 8 resident waves.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;CU&lt;/td&gt;&lt;td&gt;Compute Unit. Contains 4 SIMDs and 64 KB LDS. ~304 per MI300X.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;VGPR&lt;/td&gt;&lt;td&gt;Vector register, private per lane. 32-bit. Up to 256 per lane.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;SGPR&lt;/td&gt;&lt;td&gt;Scalar register, shared by all 64 lanes in a wave.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;AGPR&lt;/td&gt;&lt;td&gt;Accumulator register (CDNA), used for MFMA output.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;LDS&lt;/td&gt;&lt;td&gt;Local Data Share = software-managed shared memory. 64 KB per CU.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;HBM&lt;/td&gt;&lt;td&gt;Global memory. Large but slow (~500+ cycle latency).&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Occupancy&lt;/td&gt;&lt;td&gt;Number of resident waves on a SIMD (1–8). Higher = better latency hiding.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Latency hiding&lt;/td&gt;&lt;td&gt;SIMD switches to another resident wave while one waits on memory.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;SIMT&lt;/td&gt;&lt;td&gt;Single Instruction Multiple Threads. All 64 lanes run the same instruction.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;MFMA&lt;/td&gt;&lt;td&gt;Matrix Fused Multiply-Add. Wave-cooperative matrix multiply (CDNA).&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;WMMA&lt;/td&gt;&lt;td&gt;RDNA equivalent of MFMA.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Tile&lt;/td&gt;&lt;td&gt;2D chunk of a matrix processed by one workgroup.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;XPerTile / YPerTile&lt;/td&gt;&lt;td&gt;Tile dimensions in elements (algorithm-defined).&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;vec / X1&lt;/td&gt;&lt;td&gt;Elements per thread per load. Constrained by 16-byte limit.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;X0, Y0&lt;/td&gt;&lt;td&gt;Number of threads placed along X / Y axes.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Y1&lt;/td&gt;&lt;td&gt;Y-axis iteration count per thread.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Coalescing&lt;/td&gt;&lt;td&gt;Adjacent threads accessing adjacent memory → one wide HBM transaction.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;Kernel launch&lt;/td&gt;&lt;td&gt;&lt;code&gt;kernel&amp;lt;&amp;lt;&amp;lt; grid, block &amp;gt;&amp;gt;&amp;gt;(...)&lt;/code&gt; — grid = workgroups, block = threads/wg.&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;tile_distribution_pattern&lt;/td&gt;&lt;td&gt;How threads/waves are distributed across one tile (thread/warp/block raked).&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;&lt;/div&gt;

  &lt;div class=&quot;ok-box&quot; style=&quot;margin-top:32px&quot;&gt;
    &lt;b&gt;Key takeaways&lt;/b&gt;
    &lt;ul&gt;
      &lt;li&gt;Threads run in waves of 64; one instruction = one wave-step.&lt;/li&gt;
      &lt;li&gt;Memory is the slow part. High occupancy hides memory latency.&lt;/li&gt;
      &lt;li&gt;Vector loads (up to 16 B) reduce instruction count dramatically.&lt;/li&gt;
      &lt;li&gt;Tile dimensions are chosen by the algorithm; thread layout is derived from them.&lt;/li&gt;
      &lt;li&gt;MFMA is wave-cooperative — cannot be split across waves.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;

&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/6558500671975904949/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2026/05/amd-gpu-programming-primer-threads.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/6558500671975904949'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/6558500671975904949'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2026/05/amd-gpu-programming-primer-threads.html' title='AMD GPU Programming Primer — Threads, Waves, Tiles &amp; Vector Loads'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-6375298622928912092</id><published>2026-05-03T02:14:00.000-07:00</published><updated>2026-05-03T02:14:30.713-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="aws"/><category scheme="http://www.blogger.com/atom/ns#" term="ec2"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><category scheme="http://www.blogger.com/atom/ns#" term="vpn"/><title type='text'>How to Access Korean-Only Websites from Overseas Using AWS EC2 (Seoul Region VPN)</title><content type='html'>&lt;h2&gt;How to Access Korean-Only Websites from Overseas Using AWS EC2 (Seoul Region VPN)&lt;/h2&gt;

&lt;p&gt;Some Korean websites (government, financial, public institutions) block access from foreign IP addresses. This guide shows you how to create a quick VPN tunnel through AWS EC2 in Seoul to get a Korean IP address.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What you need:&lt;/strong&gt; AWS account, AWS CLI installed, Terminal (macOS/Linux)&lt;/p&gt;

&lt;hr&gt;

&lt;h3&gt;Step 1: Verify AWS CLI&lt;/h3&gt;

&lt;p&gt;Make sure AWS CLI is installed and configured:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;aws --version
aws sts get-caller-identity --region ap-northeast-2&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you see your Account ID, you&#39;re good to go.&lt;/p&gt;

&lt;hr&gt;

&lt;h3&gt;Step 2: Create a Key Pair&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;aws ec2 create-key-pair \
  --key-name kr-proxy-key \
  --region ap-northeast-2 \
  --query &#39;KeyMaterial&#39; \
  --output text &gt; ~/Desktop/kr-proxy-key.pem

chmod 400 ~/Desktop/kr-proxy-key.pem&lt;/code&gt;&lt;/pre&gt;

&lt;hr&gt;

&lt;h3&gt;Step 3: Create a Security Group&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;# Create security group
aws ec2 create-security-group \
  --group-name kr-proxy-sg \
  --description &quot;SSH proxy for Korean IP access&quot; \
  --region ap-northeast-2

# Allow SSH inbound (replace sg-xxxxx with your Group ID from above)
aws ec2 authorize-security-group-ingress \
  --group-id sg-xxxxx \
  --protocol tcp \
  --port 22 \
  --cidr 0.0.0.0/0 \
  --region ap-northeast-2&lt;/code&gt;&lt;/pre&gt;

&lt;hr&gt;

&lt;h3&gt;Step 4: Find the Latest AMI&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;aws ec2 describe-images \
  --owners amazon \
  --filters &quot;Name=name,Values=al2023-ami-2023*-x86_64&quot; &quot;Name=state,Values=available&quot; \
  --query &#39;Images | sort_by(@, &amp;amp;CreationDate) | [-1].ImageId&#39; \
  --output text \
  --region ap-northeast-2&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note the AMI ID (e.g. &lt;code&gt;ami-09a64de684ce1ac0e&lt;/code&gt;).&lt;/p&gt;

&lt;hr&gt;

&lt;h3&gt;Step 5: Launch EC2 Instance&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;aws ec2 run-instances \
  --image-id ami-09a64de684ce1ac0e \
  --instance-type t2.micro \
  --key-name kr-proxy-key \
  --security-group-ids sg-xxxxx \
  --associate-public-ip-address \
  --tag-specifications &#39;ResourceType=instance,Tags=[{Key=Name,Value=kr-proxy}]&#39; \
  --region ap-northeast-2 \
  --query &#39;Instances[0].InstanceId&#39; \
  --output text&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note the Instance ID (e.g. &lt;code&gt;i-0df42e446381ecc9a&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;t2.micro&lt;/strong&gt; is free-tier eligible (750 hours/month for 12 months).&lt;/p&gt;

&lt;hr&gt;

&lt;h3&gt;Step 6: Get Public IP&lt;/h3&gt;

&lt;p&gt;Wait about 30 seconds, then:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;aws ec2 describe-instances \
  --instance-ids i-xxxxx \
  --region ap-northeast-2 \
  --query &#39;Reservations[0].Instances[0].[State.Name, PublicIpAddress]&#39; \
  --output text&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You should see something like: &lt;code&gt;running  13.125.x.x&lt;/code&gt;&lt;/p&gt;

&lt;hr&gt;

&lt;h3&gt;Step 7: Open SSH SOCKS5 Tunnel&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;ssh -D 1080 -N -f \
  -o StrictHostKeyChecking=no \
  -i ~/Desktop/kr-proxy-key.pem \
  ec2-user@13.125.x.x&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;-D 1080&lt;/code&gt; — Creates a SOCKS5 proxy on local port 1080&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;-N&lt;/code&gt; — No remote command (tunnel only)&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;-f&lt;/code&gt; — Run in background&lt;/li&gt;
&lt;/ul&gt;

&lt;hr&gt;

&lt;h3&gt;Step 8: Verify Korean IP&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;curl --socks5-hostname localhost:1080 https://ifconfig.me&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If it returns your EC2&#39;s Korean IP (e.g. &lt;code&gt;13.125.x.x&lt;/code&gt;), it&#39;s working!&lt;/p&gt;

&lt;hr&gt;

&lt;h3&gt;Step 9: Configure Browser Proxy&lt;/h3&gt;

&lt;h4&gt;Option A: macOS System Settings&lt;/h4&gt;
&lt;ol&gt;
  &lt;li&gt;Open &lt;strong&gt;System Settings&lt;/strong&gt; → &lt;strong&gt;Network&lt;/strong&gt; → &lt;strong&gt;Wi-Fi&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;Click &lt;strong&gt;Details...&lt;/strong&gt; → &lt;strong&gt;Proxies&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;Enable &lt;strong&gt;SOCKS Proxy&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;Server: &lt;code&gt;localhost&lt;/code&gt; / Port: &lt;code&gt;1080&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Click &lt;strong&gt;OK&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;Option B: Terminal (macOS)&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;sudo networksetup -setsocksfirewallproxy &quot;Wi-Fi&quot; localhost 1080
sudo networksetup -setsocksfirewallproxystate &quot;Wi-Fi&quot; on&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Option C: curl only&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;curl --socks5-hostname localhost:1080 https://www.target-website.kr&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now open your browser and access the Korean website!&lt;/p&gt;

&lt;hr&gt;

&lt;h2&gt;Clean Up (Important!)&lt;/h2&gt;

&lt;p&gt;When you&#39;re done, clean up everything to avoid charges:&lt;/p&gt;

&lt;h3&gt;1. Close the SSH Tunnel&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;pkill -f &quot;ssh -D 1080&quot;&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;2. Turn Off Browser Proxy&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;macOS GUI:&lt;/strong&gt; System Settings → Network → Wi-Fi → Details → Proxies → SOCKS Proxy OFF&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Terminal:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo networksetup -setsocksfirewallproxystate &quot;Wi-Fi&quot; off

# Verify
networksetup -getsocksfirewallproxy &quot;Wi-Fi&quot;
# Should show: Enabled: No&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;3. Terminate EC2 Instance&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;aws ec2 terminate-instances \
  --instance-ids i-xxxxx \
  --region ap-northeast-2&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;4. Delete Security Group&lt;/h3&gt;

&lt;p&gt;Wait about 30 seconds after termination, then:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;aws ec2 delete-security-group \
  --group-id sg-xxxxx \
  --region ap-northeast-2&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;5. Delete Key Pair&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;aws ec2 delete-key-pair \
  --key-name kr-proxy-key \
  --region ap-northeast-2

rm ~/Desktop/kr-proxy-key.pem&lt;/code&gt;&lt;/pre&gt;

&lt;hr&gt;

&lt;h2&gt;Cost Summary&lt;/h2&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;8&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse; width: 100%;&quot;&gt;
  &lt;tr style=&quot;background-color: #f2f2f2;&quot;&gt;
    &lt;th&gt;Item&lt;/th&gt;
    &lt;th&gt;Cost&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;t2.micro (free tier)&lt;/td&gt;
    &lt;td&gt;&lt;strong&gt;Free&lt;/strong&gt; (750 hrs/month, 12 months)&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;t2.micro (after free tier)&lt;/td&gt;
    &lt;td&gt;~$0.0116/hr (~$8.5/month)&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Data transfer&lt;/td&gt;
    &lt;td&gt;Free up to 100GB/month&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; If you want to keep the instance for later, &lt;strong&gt;Stop&lt;/strong&gt; it instead of terminating. You only pay for EBS storage (~$0.10/GB/month) while stopped.&lt;/p&gt;

&lt;hr&gt;

&lt;h2&gt;Quick Reference: Reconnect Later&lt;/h2&gt;

&lt;p&gt;If you stopped (not terminated) the instance:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Start the instance
aws ec2 start-instances --instance-ids i-xxxxx --region ap-northeast-2

# Wait ~30 seconds, get new public IP
aws ec2 describe-instances \
  --instance-ids i-xxxxx \
  --region ap-northeast-2 \
  --query &#39;Reservations[0].Instances[0].PublicIpAddress&#39; \
  --output text

# Open tunnel
ssh -D 1080 -N -f -i ~/Desktop/kr-proxy-key.pem ec2-user@NEW-IP

# Set proxy
sudo networksetup -setsocksfirewallproxy &quot;Wi-Fi&quot; localhost 1080
sudo networksetup -setsocksfirewallproxystate &quot;Wi-Fi&quot; on&lt;/code&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/6375298622928912092/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2026/05/how-to-access-korean-only-websites-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/6375298622928912092'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/6375298622928912092'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2026/05/how-to-access-korean-only-websites-from.html' title='How to Access Korean-Only Websites from Overseas Using AWS EC2 (Seoul Region VPN)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-7637422666148080318</id><published>2026-03-08T03:31:00.000-07:00</published><updated>2026-03-08T03:46:07.149-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DUN"/><category scheme="http://www.blogger.com/atom/ns#" term="DUNS"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><title type='text'>How to Apply for a D-U-N-S Number</title><content type='html'>&lt;style&gt;
  .duns-tutorial .dt-inner { max-width: 760px; margin: 0 auto; padding: 0 24px; }
  .duns-tutorial .tag { display: inline-block; background: #e8f0fe; color: #1a56db; font-family: monospace; font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 10px; border-radius: 3px; margin-bottom: 16px; }
  .duns-tutorial .subtitle { font-size: 1rem; font-style: italic; }
  .duns-tutorial .toc { border-left: 3px solid #ddd; padding: 4px 0 4px 20px; margin: 0 0 48px; }
  .duns-tutorial .toc-title { font-family: monospace; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 12px; }
  .duns-tutorial .toc ol { padding-left: 20px; }
  .duns-tutorial .toc li { font-size: 0.95rem; line-height: 2.1; }
  .duns-tutorial .toc a { color: #2563eb; text-decoration: none; }
  .duns-tutorial .toc a:hover { text-decoration: underline; }
  .duns-tutorial .section { margin-bottom: 56px; }
  .duns-tutorial .section h2 { font-size: 1.4rem; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 16px; border-top: 2px solid #333; padding-top: 12px; }
  .duns-tutorial .section h3 { font-size: 1.05rem; font-weight: 600; margin: 24px 0 10px; }
  .duns-tutorial .section p { margin-bottom: 14px; }
  .duns-tutorial .section ul, .duns-tutorial .section ol { padding-left: 22px; margin-bottom: 14px; }
  .duns-tutorial .section li { margin-bottom: 4px; }
  .duns-tutorial .section a { color: #2563eb; }
  .duns-tutorial .step-block { border-left: 3px solid #ddd; padding: 4px 0 4px 16px; margin: 14px 0; }
  .duns-tutorial .step-block p { margin-bottom: 8px; }
  .duns-tutorial .step-block p:last-child { margin-bottom: 0; }
  .duns-tutorial .step-num { font-family: monospace; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 6px; }
  .duns-tutorial .dt-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin: 16px 0; }
  .duns-tutorial .dt-table thead { border-bottom: 2px solid #333; }
  .duns-tutorial .dt-table th { font-family: monospace; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; padding: 10px 14px; text-align: left; border: 1px solid #ddd; }
  .duns-tutorial .dt-table td { padding: 10px 14px; text-align: left; border: 1px solid #ddd; }
  .duns-tutorial .dt-table td:first-child { font-family: monospace; font-size: 12px; color: #2563eb; white-space: nowrap; }
  .duns-tutorial .note { border-left: 3px solid #86efac; padding: 4px 0 4px 16px; font-size: 0.9rem; margin: 16px 0; }
  .duns-tutorial .note a { font-weight: 600; }
  .duns-tutorial .warn { border-left: 3px solid #fcd34d; padding: 4px 0 4px 16px; font-size: 0.9rem; margin: 16px 0; }
  .duns-tutorial .warn a { font-weight: 600; }
  .duns-tutorial code { font-family: monospace; font-size: 13px; background: #e8edf5; color: #1a56db; padding: 1px 6px; border-radius: 3px; }
  .duns-tutorial .example-label { font-family: monospace; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 6px; }
  .duns-tutorial .example-block { font-family: monospace; font-size: 13px; line-height: 1.7; padding: 0 0 0 16px; margin: 12px 0; border-left: 3px solid #ddd; white-space: pre-wrap; }
  .duns-tutorial .checklist { list-style: none; padding: 0; margin: 16px 0; }
  .duns-tutorial .checklist li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid #ddd; font-size: 0.95rem; }
  .duns-tutorial .checklist li:last-child { border-bottom: none; }
  .duns-tutorial .check-box { width: 18px; height: 18px; border: 2px solid #ddd; border-radius: 3px; flex-shrink: 0; margin-top: 3px; }
  .duns-tutorial .resources ul { list-style: none; padding: 0; }
  .duns-tutorial .resources li { padding: 9px 0; border-bottom: 1px solid #ddd; font-size: 0.95rem; }
  .duns-tutorial .resources li:last-child { border-bottom: none; }
  .duns-tutorial .resources a { color: #2563eb; text-decoration: none; }
  .duns-tutorial .resources a:hover { text-decoration: underline; }
  @media (max-width: 600px) {
    .duns-tutorial .dt-table { font-size: 0.82rem; }
    .duns-tutorial .dt-table th, .duns-tutorial .dt-table td { padding: 8px 10px; }
  }
&lt;/style&gt;

&lt;div class=&quot;duns-tutorial&quot;&gt;
&lt;div class=&quot;dt-inner&quot;&gt;

  &lt;div class=&quot;toc&quot;&gt;
    &lt;div class=&quot;toc-title&quot;&gt;Contents&lt;/div&gt;
    &lt;ol&gt;
      &lt;li&gt;&lt;a href=&quot;#s1&quot;&gt;What is a D-U-N-S Number?&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#s2&quot;&gt;Prerequisites — Documents to Prepare&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#s3&quot;&gt;Go to the D&amp;amp;B Application Portal&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#s4&quot;&gt;Select Your Request Type&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#s5&quot;&gt;Search for an Existing D-U-N-S&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#s6&quot;&gt;Fill Out the Application Form&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#s7&quot;&gt;Attach Supporting Documents&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#s8&quot;&gt;Add Notes &amp;amp; Submit&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#s9&quot;&gt;What Happens Next?&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#s10&quot;&gt;Troubleshooting: Common Rejection Reasons&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#s11&quot;&gt;Using Your D-U-N-S for Apple Developer Enrollment&lt;/a&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/div&gt;

  &lt;!-- Section 1 --&gt;
  &lt;div class=&quot;section&quot; id=&quot;s1&quot;&gt;
    &lt;h2&gt;1. What is a D-U-N-S Number?&lt;/h2&gt;
    &lt;p&gt;A &lt;strong&gt;D-U-N-S Number&lt;/strong&gt; (Data Universal Numbering System) is a unique 9-digit business identifier issued by &lt;strong&gt;Dun &amp;amp; Bradstreet (D&amp;amp;B)&lt;/strong&gt;. It is used globally to identify and verify businesses for purposes such as:&lt;/p&gt;
    &lt;ul&gt;
      &lt;li&gt;Enrolling in the &lt;strong&gt;Apple Developer Program&lt;/strong&gt; as an organization&lt;/li&gt;
      &lt;li&gt;Applying for government contracts and grants&lt;/li&gt;
      &lt;li&gt;Establishing business credit profiles&lt;/li&gt;
      &lt;li&gt;Vendor and supplier registration&lt;/li&gt;
    &lt;/ul&gt;
    &lt;div class=&quot;note&quot;&gt;
      💡 &lt;strong&gt;Apple requires a D-U-N-S Number&lt;/strong&gt; to verify your organization&#39;s legal identity before issuing an Apple Developer team account. Individual accounts do not need one.
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;!-- Section 2 --&gt;
  &lt;div class=&quot;section&quot; id=&quot;s2&quot;&gt;
    &lt;h2&gt;2. Prerequisites — Documents to Prepare&lt;/h2&gt;
    &lt;p&gt;Before starting the application, gather the following information and documents:&lt;/p&gt;
    &lt;table class=&quot;dt-table&quot;&gt;
      &lt;thead&gt;
        &lt;tr&gt;&lt;th&gt;Item&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
        &lt;tr&gt;&lt;td&gt;Business Name&lt;/td&gt;&lt;td&gt;Full legal name exactly as registered&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Registration Number&lt;/td&gt;&lt;td&gt;Tax ID or company registration number&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Business Address&lt;/td&gt;&lt;td&gt;Full address including postal code and country&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Phone Number&lt;/td&gt;&lt;td&gt;International format: &lt;code&gt;+[country code][number]&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;CEO / Owner Info&lt;/td&gt;&lt;td&gt;Full legal name and title (e.g., Owner, CEO)&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Website&lt;/td&gt;&lt;td&gt;Company website URL (if available)&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Date Founded&lt;/td&gt;&lt;td&gt;Official business establishment date&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Employee Count&lt;/td&gt;&lt;td&gt;Total headcount including yourself&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Registration Certificate&lt;/td&gt;&lt;td&gt;&lt;strong&gt;English version&lt;/strong&gt; — PDF format preferred&lt;/td&gt;&lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
    &lt;div class=&quot;warn&quot;&gt;
      ⚠️ &lt;strong&gt;Non-English documents must be translated.&lt;/strong&gt; Check your country&#39;s official tax authority or business registration portal — many offer an official English-language certificate export option directly.
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;!-- Section 3 --&gt;
  &lt;div class=&quot;section&quot; id=&quot;s3&quot;&gt;
    &lt;h2&gt;3. Go to the D&amp;amp;B Application Portal&lt;/h2&gt;
    &lt;p&gt;Navigate to the appropriate portal based on your use case:&lt;/p&gt;
    &lt;div class=&quot;step-block&quot;&gt;
      &lt;div class=&quot;step-num&quot;&gt;Apple Developer Program&lt;/div&gt;
      &lt;p&gt;👉 &lt;a href=&quot;https://support.dnb.com/?CUST=APPLEDEV&quot; target=&quot;_blank&quot;&gt;https://support.dnb.com/?CUST=APPLEDEV&lt;/a&gt;&lt;/p&gt;
      &lt;p&gt;Use this URL if you are applying specifically to enroll in the Apple Developer Program as an organization.&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class=&quot;step-block&quot;&gt;
      &lt;div class=&quot;step-num&quot;&gt;General D-U-N-S Application&lt;/div&gt;
      &lt;p&gt;👉 &lt;a href=&quot;https://www.dnb.com/duns-number/get-a-duns.html&quot; target=&quot;_blank&quot;&gt;https://www.dnb.com/duns-number/get-a-duns.html&lt;/a&gt;&lt;/p&gt;
      &lt;p&gt;Use this for general business registration, government contracts, or other purposes.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;!-- Section 4 --&gt;
  &lt;div class=&quot;section&quot; id=&quot;s4&quot;&gt;
    &lt;h2&gt;4. Select Your Request Type&lt;/h2&gt;
    &lt;p&gt;On the Apple Developer D&amp;amp;B portal, you will be asked two questions:&lt;/p&gt;
    &lt;div class=&quot;step-block&quot;&gt;
      &lt;div class=&quot;step-num&quot;&gt;Step 4a&lt;/div&gt;
      &lt;p&gt;Under &lt;strong&gt;&quot;What are you?&quot;&lt;/strong&gt; → select &lt;strong&gt;Developer Program&lt;/strong&gt;&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class=&quot;step-block&quot;&gt;
      &lt;div class=&quot;step-num&quot;&gt;Step 4b&lt;/div&gt;
      &lt;p&gt;Under &lt;strong&gt;&quot;What do you need?&quot;&lt;/strong&gt; → select &lt;strong&gt;Create New DUNS&lt;/strong&gt;&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;!-- Section 5 --&gt;
  &lt;div class=&quot;section&quot; id=&quot;s5&quot;&gt;
    &lt;h2&gt;5. Search for an Existing D-U-N-S&lt;/h2&gt;
    &lt;p&gt;The portal checks whether your business already has a D-U-N-S number before creating a new one.&lt;/p&gt;
    &lt;div class=&quot;step-block&quot;&gt;
      &lt;div class=&quot;step-num&quot;&gt;Step 5a&lt;/div&gt;
      &lt;p&gt;Enter your &lt;strong&gt;business name&lt;/strong&gt; and &lt;strong&gt;full address&lt;/strong&gt; in the search fields.&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class=&quot;step-block&quot;&gt;
      &lt;div class=&quot;step-num&quot;&gt;Step 5b&lt;/div&gt;
      &lt;p&gt;Click &lt;strong&gt;&quot;Lookup by Name / Address&quot;&lt;/strong&gt;.&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class=&quot;step-block&quot;&gt;
      &lt;div class=&quot;step-num&quot;&gt;Step 5c — Expected Result&lt;/div&gt;
      &lt;p&gt;For new businesses: you will see &lt;strong&gt;&quot;No Match found&quot;&lt;/strong&gt; — this is completely normal and expected.&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class=&quot;step-block&quot;&gt;
      &lt;div class=&quot;step-num&quot;&gt;Step 5d&lt;/div&gt;
      &lt;p&gt;Click &lt;strong&gt;&quot;click here to submit a request to create a new D-U-N-S&quot;&lt;/strong&gt; to open the full application form.&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class=&quot;note&quot;&gt;
      ✅ If a match is found, your business already has a D-U-N-S. You can claim or update it instead of creating a new one — contact D&amp;amp;B support directly.
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;!-- Section 6 --&gt;
  &lt;div class=&quot;section&quot; id=&quot;s6&quot;&gt;
    &lt;h2&gt;6. Fill Out the Application Form&lt;/h2&gt;
    &lt;p&gt;Complete all fields in the &lt;strong&gt;Create D-U-N-S Number&lt;/strong&gt; form. All fields must exactly match your official registration documents.&lt;/p&gt;
    &lt;table class=&quot;dt-table&quot;&gt;
      &lt;thead&gt;
        &lt;tr&gt;&lt;th&gt;Field&lt;/th&gt;&lt;th&gt;What to Enter&lt;/th&gt;&lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
        &lt;tr&gt;&lt;td&gt;Full Legal Business Name&lt;/td&gt;&lt;td&gt;Exact name as on registration documents&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Business Registration Number&lt;/td&gt;&lt;td&gt;Your tax ID / company ID number&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Company Phone&lt;/td&gt;&lt;td&gt;International format (e.g., &lt;code&gt;+358501234567&lt;/code&gt;)&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Street Address&lt;/td&gt;&lt;td&gt;Full street address&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;City&lt;/td&gt;&lt;td&gt;City name&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;State / Province&lt;/td&gt;&lt;td&gt;State or province (if applicable)&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Postal Code&lt;/td&gt;&lt;td&gt;ZIP / postal code&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Country&lt;/td&gt;&lt;td&gt;Your country&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Business Structure&lt;/td&gt;&lt;td&gt;e.g., Sole Proprietorship, LLC, Corporation&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;CEO / Owner Name&lt;/td&gt;&lt;td&gt;Full legal name&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;CEO / Owner Title&lt;/td&gt;&lt;td&gt;e.g., Owner, CEO, Director&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Website&lt;/td&gt;&lt;td&gt;Company website URL&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Home-Based Business&lt;/td&gt;&lt;td&gt;Yes / No&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Number of Employees&lt;/td&gt;&lt;td&gt;Total headcount (including yourself)&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Date Founded&lt;/td&gt;&lt;td&gt;Official establishment date (MM/DD/YYYY)&lt;/td&gt;&lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
    &lt;div class=&quot;warn&quot;&gt;
      ⚠️ &lt;strong&gt;Exact match required.&lt;/strong&gt; The business name, address, and registration number must match your official documents precisely. Even minor differences (abbreviations, punctuation) can cause rejection.
    &lt;/div&gt;
    &lt;p&gt;Click &lt;strong&gt;&quot;Next&quot;&lt;/strong&gt; to advance to the document attachment page.&lt;/p&gt;
  &lt;/div&gt;

  &lt;!-- Section 7 --&gt;
  &lt;div class=&quot;section&quot; id=&quot;s7&quot;&gt;
    &lt;h2&gt;7. Attach Supporting Documents&lt;/h2&gt;
    &lt;p&gt;Upload a document to verify your business registration. This is &lt;strong&gt;required&lt;/strong&gt; — submissions without a document attachment are typically rejected.&lt;/p&gt;
    &lt;div class=&quot;step-block&quot;&gt;
      &lt;div class=&quot;step-num&quot;&gt;Accepted Documents&lt;/div&gt;
      &lt;p&gt;✅ English Business Registration Certificate (strongly preferred)&lt;/p&gt;
      &lt;p&gt;✅ Official government-issued business license&lt;/p&gt;
      &lt;p&gt;✅ Any official document showing your business name, registration number, and address&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class=&quot;note&quot;&gt;
      📄 &lt;strong&gt;PDF format is recommended.&lt;/strong&gt; File size is typically not an issue, but keep it under 5MB to be safe. Make sure the document is clearly legible and all key information is visible.
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;!-- Section 8 --&gt;
  &lt;div class=&quot;section&quot; id=&quot;s8&quot;&gt;
    &lt;h2&gt;8. Add Notes &amp;amp; Submit&lt;/h2&gt;
    &lt;p&gt;There is usually a free-text &lt;strong&gt;Additional Details / Notes&lt;/strong&gt; field. Always fill this in — it helps the D&amp;amp;B reviewer understand your submission and can speed up approval.&lt;/p&gt;

    &lt;h3&gt;Example — First-time application&lt;/h3&gt;
    &lt;div class=&quot;example-label&quot;&gt;Sample note text&lt;/div&gt;
    &lt;div class=&quot;example-block&quot;&gt;This is a new D-U-N-S number request for [Your Business Name], a sole proprietorship
registered in [Country] since [Year]. Business is engaged in [industry, e.g. software
development]. English Business Registration Certificate is attached.&lt;/div&gt;

    &lt;h3&gt;Example — Resubmission after rejection&lt;/h3&gt;
    &lt;div class=&quot;example-label&quot;&gt;Sample note text&lt;/div&gt;
    &lt;div class=&quot;example-block&quot;&gt;Resubmitting after previous rejection (Case #XXXXXXXX) which was closed due to
missing English Business Registration Certificate. The English certificate is now attached.
Business registration number: [Your Number]. Business started: [Date].&lt;/div&gt;

    &lt;p&gt;After reviewing all information, click &lt;strong&gt;Submit&lt;/strong&gt;.&lt;/p&gt;
    &lt;div class=&quot;note&quot;&gt;
      💾 &lt;strong&gt;Save your case number immediately&lt;/strong&gt; after submission — you will need it to track your application status or to reference in any resubmission.
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;!-- Section 9 --&gt;
  &lt;div class=&quot;section&quot; id=&quot;s9&quot;&gt;
    &lt;h2&gt;9. What Happens Next?&lt;/h2&gt;
    &lt;p&gt;After submission, D&amp;amp;B will review your request. Here is the typical timeline:&lt;/p&gt;
    &lt;table class=&quot;dt-table&quot;&gt;
      &lt;tbody&gt;
        &lt;tr&gt;&lt;td&gt;Immediately&lt;/td&gt;&lt;td&gt;On-screen confirmation + case number displayed. Check your email for a confirmation from D&amp;amp;B (check spam).&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;1–2 business days&lt;/td&gt;&lt;td&gt;D&amp;amp;B reviews your submitted information and documents.&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;3–5 business days&lt;/td&gt;&lt;td&gt;D-U-N-S Number issued and emailed to you.&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Up to 30 days&lt;/td&gt;&lt;td&gt;In some cases D&amp;amp;B may request additional documentation.&lt;/td&gt;&lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
    &lt;div class=&quot;note&quot;&gt;
      📬 D&amp;amp;B will send your D-U-N-S Number by email. Once received, the number is also searchable via the D&amp;amp;B portal. &lt;strong&gt;Apple recommends waiting 24–48 hours&lt;/strong&gt; after receiving your number before using it for developer enrollment.
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;!-- Section 10 --&gt;
  &lt;div class=&quot;section&quot; id=&quot;s10&quot;&gt;
    &lt;h2&gt;10. Troubleshooting: Common Rejection Reasons&lt;/h2&gt;
    &lt;table class=&quot;dt-table&quot;&gt;
      &lt;thead&gt;
        &lt;tr&gt;&lt;th&gt;Issue&lt;/th&gt;&lt;th&gt;Solution&lt;/th&gt;&lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
        &lt;tr&gt;&lt;td&gt;Missing English document&lt;/td&gt;&lt;td&gt;Obtain an official English translation of your registration certificate and resubmit&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Business name mismatch&lt;/td&gt;&lt;td&gt;Ensure the name on the form exactly matches your official documents (character for character)&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Address not recognized&lt;/td&gt;&lt;td&gt;Use the exact address format from your registration documents&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Duplicate D-U-N-S found&lt;/td&gt;&lt;td&gt;Contact D&amp;amp;B to claim or update the existing record instead of creating a new one&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Case closed, no response&lt;/td&gt;&lt;td&gt;Resubmit the form and reference the previous case number in the notes field&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td&gt;Document unreadable&lt;/td&gt;&lt;td&gt;Re-export or rescan the document as a clear, high-resolution PDF&lt;/td&gt;&lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;

  &lt;!-- Section 11 --&gt;
  &lt;div class=&quot;section&quot; id=&quot;s11&quot;&gt;
    &lt;h2&gt;11. Using Your D-U-N-S for Apple Developer Enrollment&lt;/h2&gt;
    &lt;p&gt;Once you have your D-U-N-S Number:&lt;/p&gt;
    &lt;div class=&quot;step-block&quot;&gt;
      &lt;div class=&quot;step-num&quot;&gt;Step 1&lt;/div&gt;
      &lt;p&gt;Go to &lt;a href=&quot;https://developer.apple.com/enroll/&quot; target=&quot;_blank&quot;&gt;https://developer.apple.com/enroll/&lt;/a&gt;&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class=&quot;step-block&quot;&gt;
      &lt;div class=&quot;step-num&quot;&gt;Step 2&lt;/div&gt;
      &lt;p&gt;Select &lt;strong&gt;&quot;Enroll as an Organization&quot;&lt;/strong&gt; (not Individual).&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class=&quot;step-block&quot;&gt;
      &lt;div class=&quot;step-num&quot;&gt;Step 3&lt;/div&gt;
      &lt;p&gt;Enter your D-U-N-S Number when prompted. Apple will verify it against D&amp;amp;B&#39;s database.&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class=&quot;step-block&quot;&gt;
      &lt;div class=&quot;step-num&quot;&gt;Step 4&lt;/div&gt;
      &lt;p&gt;Allow &lt;strong&gt;24–48 hours&lt;/strong&gt; after receiving your D-U-N-S before enrolling — the number needs time to propagate in D&amp;amp;B&#39;s system.&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class=&quot;note&quot;&gt;
      ✅ The Apple verification process typically takes a few days after enrollment. Apple may call your registered business phone number to verify your identity as the organization&#39;s legal representative.
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;!-- Final Checklist --&gt;
  &lt;div class=&quot;section&quot;&gt;
    &lt;h2&gt;Final Checklist&lt;/h2&gt;
    &lt;ul class=&quot;checklist&quot;&gt;
      &lt;li&gt;&lt;span class=&quot;check-box&quot;&gt;&lt;/span&gt; Prepared English business registration certificate (PDF)&lt;/li&gt;
      &lt;li&gt;&lt;span class=&quot;check-box&quot;&gt;&lt;/span&gt; Navigated to the D&amp;amp;B portal (APPLEDEV or general)&lt;/li&gt;
      &lt;li&gt;&lt;span class=&quot;check-box&quot;&gt;&lt;/span&gt; Selected correct request type (Developer Program → Create New DUNS)&lt;/li&gt;
      &lt;li&gt;&lt;span class=&quot;check-box&quot;&gt;&lt;/span&gt; Searched for existing D-U-N-S — confirmed no match&lt;/li&gt;
      &lt;li&gt;&lt;span class=&quot;check-box&quot;&gt;&lt;/span&gt; Filled out all form fields matching official documents exactly&lt;/li&gt;
      &lt;li&gt;&lt;span class=&quot;check-box&quot;&gt;&lt;/span&gt; Uploaded supporting document (English certificate)&lt;/li&gt;
      &lt;li&gt;&lt;span class=&quot;check-box&quot;&gt;&lt;/span&gt; Added descriptive notes in the Additional Details field&lt;/li&gt;
      &lt;li&gt;&lt;span class=&quot;check-box&quot;&gt;&lt;/span&gt; Submitted the form and saved the case number&lt;/li&gt;
      &lt;li&gt;&lt;span class=&quot;check-box&quot;&gt;&lt;/span&gt; Waiting for D&amp;amp;B email confirmation (3–5 business days)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;

  &lt;!-- Resources --&gt;
  &lt;div class=&quot;section&quot;&gt;
    &lt;h2&gt;Resources&lt;/h2&gt;
    &lt;div class=&quot;resources&quot;&gt;
      &lt;ul&gt;
        &lt;li&gt;🏛️ &lt;a href=&quot;https://support.dnb.com/?CUST=APPLEDEV&quot; target=&quot;_blank&quot;&gt;D&amp;amp;B Portal for Apple Developer — support.dnb.com/?CUST=APPLEDEV&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;🍎 &lt;a href=&quot;https://developer.apple.com/support/D-U-N-S/&quot; target=&quot;_blank&quot;&gt;Apple&#39;s D-U-N-S Number guide — developer.apple.com&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;🍎 &lt;a href=&quot;https://developer.apple.com/enroll/&quot; target=&quot;_blank&quot;&gt;Apple Developer Program Enrollment — developer.apple.com/enroll&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;🏦 &lt;a href=&quot;https://www.dnb.com/duns-number/get-a-duns.html&quot; target=&quot;_blank&quot;&gt;General D-U-N-S Number Application — dnb.com&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;p style=&quot;font-size: 0.85em; margin-top: 40px;&quot;&gt;Last updated: March 2026 · For general informational purposes&lt;/p&gt;
&lt;p style=&quot;font-size: 0.8em; margin-top: 8px;&quot;&gt;Main image by &lt;a href=&quot;https://unsplash.com/@syawish&quot; target=&quot;_blank&quot; &gt;Syawish Rehman&lt;/a&gt; on Unsplash&lt;/p&gt;

&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/7637422666148080318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2026/03/how-to-apply-for-d-u-n-s-number.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/7637422666148080318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/7637422666148080318'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2026/03/how-to-apply-for-d-u-n-s-number.html' title='How to Apply for a D-U-N-S Number'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-3582496463909776048</id><published>2026-01-09T13:51:00.032-08:00</published><updated>2026-01-09T13:51:06.114-08:00</updated><title type='text'>🚙🚙 AUTOMATIC NUMBER PLATE RECOGNITION (ANPR, LPR, ALPR) solution</title><content type='html'>&lt;iframe width=&quot;480&quot; height=&quot;270&quot; src=&quot;https://youtube.com/embed/hF0RmN2LEXA?si=3utwSf9OuFhlZHM9&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/3582496463909776048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2026/01/automatic-number-plate-recognition-anpr.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/3582496463909776048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/3582496463909776048'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2026/01/automatic-number-plate-recognition-anpr.html' title='🚙🚙 AUTOMATIC NUMBER PLATE RECOGNITION (ANPR, LPR, ALPR) solution'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/hF0RmN2LEXA/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-8266134919207589693</id><published>2026-01-09T05:12:00.000-08:00</published><updated>2026-01-09T05:12:30.115-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="amd"/><category scheme="http://www.blogger.com/atom/ns#" term="build"/><category scheme="http://www.blogger.com/atom/ns#" term="hipdnn"/><category scheme="http://www.blogger.com/atom/ns#" term="miopen"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><title type='text'>Step-by-Step: Building MIOpen and hipDNN with Ninja</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;composer-human-ai-pair-container&quot; style=&quot;background-color: #181818; box-sizing: border-box; color: rgba(228, 228, 228, 0.55); display: flex; flex-direction: column; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; orphans: 2; position: relative; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;relative composer-rendered-message hide-if-empty composer-message-blur&quot; data-message-id=&quot;4f2a9747-e3d7-4d02-b762-aa25099bcd12&quot; data-message-index=&quot;27&quot; data-message-kind=&quot;assistant&quot; data-message-role=&quot;ai&quot; id=&quot;bubble-aa25099bcd12&quot; style=&quot;opacity: 1; outline: currentcolor; padding: 0px 18px; position: relative; z-index: 99;&quot; tabindex=&quot;0&quot;&gt;&lt;div&gt;&lt;div style=&quot;position: sticky; top: 0px;&quot;&gt;&lt;div style=&quot;padding: 0px 2px;&quot;&gt;&lt;span class=&quot;anysphere-markdown-container-root&quot; color=&quot;rgba(228, 228, 228, 0.92)&quot; style=&quot;font-size: 1em; line-height: 1.5; min-height: 22.2px;&quot;&gt;&lt;section class=&quot;markdown-section&quot; data-markdown-raw=&quot;

## **Step-by-Step: Building MIOpen and hipDNN with Ninja**&quot; data-section-index=&quot;1&quot; id=&quot;markdown-section-4f2a9747-e3d7-4d02-b762-aa25099bcd12-1&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;h2 style=&quot;font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot;&gt;Step-by-Step: Building MIOpen and hipDNN with Ninja&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section&quot; data-markdown-raw=&quot;
Let me execute this for you:&quot; data-section-index=&quot;3&quot; id=&quot;markdown-section-4f2a9747-e3d7-4d02-b762-aa25099bcd12-3&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;/section&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-human-ai-pair-container&quot; style=&quot;background-color: #181818; box-sizing: border-box; color: rgba(228, 228, 228, 0.55); display: flex; flex-direction: column; font-family: -apple-system, system-ui, sans-serif; font-variant-ligatures: normal; min-height: 672.141px; orphans: 2; position: relative; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;relative composer-rendered-message hide-if-empty composer-message-blur&quot; data-message-id=&quot;7abf39c7-efd3-405c-bcb5-2caf034204e5&quot; data-message-index=&quot;35&quot; data-message-kind=&quot;assistant&quot; data-message-role=&quot;ai&quot; id=&quot;bubble-2caf034204e5&quot; style=&quot;opacity: 1; outline: currentcolor; padding: 0px 18px; position: relative; z-index: 99;&quot; tabindex=&quot;0&quot;&gt;&lt;div style=&quot;position: sticky; top: 0px;&quot;&gt;&lt;div style=&quot;font-size: 13px; padding: 0px 2px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in; font-size: 1.15em;&quot;&gt;Step&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in; font-size: 1.15em;&quot;&gt;&amp;nbsp;1: Navigate to the monorepo&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding: 0px 2px;&quot;&gt;&lt;span style=&quot;font-size: 14.95px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding: 0px 2px;&quot;&gt;&lt;span style=&quot;font-size: 14.95px;&quot;&gt;git clone&amp;nbsp;&lt;/span&gt;https://github.com/ROCm/rocm-libraries.git&lt;/div&gt;&lt;div style=&quot;padding: 0px 2px;&quot;&gt;&amp;gt;cd rocm-libraries&lt;/div&gt;&lt;div style=&quot;padding: 0px 2px;&quot;&gt;&lt;span class=&quot;anysphere-markdown-container-root&quot; color=&quot;rgba(228, 228, 228, 0.92)&quot; style=&quot;font-size: 1em; line-height: 1.5; min-height: 22.2px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in; font-size: 1.15em;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding: 0px 2px;&quot;&gt;&lt;span class=&quot;anysphere-markdown-container-root&quot; color=&quot;rgba(228, 228, 228, 0.92)&quot; style=&quot;font-size: 1em; line-height: 1.5; min-height: 22.2px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in; font-size: 1.15em;&quot;&gt;Step 2: Create&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in; font-size: 1.15em;&quot;&gt;&amp;nbsp;a&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in; font-size: 1.15em;&quot;&gt;&amp;nbsp;buil&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in; font-size: 1.15em;&quot;&gt;d directory&lt;/span&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```bash
mkdir -p build_miopen_hipdnn
cd build_miopen_hipdnn
```&quot; data-section-index=&quot;6&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-6&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container markdown-block-code&quot; style=&quot;animation: 0.25s fade-in; border-radius: 6px; overflow: hidden;&quot;&gt;&lt;div style=&quot;animation: auto; height: 49.6615px; width: 538.008px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock display-codeblock&quot; style=&quot;animation: auto; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.894118 0.894118 0.894118 / 0.073725) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: auto; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;--vscode-sidebar-background: #181818; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div data-keybinding-context=&quot;228&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;animation: auto; box-sizing: border-box; position: relative; width: 524.349px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs-dark&quot; data-uri=&quot;display-codeblock://0otavxjuhx&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto; height: 48px; overflow-wrap: normal; overflow: visible; position: relative; width: 524px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 48px; overflow: hidden; position: relative; width: 524px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 48px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 48px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 48px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto; height: 48px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 524px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 48px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 524px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;mkdir&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-p&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;build_miopen_hipdnn&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;build_miopen_hipdnn&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: rgba(228, 228, 228, 0.92); border-color: rgba(228, 228, 228, 0.92); box-sizing: border-box; color: rgba(27, 27, 27, 0.92); cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 1.66667px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; transition: opacity 0.8s linear; width: 524px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 524px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 48px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 48px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 48px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 48px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;115&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;115&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.03); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

### **Step 3: Configure with CMake using Ninja**&quot; data-section-index=&quot;7&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-7&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;h3 style=&quot;animation: 0.25s fade-in; font-size: 1.15em; line-height: 1.25; margin-bottom: 8px; margin-top: 18px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Step&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;3: Configure with&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;CMake using&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;Ninja&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```bash
cmake -GNinja -B . -S .. \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=/opt/rocm \
  -DCMAKE_PREFIX_PATH=/opt/rocm \
  -DROCM_LIBS_ENABLE_COMPONENTS=&amp;quot;miopen;hipdnn&amp;quot;
```&quot; data-section-index=&quot;8&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-8&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container markdown-block-code&quot; style=&quot;animation: 0.25s fade-in; border-radius: 6px; overflow: hidden;&quot;&gt;&lt;div style=&quot;animation: auto; height: 103.665px; width: 538.008px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock display-codeblock&quot; style=&quot;animation: auto; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.894118 0.894118 0.894118 / 0.073725) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: auto; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;--vscode-sidebar-background: #181818; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div data-keybinding-context=&quot;229&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;animation: auto; box-sizing: border-box; position: relative; width: 524.349px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs-dark&quot; data-uri=&quot;display-codeblock://2v2vo1ck2i&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto; height: 102px; overflow-wrap: normal; overflow: visible; position: relative; width: 524px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 102px; overflow: hidden; position: relative; width: 524px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 102px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 102px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 102px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto; height: 102px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 524px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 102px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 524px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;cmake&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-GNinja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-B&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-S&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto; color: #d6d6dd;&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-DCMAKE_BUILD_TYPE=Release&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto; color: #d6d6dd;&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-DCMAKE_INSTALL_PREFIX=/opt/rocm&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto; color: #d6d6dd;&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-DCMAKE_PREFIX_PATH=/opt/rocm&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto; color: #d6d6dd;&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-DROCM_LIBS_ENABLE_COMPONENTS=&quot;miopen;hipdnn&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: rgba(228, 228, 228, 0.92); border-color: rgba(228, 228, 228, 0.92); box-sizing: border-box; color: rgba(27, 27, 27, 0.92); cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 1.66667px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; transition: opacity 0.8s linear; width: 524px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 524px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 102px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 102px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 102px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 102px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;244&quot; style=&quot;animation: auto !important; height: 102px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;244&quot; style=&quot;animation: auto !important; height: 102px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.03); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
**What this does:**
- `-GNinja` - Use Ninja build system (faster than Make)
- `-DCMAKE_BUILD_TYPE=Release` - Optimized build
- `-DCMAKE_INSTALL_PREFIX=/opt/rocm` - Install location
- `-DCMAKE_PREFIX_PATH=/opt/rocm` - Where to find ROCm dependencies
- `-DROCM_LIBS_ENABLE_COMPONENTS=&amp;quot;miopen;hipdnn&amp;quot;` - Build only these two projects + their dependencies&quot; data-section-index=&quot;10&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-10&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;What&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;this does:&lt;/span&gt;&lt;/span&gt;&lt;ul style=&quot;animation: 0.25s fade-in; margin: 0px 0px 0px 16px; padding: 0px;&quot;&gt;&lt;li data-indent=&quot;0&quot; style=&quot;animation: 0.25s fade-in; list-style-type: disc; margin-bottom: 2px; margin-left: 0px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.199297 0.199297 0.199297 / 0.393725); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;G&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Ninja&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;- Use&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;Ninja build system&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;(faster than Make)&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;animation: 0.25s fade-in; margin: 0px 0px 0px 16px; padding: 0px;&quot;&gt;&lt;li data-indent=&quot;0&quot; style=&quot;animation: 0.25s fade-in; list-style-type: disc; margin-bottom: 2px; margin-left: 0px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.199297 0.199297 0.199297 / 0.393725); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;DCMAKE_BUILD_TYPE=&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Release&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;- Optimized build&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;animation: 0.25s fade-in; margin: 0px 0px 0px 16px; padding: 0px;&quot;&gt;&lt;li data-indent=&quot;0&quot; style=&quot;animation: 0.25s fade-in; list-style-type: disc; margin-bottom: 2px; margin-left: 0px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.199297 0.199297 0.199297 / 0.393725); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;-DC&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;MAKE_INSTALL_PREFIX=/&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;opt/rocm&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;- Install location&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;animation: 0.25s fade-in; margin: 0px 0px 0px 16px; padding: 0px;&quot;&gt;&lt;li data-indent=&quot;0&quot; style=&quot;animation: 0.25s fade-in; list-style-type: disc; margin-bottom: 2px; margin-left: 0px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.199297 0.199297 0.199297 / 0.393725); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;-DCMAKE_&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;PREFIX_PATH=/opt/rocm&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;- Where&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;to find RO&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Cm dependencies&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;animation: 0.25s fade-in; margin: 0px 0px 0px 16px; padding: 0px;&quot;&gt;&lt;li data-indent=&quot;0&quot; style=&quot;animation: 0.25s fade-in; list-style-type: disc; margin-bottom: 2px; margin-left: 0px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.199297 0.199297 0.199297 / 0.393725); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;-DROCM_&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;LIBS_ENABLE_COMPONENTS&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;=&quot;miopen;hipdnn&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;- Buil&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;d only&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;these&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;two projects&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;+ their dependencies&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

### **Step 4: Build both projects**&quot; data-section-index=&quot;11&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-11&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;h3 style=&quot;animation: 0.25s fade-in; font-size: 1.15em; line-height: 1.25; margin-bottom: 8px; margin-top: 18px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Step 4&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;: Build both&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;projects&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```bash
ninja -j$(nproc)
```&quot; data-section-index=&quot;12&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-12&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container markdown-block-code&quot; style=&quot;animation: 0.25s fade-in; border-radius: 6px; overflow: hidden;&quot;&gt;&lt;div style=&quot;animation: auto; height: 31.6667px; width: 538.008px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock display-codeblock&quot; style=&quot;animation: auto; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.894118 0.894118 0.894118 / 0.073725) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: auto; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;--vscode-sidebar-background: #181818; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div data-keybinding-context=&quot;230&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;animation: auto; box-sizing: border-box; position: relative; width: 524.349px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs-dark&quot; data-uri=&quot;display-codeblock://t9jp1g7hc5&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto; height: 30px; overflow-wrap: normal; overflow: visible; position: relative; width: 524px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 30px; overflow: hidden; position: relative; width: 524px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 30px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 30px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 30px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto; height: 30px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 524px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 30px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 524px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;ninja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-j$(&lt;/span&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;nproc&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: rgba(228, 228, 228, 0.92); border-color: rgba(228, 228, 228, 0.92); box-sizing: border-box; color: rgba(27, 27, 27, 0.92); cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 1.66667px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; transition: opacity 0.8s linear; width: 524px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 524px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 30px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 30px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 30px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 30px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;72&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;72&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.03); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
Or if you want to limit parallel jobs (e.g., for memory constraints):&quot; data-section-index=&quot;14&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-14&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Or&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;if you want to limit&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;parallel&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;jobs&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;(e.g., for memory&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;constraints):&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```bash
ninja -j8
```&quot; data-section-index=&quot;15&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-15&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container markdown-block-code&quot; style=&quot;animation: 0.25s fade-in; border-radius: 6px; overflow: hidden;&quot;&gt;&lt;div style=&quot;animation: auto; height: 31.6667px; width: 538.008px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock display-codeblock&quot; style=&quot;animation: auto; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.894118 0.894118 0.894118 / 0.073725) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: auto; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;--vscode-sidebar-background: #181818; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div data-keybinding-context=&quot;231&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;animation: auto; box-sizing: border-box; position: relative; width: 524.349px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs-dark&quot; data-uri=&quot;display-codeblock://a3ng0ge9d6&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto; height: 30px; overflow-wrap: normal; overflow: visible; position: relative; width: 524px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 30px; overflow: hidden; position: relative; width: 524px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 30px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 30px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 30px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto; height: 30px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 524px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 30px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 524px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;ninja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-j8&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: rgba(228, 228, 228, 0.92); border-color: rgba(228, 228, 228, 0.92); box-sizing: border-box; color: rgba(27, 27, 27, 0.92); cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 1.66667px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; transition: opacity 0.8s linear; width: 524px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 524px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 30px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 30px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 30px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 30px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;72&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;72&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.03); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

### **Step 5: Run tests (optional)**&quot; data-section-index=&quot;16&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-16&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;h3 style=&quot;animation: 0.25s fade-in; font-size: 1.15em; line-height: 1.25; margin-bottom: 8px; margin-top: 18px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Step 5&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;: Run&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;tests&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;(optional)&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```bash
# Test everything
ninja check

# Or test specific components
ninja test
```&quot; data-section-index=&quot;17&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-17&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container markdown-block-code&quot; style=&quot;animation: 0.25s fade-in; border-radius: 6px; overflow: hidden;&quot;&gt;&lt;div style=&quot;animation: auto; height: 103.665px; width: 538.008px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock display-codeblock&quot; style=&quot;animation: auto; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.894118 0.894118 0.894118 / 0.073725) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: auto; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;--vscode-sidebar-background: #181818; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div data-keybinding-context=&quot;232&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;animation: auto; box-sizing: border-box; position: relative; width: 524.349px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs-dark&quot; data-uri=&quot;display-codeblock://hf8rmlnczt&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto; height: 102px; overflow-wrap: normal; overflow: visible; position: relative; width: 524px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 102px; overflow: hidden; position: relative; width: 524px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 102px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 102px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 102px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto; height: 102px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 524px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 102px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 524px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk17 mtki&quot; color=&quot;rgba(228, 228, 228, 0.37)&quot; style=&quot;animation: auto; font-style: italic;&quot;&gt;#&amp;nbsp;Test&amp;nbsp;everything&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;ninja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;check&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk17 mtki&quot; color=&quot;rgba(228, 228, 228, 0.37)&quot; style=&quot;animation: auto; font-style: italic;&quot;&gt;#&amp;nbsp;Or&amp;nbsp;test&amp;nbsp;specific&amp;nbsp;components&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;ninja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;test&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: rgba(228, 228, 228, 0.92); border-color: rgba(228, 228, 228, 0.92); box-sizing: border-box; color: rgba(27, 27, 27, 0.92); cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 1.66667px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; transition: opacity 0.8s linear; width: 524px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 524px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 102px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 102px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 102px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 102px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;244&quot; style=&quot;animation: auto !important; height: 102px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;244&quot; style=&quot;animation: auto !important; height: 102px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.03); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

### **Step 6: Install (optional)**&quot; data-section-index=&quot;18&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-18&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;h3 style=&quot;animation: 0.25s fade-in; font-size: 1.15em; line-height: 1.25; margin-bottom: 8px; margin-top: 18px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Step 6&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;: Install&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;(optional)&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```bash
sudo ninja install
```&quot; data-section-index=&quot;19&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-19&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container markdown-block-code&quot; style=&quot;animation: 0.25s fade-in; border-radius: 6px; overflow: hidden;&quot;&gt;&lt;div style=&quot;animation: auto; height: 31.6667px; width: 538.008px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock display-codeblock&quot; style=&quot;animation: auto; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.894118 0.894118 0.894118 / 0.073725) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: auto; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;--vscode-sidebar-background: #181818; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div data-keybinding-context=&quot;233&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;animation: auto; box-sizing: border-box; position: relative; width: 524.349px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs-dark&quot; data-uri=&quot;display-codeblock://8gm46vx9gt&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto; height: 30px; overflow-wrap: normal; overflow: visible; position: relative; width: 524px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 30px; overflow: hidden; position: relative; width: 524px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 30px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 30px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 30px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto; height: 30px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 524px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 30px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 524px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;ninja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;install&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: rgba(228, 228, 228, 0.92); border-color: rgba(228, 228, 228, 0.92); box-sizing: border-box; color: rgba(27, 27, 27, 0.92); cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 1.66667px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; transition: opacity 0.8s linear; width: 524px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 524px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 30px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 30px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 30px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 30px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;72&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;72&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.03); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

---&quot; data-section-index=&quot;20&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-20&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;hr style=&quot;animation: 0.25s fade-in; background-color: #88c0d0; border: medium; height: 1px; margin: 1em 0px;&quot; /&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## **Alternative: Build with specific options**&quot; data-section-index=&quot;21&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-21&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Alternative&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;: Build with&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;specific&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;options&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
If you need more control, you can add these flags:&quot; data-section-index=&quot;23&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-23&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;If you nee&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;d more&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;control, you can ad&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;d these&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;flags&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```bash
cmake -GNinja -B . -S .. \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=/opt/rocm \
  -DCMAKE_PREFIX_PATH=/opt/rocm \
  -DROCM_LIBS_ENABLE_COMPONENTS=&amp;quot;miopen;hipdnn&amp;quot; \
  -DBUILD_DEV=ON \
  -DCMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc \
  -DMIOPEN_BACKEND=HIP
```&quot; data-section-index=&quot;24&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-24&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container markdown-block-code&quot; style=&quot;animation: 0.25s fade-in; border-radius: 6px; overflow: hidden;&quot;&gt;&lt;div style=&quot;animation: auto; height: 157.663px; width: 538.008px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock display-codeblock&quot; style=&quot;animation: auto; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.894118 0.894118 0.894118 / 0.073725) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: auto; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;--vscode-sidebar-background: #181818; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div data-keybinding-context=&quot;234&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;animation: auto; box-sizing: border-box; position: relative; width: 524.349px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs-dark&quot; data-uri=&quot;display-codeblock://ysxevug53a&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto; height: 156px; overflow-wrap: normal; overflow: visible; position: relative; width: 524px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 156px; overflow: hidden; position: relative; width: 524px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 156px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 156px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 156px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto; height: 156px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 524px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 156px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 524px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;cmake&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-GNinja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-B&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-S&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto; color: #d6d6dd;&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-DCMAKE_BUILD_TYPE=Release&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto; color: #d6d6dd;&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-DCMAKE_INSTALL_PREFIX=/opt/rocm&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto; color: #d6d6dd;&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-DCMAKE_PREFIX_PATH=/opt/rocm&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto; color: #d6d6dd;&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-DROCM_LIBS_ENABLE_COMPONENTS=&quot;miopen;hipdnn&quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto; color: #d6d6dd;&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-DBUILD_DEV=ON&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto; color: #d6d6dd;&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-DCMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto; color: #d6d6dd;&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-DMIOPEN_BACKEND=HIP&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: rgba(228, 228, 228, 0.92); border-color: rgba(228, 228, 228, 0.92); box-sizing: border-box; color: rgba(27, 27, 27, 0.92); cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 1.66667px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; transition: opacity 0.8s linear; width: 524px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 524px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 156px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 156px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 156px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 156px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;374&quot; style=&quot;animation: auto !important; height: 156px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;374&quot; style=&quot;animation: auto !important; height: 156px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.03); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

---&quot; data-section-index=&quot;25&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-25&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;hr style=&quot;animation: 0.25s fade-in; background-color: #88c0d0; border: medium; height: 1px; margin: 1em 0px;&quot; /&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## **Useful Ninja Commands**&quot; data-section-index=&quot;26&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-26&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Useful&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;Ninja Commands&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```bash
# Build only MIOpen
ninja miopen

# Build only hipDNN
ninja hipdnn

# Clean build
ninja clean

# Verbose output (see actual commands)
ninja -v

# Dry run (show what would be built)
ninja -n

# Build specific target
ninja MIOpenDriver
```&quot; data-section-index=&quot;27&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-27&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container markdown-block-code&quot; style=&quot;animation: 0.25s fade-in; border-radius: 6px; overflow: hidden;&quot;&gt;&lt;div style=&quot;animation: auto; height: 319.661px; width: 538.008px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock display-codeblock&quot; style=&quot;animation: auto; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.894118 0.894118 0.894118 / 0.073725) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: auto; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;--vscode-sidebar-background: #181818; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div data-keybinding-context=&quot;235&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;animation: auto; box-sizing: border-box; position: relative; width: 524.349px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs-dark&quot; data-uri=&quot;display-codeblock://0uuuz22ava&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto; height: 318px; overflow-wrap: normal; overflow: visible; position: relative; width: 524px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 318px; overflow: hidden; position: relative; width: 524px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 318px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 318px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 318px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 150px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 168px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 186px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 204px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 222px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 240px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 258px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 276px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 294px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto; height: 318px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 524px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 150px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 168px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 186px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 204px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 222px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 240px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 258px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 276px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 294px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 318px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 524px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk17 mtki&quot; color=&quot;rgba(228, 228, 228, 0.37)&quot; style=&quot;animation: auto; font-style: italic;&quot;&gt;#&amp;nbsp;Build&amp;nbsp;only&amp;nbsp;MIOpen&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;ninja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;miopen&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk17 mtki&quot; color=&quot;rgba(228, 228, 228, 0.37)&quot; style=&quot;animation: auto; font-style: italic;&quot;&gt;#&amp;nbsp;Build&amp;nbsp;only&amp;nbsp;hipDNN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;ninja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;hipdnn&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk17 mtki&quot; color=&quot;rgba(228, 228, 228, 0.37)&quot; style=&quot;animation: auto; font-style: italic;&quot;&gt;#&amp;nbsp;Clean&amp;nbsp;build&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;ninja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;clean&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 150px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 168px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk17 mtki&quot; color=&quot;rgba(228, 228, 228, 0.37)&quot; style=&quot;animation: auto; font-style: italic;&quot;&gt;#&amp;nbsp;Verbose&amp;nbsp;output&amp;nbsp;(see&amp;nbsp;actual&amp;nbsp;commands)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 186px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;ninja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-v&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 204px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 222px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk17 mtki&quot; color=&quot;rgba(228, 228, 228, 0.37)&quot; style=&quot;animation: auto; font-style: italic;&quot;&gt;#&amp;nbsp;Dry&amp;nbsp;run&amp;nbsp;(show&amp;nbsp;what&amp;nbsp;would&amp;nbsp;be&amp;nbsp;built)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 240px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;ninja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-n&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 258px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 276px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk17 mtki&quot; color=&quot;rgba(228, 228, 228, 0.37)&quot; style=&quot;animation: auto; font-style: italic;&quot;&gt;#&amp;nbsp;Build&amp;nbsp;specific&amp;nbsp;target&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 294px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;ninja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;MIOpenDriver&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: rgba(228, 228, 228, 0.92); border-color: rgba(228, 228, 228, 0.92); box-sizing: border-box; color: rgba(27, 27, 27, 0.92); cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 1.66667px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; transition: opacity 0.8s linear; width: 524px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 524px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 318px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 318px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 318px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 318px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;763&quot; style=&quot;animation: auto !important; height: 318px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;763&quot; style=&quot;animation: auto !important; height: 318px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.03); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

---&quot; data-section-index=&quot;28&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-28&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;hr style=&quot;animation: 0.25s fade-in; background-color: #88c0d0; border: medium; height: 1px; margin: 1em 0px;&quot; /&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## **Expected Build Time**&quot; data-section-index=&quot;29&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-29&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Expecte&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;d Buil&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;d Time&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

- **Configuration (CMake)**: ~30 seconds to 2 minutes
- **MIOpen build**: ~20-40 minutes (first time)
- **hipDNN build**: ~5-10 minutes
- **Total**: ~30-50 minutes on MI250X system&quot; data-section-index=&quot;30&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-30&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;ul style=&quot;animation: 0.25s fade-in; margin: 0px 0px 0px 16px; padding: 0px;&quot;&gt;&lt;li data-indent=&quot;0&quot; style=&quot;animation: 0.25s fade-in; list-style-type: disc; margin-bottom: 2px; margin-left: 0px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Configuration&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;(CMake)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;~30&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;seconds to&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;2 minutes&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;animation: 0.25s fade-in; margin: 0px 0px 0px 16px; padding: 0px;&quot;&gt;&lt;li data-indent=&quot;0&quot; style=&quot;animation: 0.25s fade-in; list-style-type: disc; margin-bottom: 2px; margin-left: 0px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;M&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;IOpen buil&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;d&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;: ~20&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;-4&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;0 minutes&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;(first&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;time&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;)&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;animation: 0.25s fade-in; margin: 0px 0px 0px 16px; padding: 0px;&quot;&gt;&lt;li data-indent=&quot;0&quot; style=&quot;animation: 0.25s fade-in; list-style-type: disc; margin-bottom: 2px; margin-left: 0px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;hipDNN buil&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;d&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;: ~&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;5-10 minutes&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;animation: 0.25s fade-in; margin: 0px 0px 0px 16px; padding: 0px;&quot;&gt;&lt;li data-indent=&quot;0&quot; style=&quot;animation: 0.25s fade-in; list-style-type: disc; margin-bottom: 2px; margin-left: 0px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Total&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;~3&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;0-5&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;0 minutes on&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;MI&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;250X system&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

---&quot; data-section-index=&quot;31&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-31&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;hr style=&quot;animation: 0.25s fade-in; background-color: #88c0d0; border: medium; height: 1px; margin: 1em 0px;&quot; /&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## **What Gets Built**&quot; data-section-index=&quot;32&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-32&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;What&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;Gets&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;Built&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
After successful build, you&#39;ll have:&quot; data-section-index=&quot;34&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-34&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;After&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;successful&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;build, you&#39;ll have&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```
build_miopen_hipdnn/
├── projects/
│   ├── miopen/
│   │   ├── lib/libMIOpen.so
│   │   ├── bin/MIOpenDriver
│   │   └── test/
│   └── hipdnn/
│       ├── backend/src/libhipdnn.so
│       ├── frontend/
│       ├── plugins/
│       └── tests/
```&quot; data-section-index=&quot;35&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-35&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container markdown-block-code&quot; style=&quot;animation: 0.25s fade-in; border-radius: 6px; overflow: hidden;&quot;&gt;&lt;div style=&quot;animation: auto; height: 211.667px; width: 538.008px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock display-codeblock&quot; style=&quot;animation: auto; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.894118 0.894118 0.894118 / 0.073725) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: auto; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; data-mode-id=&quot;worktree-plaintext&quot; style=&quot;--vscode-sidebar-background: #181818; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div data-keybinding-context=&quot;236&quot; data-mode-id=&quot;plaintext&quot; style=&quot;animation: auto; box-sizing: border-box; position: relative; width: 524.349px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs-dark&quot; data-uri=&quot;display-codeblock://lnv2adudt9&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto; height: 210px; overflow-wrap: normal; overflow: visible; position: relative; width: 524px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 210px; overflow: hidden; position: relative; width: 524px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 210px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 210px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 210px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 150px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 168px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 186px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto; height: 210px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 524px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 150px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 168px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 186px; width: 523.997px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 210px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 524px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;build_miopen_hipdnn/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;├──&amp;nbsp;projects/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;│&amp;nbsp;&amp;nbsp;&amp;nbsp;├──&amp;nbsp;miopen/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;│&amp;nbsp;&amp;nbsp;&amp;nbsp;│&amp;nbsp;&amp;nbsp;&amp;nbsp;├──&amp;nbsp;lib/libMIOpen.so&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;│&amp;nbsp;&amp;nbsp;&amp;nbsp;│&amp;nbsp;&amp;nbsp;&amp;nbsp;├──&amp;nbsp;bin/MIOpenDriver&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;│&amp;nbsp;&amp;nbsp;&amp;nbsp;│&amp;nbsp;&amp;nbsp;&amp;nbsp;└──&amp;nbsp;test/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;│&amp;nbsp;&amp;nbsp;&amp;nbsp;└──&amp;nbsp;hipdnn/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;│&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;├──&amp;nbsp;backend/src/libhipdnn.so&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 150px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;│&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;├──&amp;nbsp;frontend/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 168px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;│&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;├──&amp;nbsp;plugins/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 186px; width: 523.997px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;│&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;└──&amp;nbsp;tests/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: rgba(228, 228, 228, 0.92); border-color: rgba(228, 228, 228, 0.92); box-sizing: border-box; color: rgba(27, 27, 27, 0.92); cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 1.66667px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; transition: opacity 0.8s linear; width: 524px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 524px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 210px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 210px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 524px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 210px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 210px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;504&quot; style=&quot;animation: auto !important; height: 210px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;504&quot; style=&quot;animation: auto !important; height: 210px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.03); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

---&quot; data-section-index=&quot;36&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-36&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;hr style=&quot;animation: 0.25s fade-in; background-color: #88c0d0; border: medium; height: 1px; margin: 1em 0px;&quot; /&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## **If You Encounter Issues**&quot; data-section-index=&quot;37&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-37&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;If&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;You Encounter Issues&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

1. **Missing dependencies error:**
   ```bash
   # The superbuild should handle this, but if needed:
   cmake -DROCM_LIBS_ENABLE_COMPONENTS=&amp;quot;rocblas;hipblas;composablekernel;miopen;hipdnn&amp;quot; ...
   ```&quot; data-section-index=&quot;38&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-38&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;ol style=&quot;animation: 0.25s fade-in; margin: 0px 0px 0px 16px; padding: 0px;&quot;&gt;&lt;li data-indent=&quot;0&quot; style=&quot;animation: 0.25s fade-in; list-style-type: decimal; margin-bottom: 2px; margin-left: 0px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;&quot; value=&quot;1&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Missing dependencies error&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;div class=&quot;markdown-code-outer-container markdown-block-code&quot; style=&quot;animation: 0.25s fade-in; border-radius: 6px; overflow: hidden;&quot;&gt;&lt;div style=&quot;animation: auto; height: 59.6615px; width: 522.012px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock display-codeblock&quot; style=&quot;animation: auto; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.894118 0.894118 0.894118 / 0.073725) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: auto; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;--vscode-sidebar-background: #181818; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div data-keybinding-context=&quot;237&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;animation: auto; box-sizing: border-box; position: relative; width: 508.353px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs-dark&quot; data-uri=&quot;display-codeblock://dhfm2hmtso&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto; height: 58px; overflow-wrap: normal; overflow: visible; position: relative; width: 508px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 58px; overflow: hidden; position: relative; width: 508px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 21.668px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 58px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 58px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 58px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto; height: 58px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 508px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 685px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 685px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 685px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 58px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 685px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 685px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk17 mtki&quot; color=&quot;rgba(228, 228, 228, 0.37)&quot; style=&quot;animation: auto; font-style: italic;&quot;&gt;#&amp;nbsp;The&amp;nbsp;superbuild&amp;nbsp;should&amp;nbsp;handle&amp;nbsp;this,&amp;nbsp;but&amp;nbsp;if&amp;nbsp;needed&lt;/span&gt;&lt;span class=&quot;mtk17 mtki&quot; color=&quot;rgba(228, 228, 228, 0.37)&quot; style=&quot;animation: auto; font-style: italic;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 685px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;cmake&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-DROCM_LIBS_ENABLE_COMPONENTS=&quot;rocblas;hipblas;com&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;posablekernel;miopen;hipdnn&quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: rgba(228, 228, 228, 0.92); border-color: rgba(228, 228, 228, 0.92); box-sizing: border-box; color: rgba(27, 27, 27, 0.92); cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 1.66667px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; transition: opacity 0.8s linear; width: 508px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 376px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 58px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 58px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 508px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 508px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 58px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 58px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;139&quot; style=&quot;animation: auto !important; height: 58px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;139&quot; style=&quot;animation: auto !important; height: 58px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.03); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

2. **Out of memory during build:**
   ```bash
   ninja -j4  # Reduce parallel jobs
   ```&quot; data-section-index=&quot;39&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-39&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;ol style=&quot;animation: 0.25s fade-in; margin: 0px 0px 0px 16px; padding: 0px;&quot;&gt;&lt;li data-indent=&quot;0&quot; style=&quot;animation: 0.25s fade-in; list-style-type: decimal; margin-bottom: 2px; margin-left: 0px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;&quot; value=&quot;2&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Out&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;of memory during&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;build:&lt;/span&gt;&lt;/span&gt;&lt;div class=&quot;markdown-code-outer-container markdown-block-code&quot; style=&quot;animation: 0.25s fade-in; border-radius: 6px; overflow: hidden;&quot;&gt;&lt;div style=&quot;animation: auto; height: 31.6667px; width: 522.012px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock display-codeblock&quot; style=&quot;animation: auto; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.894118 0.894118 0.894118 / 0.073725) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: auto; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;--vscode-sidebar-background: #181818; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div data-keybinding-context=&quot;238&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;animation: auto; box-sizing: border-box; position: relative; width: 508.353px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs-dark&quot; data-uri=&quot;display-codeblock://narowx8qvb&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto; height: 30px; overflow-wrap: normal; overflow: visible; position: relative; width: 508px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 30px; overflow: hidden; position: relative; width: 508px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 30px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 30px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 30px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto; height: 30px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 508px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 508px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 507.995px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 30px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 508px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 507.995px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;ninja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-j4&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk17 mtki&quot; color=&quot;rgba(228, 228, 228, 0.37)&quot; style=&quot;animation: auto; font-style: italic;&quot;&gt;#&amp;nbsp;Reduce&amp;nbsp;parallel&amp;nbsp;jobs&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: rgba(228, 228, 228, 0.92); border-color: rgba(228, 228, 228, 0.92); box-sizing: border-box; color: rgba(27, 27, 27, 0.92); cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 1.66667px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; transition: opacity 0.8s linear; width: 508px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 508px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 30px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 30px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 508px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 508px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 30px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 30px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;72&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;72&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.03); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

3. **See what would be built:**
   ```bash
   ninja -n | grep -E &amp;quot;(miopen|hipdnn)&amp;quot;
   ```&quot; data-section-index=&quot;40&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-40&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;ol style=&quot;animation: 0.25s fade-in; margin: 0px 0px 0px 16px; padding: 0px;&quot;&gt;&lt;li data-indent=&quot;0&quot; style=&quot;animation: 0.25s fade-in; list-style-type: decimal; margin-bottom: 2px; margin-left: 0px; margin-top: 2px; padding-bottom: 2px; padding-top: 2px;&quot; value=&quot;3&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;See&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;what&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;woul&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;d be built:&lt;/span&gt;&lt;/span&gt;&lt;div class=&quot;markdown-code-outer-container markdown-block-code&quot; style=&quot;animation: 0.25s fade-in; border-radius: 6px; overflow: hidden;&quot;&gt;&lt;div style=&quot;animation: auto; height: 31.6667px; width: 522.012px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock display-codeblock&quot; style=&quot;animation: auto; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.894118 0.894118 0.894118 / 0.073725) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: auto; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;--vscode-sidebar-background: #181818; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div data-keybinding-context=&quot;239&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;animation: auto; box-sizing: border-box; position: relative; width: 508.353px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs-dark&quot; data-uri=&quot;display-codeblock://0v5jh3pe3h&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto; height: 30px; overflow-wrap: normal; overflow: visible; position: relative; width: 508px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 30px; overflow: hidden; position: relative; width: 508px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 282px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 21.668px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 30px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 30px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 30px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto; height: 30px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 508px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 508px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 507.995px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 30px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 508px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 507.995px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;ninja&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-n&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto; color: #d6d6dd;&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9&quot; style=&quot;animation: auto; color: #efb080;&quot;&gt;grep&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;-E&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto; color: #e394dc;&quot;&gt;&quot;(miopen|hipdnn)&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: rgba(228, 228, 228, 0.92); border-color: rgba(228, 228, 228, 0.92); box-sizing: border-box; color: rgba(27, 27, 27, 0.92); cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 282px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 1.66667px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; transition: opacity 0.8s linear; width: 508px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 508px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 30px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.07); contain: strict; height: 30px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 508px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 508px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 30px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 30px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;72&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;72&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(228, 228, 228, 0.03); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

---&quot; data-section-index=&quot;41&quot; id=&quot;markdown-section-7abf39c7-efd3-405c-bcb5-2caf034204e5-41&quot; style=&quot;border-radius: 4px; line-height: 19.5px; margin: 6px 0px; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px;&quot;&gt;&lt;/section&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/8266134919207589693/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2026/01/step-by-step-building-miopen-and-hipdnn.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/8266134919207589693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/8266134919207589693'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2026/01/step-by-step-building-miopen-and-hipdnn.html' title='Step-by-Step: Building MIOpen and hipDNN with Ninja'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-6397416249303201248</id><published>2025-12-31T11:24:00.000-08:00</published><updated>2025-12-31T11:24:16.364-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="aws"/><category scheme="http://www.blogger.com/atom/ns#" term="AWS SAM"/><category scheme="http://www.blogger.com/atom/ns#" term="CICD"/><category scheme="http://www.blogger.com/atom/ns#" term="CloudComputing"/><category scheme="http://www.blogger.com/atom/ns#" term="Deployment"/><category scheme="http://www.blogger.com/atom/ns#" term="DevOps"/><category scheme="http://www.blogger.com/atom/ns#" term="lambda"/><category scheme="http://www.blogger.com/atom/ns#" term="opsworkscm"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="sam"/><category scheme="http://www.blogger.com/atom/ns#" term="sam boroken"/><category scheme="http://www.blogger.com/atom/ns#" term="ServerlessFramework"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><category scheme="http://www.blogger.com/atom/ns#" term="Troubleshooting"/><title type='text'> AWS SAM Troubleshooting - Fixing pip/runtime and AWS CLI Issues</title><content type='html'>&lt;br /&gt;&lt;h2&gt;🔧 AWS SAM Troubleshooting - Fixing pip/runtime and AWS CLI Issues&lt;/h2&gt;

&lt;p&gt;If you&#39;re deploying AWS Lambda functions with SAM (Serverless Application Model), you may have encountered frustrating build errors. This guide explains the two most common issues and how to fix them permanently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This guide uses generic examples (&lt;code&gt;&amp;lt;YOUR_STACK_NAME&amp;gt;&lt;/code&gt;) and is safe to share publicly.&lt;/p&gt;

&lt;h3&gt;🚨 The Two Common Problems&lt;/h3&gt;

&lt;h4&gt;Problem A — &lt;code&gt;sam build&lt;/code&gt; fails with pip/runtime error&lt;/h4&gt;

&lt;p&gt;You may see this error:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Error: PythonPipBuilder:ResolveDependencies - Failed to find a Python runtime containing pip on the PATH.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;What this means:&lt;/strong&gt; SAM is trying to build for a specific Lambda runtime (like &lt;code&gt;python3.11&lt;/code&gt;), but your shell has:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;python&lt;/code&gt; from one location (e.g., conda environment)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;pip&lt;/code&gt; from another location (e.g., &lt;code&gt;~/.local/bin&lt;/code&gt; or &lt;code&gt;/usr/bin&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SAM requires a &lt;strong&gt;matching pair&lt;/strong&gt; - the &lt;code&gt;pip&lt;/code&gt; must belong to the same Python interpreter that matches your Lambda runtime version.&lt;/p&gt;

&lt;h4&gt;Problem B — AWS CLI crashes with botocore conflicts&lt;/h4&gt;

&lt;p&gt;You may see errors like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;KeyError: &#39;opsworkscm&#39;
ModuleNotFoundError: No module named &#39;dateutil&#39;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;What this means:&lt;/strong&gt; Your system AWS CLI (&lt;code&gt;/usr/bin/aws&lt;/code&gt;) is accidentally importing incompatible &lt;code&gt;botocore&lt;/code&gt; or &lt;code&gt;boto3&lt;/code&gt; packages from &lt;code&gt;~/.local/lib/python...&lt;/code&gt;, causing version conflicts.&lt;/p&gt;

&lt;h3&gt;🔍 Quick Diagnosis (5 Commands)&lt;/h3&gt;

&lt;p&gt;Run these from your SAM project directory to diagnose the issue:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# 1. What Python runtime does your template.yaml require?
grep &quot;Runtime: python&quot; template.yaml

# 2. What python are you using?
which python
python -V

# 3. What pip are you using?
which pip
pip -V

# 4. Does pip belong to this python?
python -m pip -V
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;🚩 Red flag:&lt;/strong&gt; If &lt;code&gt;pip -V&lt;/code&gt; and &lt;code&gt;python -m pip -V&lt;/code&gt; show different paths or Python versions, &lt;strong&gt;your PATH is contaminated&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;✅ The Fix: Dedicated Environment + Clean PATH&lt;/h3&gt;

&lt;p&gt;The solution is to create an isolated environment that matches your Lambda runtime and force clean PATH ordering.&lt;/p&gt;

&lt;h4&gt;Step 1: Create an environment matching your Lambda runtime&lt;/h4&gt;

&lt;p&gt;If your &lt;code&gt;template.yaml&lt;/code&gt; specifies &lt;code&gt;Runtime: python3.11&lt;/code&gt;, create a Python 3.11 environment:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Using conda (recommended)
conda create -n aws-sam-py311 python=3.11 pip -y
conda activate aws-sam-py311

# Or using venv
python3.11 -m venv ~/.virtualenvs/aws-sam-py311
source ~/.virtualenvs/aws-sam-py311/bin/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Step 2: Install SAM CLI and AWS CLI inside the environment&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;# Upgrade pip first
python -m pip install --upgrade pip

# Install SAM CLI
python -m pip install aws-sam-cli

# Optional: Install AWS CLI v2 (avoids system aws/botocore conflicts)
# Using conda-forge:
conda install -c conda-forge awscli -y

# Or using pip:
python -m pip install awscli
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Step 3: Disable user-site imports and fix PATH ordering&lt;/h4&gt;

&lt;p&gt;This is the &lt;strong&gt;critical step&lt;/strong&gt; that prevents &lt;code&gt;~/.local&lt;/code&gt; contamination:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Disable user site-packages (~/.local)
export PYTHONNOUSERSITE=1

# Force clean PATH (conda/venv bin first, then system)
export PATH=&quot;$CONDA_PREFIX/bin:/usr/bin:/bin&quot;

# Or for venv:
# export PATH=&quot;$VIRTUAL_ENV/bin:/usr/bin:/bin&quot;

# Clear shell hash table
hash -r
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Step 4: Verify the fix&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;# All should point to your environment
which python
which pip
which sam
which aws

# Verify versions match
python -V      # Should be 3.11.x
pip -V         # Should show python 3.11
sam --version  # Should work without errors
aws --version  # Should work without errors
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Step 5: Build and deploy&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;sam build --cached --parallel
sam deploy --no-confirm-changeset --stack-name &amp;lt;YOUR_STACK_NAME&amp;gt; --region &amp;lt;YOUR_AWS_REGION&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🐳 Alternative: Container Build (Docker)&lt;/h3&gt;

&lt;p&gt;If you have Docker installed, you can avoid all Python toolchain issues by building in a container:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sam build --use-container
sam deploy --no-confirm-changeset --stack-name &amp;lt;YOUR_STACK_NAME&amp;gt; --region &amp;lt;YOUR_AWS_REGION&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;✅ No need to match local Python version&lt;/li&gt;
&lt;li&gt;✅ Builds in environment identical to Lambda&lt;/li&gt;
&lt;li&gt;✅ Most reproducible approach&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;❌ Slower than native builds&lt;/li&gt;
&lt;li&gt;❌ Requires Docker installed and running&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;⚡ Quick Fix for Broken AWS CLI (Emergency)&lt;/h3&gt;

&lt;p&gt;If you need to use system AWS CLI right now and it&#39;s broken:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Force it to ignore user-site packages
PYTHONNOUSERSITE=1 /usr/bin/aws --version
PYTHONNOUSERSITE=1 /usr/bin/aws sts get-caller-identity
PYTHONNOUSERSITE=1 /usr/bin/aws s3 ls
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;But the proper fix is:&lt;/strong&gt; Install AWS CLI inside your dedicated environment (see Step 2 above).&lt;/p&gt;

&lt;h3&gt;🤔 Why Lambda is python3.11 but my machine uses python3.12?&lt;/h3&gt;

&lt;p&gt;This is a common source of confusion. They are &lt;strong&gt;different things&lt;/strong&gt;:&lt;/p&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;8&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse; width: 100%;&quot;&gt;
&lt;tbody&gt;&lt;tr style=&quot;background-color: #f0f0f0;&quot;&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;What It Is&lt;/th&gt;
&lt;th&gt;Where It&#39;s Defined&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Lambda Runtime&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Python version AWS runs in production&lt;/td&gt;
&lt;td&gt;&lt;code&gt;template.yaml&lt;/code&gt; → &lt;code&gt;Runtime: python3.11&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Your Local Python&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Python version for development/training/scripts&lt;/td&gt;
&lt;td&gt;Your system default or conda environment&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&lt;strong&gt;Key point:&lt;/strong&gt; When SAM builds your Lambda functions, it must build dependencies compatible with the &lt;strong&gt;Lambda runtime&lt;/strong&gt;, even if your system default is Python 3.12.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example from template.yaml:&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;AnprDeviceLicenseValidateFunction:
  Type: AWS::Serverless::Function
  Properties:
    CodeUri: anpr_device_license_validate/
    Handler: app.lambda_handler
    Runtime: python3.11          # ← Lambda uses 3.11
    Architectures:
      - x86_64
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So you have three options:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Match local environment to Lambda&lt;/strong&gt; (recommended) - Create python3.11 env for SAM work&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use container build&lt;/strong&gt; - Let Docker handle it with &lt;code&gt;sam build --use-container&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Upgrade Lambda runtime&lt;/strong&gt; - Change &lt;code&gt;template.yaml&lt;/code&gt; to &lt;code&gt;python3.12&lt;/code&gt; (requires testing)&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;📋 Complete Example: Deploy Script&lt;/h3&gt;

&lt;p&gt;Here&#39;s a complete bash script that implements all the fixes:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/env bash
set -euo pipefail

# Activate conda environment (matches Lambda runtime)
source ~/anaconda3/etc/profile.d/conda.sh
conda activate aws-sam-py311

# Critical: Clean PATH and disable user-site
export PYTHONNOUSERSITE=1
export PATH=&quot;$CONDA_PREFIX/bin:/usr/bin:/bin&quot;
hash -r

echo &quot;Environment ready:&quot;
echo &quot;  Python: $(python -V)&quot;
echo &quot;  SAM: $(sam --version | head -1)&quot;
echo &quot;  AWS: $(aws --version)&quot;

# Build and deploy
sam build --cached --parallel
sam deploy --no-confirm-changeset
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🎯 Troubleshooting Checklist&lt;/h3&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;8&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse; width: 100%;&quot;&gt;
&lt;tbody&gt;&lt;tr style=&quot;background-color: #f0f0f0;&quot;&gt;
&lt;th&gt;Issue&lt;/th&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;Fix&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sam build fails&lt;/td&gt;
&lt;td&gt;&lt;code&gt;which pip&lt;/code&gt; vs &lt;code&gt;python -m pip -V&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Create dedicated env, fix PATH&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;aws command crashes&lt;/td&gt;
&lt;td&gt;&lt;code&gt;echo $PYTHONNOUSERSITE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Set &lt;code&gt;PYTHONNOUSERSITE=1&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wrong Python version&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python -V&lt;/code&gt; vs Lambda runtime&lt;/td&gt;
&lt;td&gt;Create env matching Lambda&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multiple pip versions&lt;/td&gt;
&lt;td&gt;&lt;code&gt;which -a pip&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Fix PATH ordering&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Conda conflicts&lt;/td&gt;
&lt;td&gt;&lt;code&gt;conda env list&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Create separate env for SAM&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h3&gt;🔒 Security Best Practices&lt;/h3&gt;

&lt;div style=&quot;background-color: #fff3e0; border-left-color: rgb(255, 152, 0); border-left-style: solid; border-left-width: 4px; border-left: 4px solid #ff9800; margin: 15px 0px; padding: 12px;&quot;&gt;
&lt;p&gt;&lt;strong&gt;⚠️ When sharing code publicly:&lt;/strong&gt;&lt;/p&gt;
&lt;ul style=&quot;margin: 8px 0px;&quot;&gt;
&lt;li&gt;❌ &lt;strong&gt;Never publish template.yaml with secrets&lt;/strong&gt; (API keys, tokens, webhook URLs)&lt;/li&gt;
&lt;li&gt;✅ Use &lt;strong&gt;AWS Secrets Manager&lt;/strong&gt; or &lt;strong&gt;SSM Parameter Store&lt;/strong&gt; for secrets&lt;/li&gt;
&lt;li&gt;✅ Redact from logs:
&lt;ul&gt;
&lt;li&gt;AWS account IDs&lt;/li&gt;
&lt;li&gt;API Gateway URLs&lt;/li&gt;
&lt;li&gt;Stack names and ARNs&lt;/li&gt;
&lt;li&gt;Any access keys/tokens&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;h3&gt;💡 Pro Tips&lt;/h3&gt;

&lt;h4&gt;1. Create a deployment script&lt;/h4&gt;

&lt;p&gt;Instead of remembering all these environment variables, create a &lt;code&gt;deploy.sh&lt;/code&gt; script:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/env bash
set -euo pipefail

# Activate environment
source ~/anaconda3/etc/profile.d/conda.sh
conda activate aws-sam-py311

# Clean environment
export PYTHONNOUSERSITE=1
export PATH=&quot;$CONDA_PREFIX/bin:/usr/bin:/bin&quot;
hash -r

# Build and deploy
sam build --cached --parallel
sam deploy --no-confirm-changeset

echo &quot;✅ Deployment complete!&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Make it executable: &lt;code&gt;chmod +x deploy.sh&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;2. Use SAM build cache for faster builds&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;# First build (slow)
sam build

# Subsequent builds (much faster!)
sam build --cached --parallel
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;3. Test locally before deploying&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;# Invoke function locally
sam local invoke MyFunction --event events/test.json

# Start local API
sam local start-api
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;4. Skip changeset confirmation in CI/CD&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;# Manual deployment - shows changes
sam deploy

# CI/CD deployment - no prompts
sam deploy --no-confirm-changeset
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;📊 Before vs After&lt;/h3&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;8&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse; width: 100%;&quot;&gt;
&lt;tbody&gt;&lt;tr style=&quot;background-color: #ffebee;&quot;&gt;
&lt;th&gt;❌ Before (Broken)&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;code&gt;$ sam build
Error: Failed to find Python runtime containing pip

$ aws --version
KeyError: &#39;opsworkscm&#39;

$ which pip
/home/user/.local/bin/pip  # Wrong location!

$ pip -V
pip 24.0 (python 3.12)     # Wrong version!
&lt;/code&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;8&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse; margin-top: 15px; width: 100%;&quot;&gt;
&lt;tbody&gt;&lt;tr style=&quot;background-color: #e8f5e9;&quot;&gt;
&lt;th&gt;✅ After (Fixed)&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;code&gt;$ conda activate aws-sam-py311
$ export PYTHONNOUSERSITE=1
$ export PATH=&quot;$CONDA_PREFIX/bin:/usr/bin:/bin&quot;

$ sam build
Build Succeeded ✨

$ aws --version
aws-cli/2.32.26 Python/3.11.14

$ which pip
/home/user/anaconda3/envs/aws-sam-py311/bin/pip  # Correct!

$ pip -V
pip 25.3 (python 3.11)     # Matches Lambda runtime!
&lt;/code&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h3&gt;🎓 Summary&lt;/h3&gt;

&lt;p&gt;The root cause of most SAM build failures is &lt;strong&gt;PATH contamination&lt;/strong&gt; - your shell mixes Python versions and pip locations from different sources (&lt;code&gt;~/.local&lt;/code&gt;, &lt;code&gt;/usr/bin&lt;/code&gt;, conda environments).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The complete fix:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;✅ Create dedicated environment matching Lambda runtime (&lt;code&gt;python3.11&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;✅ Install SAM CLI and AWS CLI &lt;strong&gt;inside&lt;/strong&gt; that environment&lt;/li&gt;
&lt;li&gt;✅ Set &lt;code&gt;PYTHONNOUSERSITE=1&lt;/code&gt; to disable user-site packages&lt;/li&gt;
&lt;li&gt;✅ Fix PATH ordering: &lt;code&gt;export PATH=&quot;$CONDA_PREFIX/bin:/usr/bin:/bin&quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;✅ Run &lt;code&gt;hash -r&lt;/code&gt; to clear shell cache&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After this, &lt;code&gt;sam build&lt;/code&gt; and &lt;code&gt;aws&lt;/code&gt; commands will work reliably! 🚀&lt;/p&gt;

&lt;h3&gt;🔗 Additional Resources&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;📚 &lt;a href=&quot;https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html&quot;&gt;AWS SAM Official Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;🐍 &lt;a href=&quot;https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html&quot;&gt;Conda Environment Management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;🐳 &lt;a href=&quot;https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-build.html#build-container-pt&quot;&gt;SAM Container Builds&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;⚙️ &lt;a href=&quot;https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html&quot;&gt;AWS CLI v2 Installation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;em&gt;Tags: AWS, SAM, Lambda, Python, DevOps, Deployment, Troubleshooting, ServerlessFramework, CICD, CloudComputing&lt;/em&gt;&lt;/p&gt;

</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/6397416249303201248/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2025/12/aws-sam-troubleshooting-fixing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/6397416249303201248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/6397416249303201248'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2025/12/aws-sam-troubleshooting-fixing.html' title=' AWS SAM Troubleshooting - Fixing pip/runtime and AWS CLI Issues'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-744853647301894963</id><published>2025-12-30T14:02:12.778-08:00</published><updated>2025-12-30T14:02:48.831-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ANPR"/><category scheme="http://www.blogger.com/atom/ns#" term="Benchmarks"/><category scheme="http://www.blogger.com/atom/ns#" term="ComputerVision"/><category scheme="http://www.blogger.com/atom/ns#" term="DeepLearning"/><category scheme="http://www.blogger.com/atom/ns#" term="GPU"/><category scheme="http://www.blogger.com/atom/ns#" term="MachineLearning"/><category scheme="http://www.blogger.com/atom/ns#" term="metrics"/><category scheme="http://www.blogger.com/atom/ns#" term="Models"/><category scheme="http://www.blogger.com/atom/ns#" term="Optimization"/><category scheme="http://www.blogger.com/atom/ns#" term="Performance"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><title type='text'>MareArts ANPR V14 Models - Complete Performance Guide &amp; Benchmarks</title><content type='html'>&lt;br /&gt;&lt;h2&gt;⚡ MareArts ANPR V14 Models - Performance, Metrics &amp;amp; How to Choose&lt;/h2&gt;

&lt;p&gt;Choosing the right ANPR model is crucial for your application. Too heavy? Slow performance. Too light? Lower accuracy. In this comprehensive guide, we&#39;ll break down all MareArts ANPR V14 models with real benchmarks to help you make the perfect choice.&lt;/p&gt;

&lt;h3&gt;🎯 Two-Stage Pipeline Architecture&lt;/h3&gt;

&lt;p&gt;MareArts ANPR uses a &lt;strong&gt;two-stage pipeline&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Detector&lt;/strong&gt; - Finds license plates in images (Where is the plate?)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OCR&lt;/strong&gt; - Reads text from detected plates (What does it say?)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can mix and match models from each stage to optimize for your specific needs!&lt;/p&gt;

&lt;h3&gt;📊 Detector Models - Find License Plates&lt;/h3&gt;

&lt;h4&gt;Model Sizes Explained&lt;/h4&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Size&lt;/th&gt;
&lt;th&gt;Parameters&lt;/th&gt;
&lt;th&gt;Speed&lt;/th&gt;
&lt;th&gt;Accuracy&lt;/th&gt;
&lt;th&gt;Best For&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;pico&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Smallest&lt;/td&gt;
&lt;td&gt;Fast&lt;/td&gt;
&lt;td&gt;Good (96-98%)&lt;/td&gt;
&lt;td&gt;Mobile, Edge devices&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;micro&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Small&lt;/td&gt;
&lt;td&gt;Very Fast&lt;/td&gt;
&lt;td&gt;Excellent (97-99%)&lt;/td&gt;
&lt;td&gt;🏆 Best overall&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;small&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Fastest&lt;/td&gt;
&lt;td&gt;Excellent (98-99%)&lt;/td&gt;
&lt;td&gt;High-speed applications&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;medium&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Large&lt;/td&gt;
&lt;td&gt;Fast&lt;/td&gt;
&lt;td&gt;Excellent (98-99%)&lt;/td&gt;
&lt;td&gt;Balanced&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;large&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Largest&lt;/td&gt;
&lt;td&gt;Moderate&lt;/td&gt;
&lt;td&gt;Highest (99%+)&lt;/td&gt;
&lt;td&gt;Maximum accuracy&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h4&gt;Resolution Options&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;320p models (320×320)&lt;/strong&gt; - 2× faster, 96-98% detection&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;640p models (640×640)&lt;/strong&gt; - Highest accuracy, 98-99% detection&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Precision Options&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;FP32&lt;/strong&gt; - Fastest on GPU (2× faster than FP16), standard size&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;FP16&lt;/strong&gt; - 50% smaller file size, same accuracy, slower inference&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Complete Detector Performance Table&lt;/h4&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Model Name&lt;/th&gt;
&lt;th&gt;Detection Rate&lt;/th&gt;
&lt;th&gt;Speed (GPU)&lt;/th&gt;
&lt;th&gt;Size&lt;/th&gt;
&lt;th&gt;Recommendation&lt;/th&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color: #e8f5e9;&quot;&gt;
&lt;td&gt;&lt;strong&gt;micro_320p_fp32&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;97.13%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;128 FPS&lt;/strong&gt; (7.8ms)&lt;/td&gt;
&lt;td&gt;83 MB&lt;/td&gt;
&lt;td&gt;🏆 Best overall&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color: #e8f5e9;&quot;&gt;
&lt;td&gt;&lt;strong&gt;micro_320p_fp16&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;97.13%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;56 FPS&lt;/strong&gt; (17.9ms)&lt;/td&gt;
&lt;td&gt;42 MB&lt;/td&gt;
&lt;td&gt;🏆 Best mobile&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;small_320p_fp32&lt;/td&gt;
&lt;td&gt;98.00%&lt;/td&gt;
&lt;td&gt;142 FPS (7.0ms)&lt;/td&gt;
&lt;td&gt;114 MB&lt;/td&gt;
&lt;td&gt;⚡ Fastest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;medium_320p_fp32&lt;/td&gt;
&lt;td&gt;98.06%&lt;/td&gt;
&lt;td&gt;136 FPS (7.4ms)&lt;/td&gt;
&lt;td&gt;153 MB&lt;/td&gt;
&lt;td&gt;High detection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;large_320p_fp32&lt;/td&gt;
&lt;td&gt;98.40%&lt;/td&gt;
&lt;td&gt;131 FPS (7.6ms)&lt;/td&gt;
&lt;td&gt;164 MB&lt;/td&gt;
&lt;td&gt;Strong performance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pico_320p_fp32&lt;/td&gt;
&lt;td&gt;96.02%&lt;/td&gt;
&lt;td&gt;129 FPS (7.8ms)&lt;/td&gt;
&lt;td&gt;75 MB&lt;/td&gt;
&lt;td&gt;📱 Smallest + fast&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pico_640p_fp32&lt;/td&gt;
&lt;td&gt;98.54%&lt;/td&gt;
&lt;td&gt;66 FPS (15.2ms)&lt;/td&gt;
&lt;td&gt;75 MB&lt;/td&gt;
&lt;td&gt;Balanced&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;small_640p_fp32&lt;/td&gt;
&lt;td&gt;99.15%&lt;/td&gt;
&lt;td&gt;70 FPS (14.3ms)&lt;/td&gt;
&lt;td&gt;114 MB&lt;/td&gt;
&lt;td&gt;High detection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;medium_640p_fp32&lt;/td&gt;
&lt;td&gt;99.21%&lt;/td&gt;
&lt;td&gt;66 FPS (15.1ms)&lt;/td&gt;
&lt;td&gt;153 MB&lt;/td&gt;
&lt;td&gt;Very high&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;large_640p_fp32&lt;/td&gt;
&lt;td&gt;99.31%&lt;/td&gt;
&lt;td&gt;60 FPS (16.7ms)&lt;/td&gt;
&lt;td&gt;164 MB&lt;/td&gt;
&lt;td&gt;🎯 Highest accuracy&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&lt;strong&gt;Key Findings:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;320p models&lt;/strong&gt;: 2× faster than 640p (96-98% accuracy)&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;640p models&lt;/strong&gt;: Highest accuracy (98-99%) for difficult cases&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;FP16 models&lt;/strong&gt;: 50% smaller, same accuracy, ~50% slower&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Recommended&lt;/strong&gt;: micro_320p_fp32 (best speed/accuracy balance)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;📖 OCR Models - Read License Plate Text&lt;/h3&gt;

&lt;h4&gt;Two Key Metrics&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Exact Match&lt;/strong&gt; - Entire plate number is 100% correct&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Character Accuracy&lt;/strong&gt; - Percentage of individual characters correct&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; Actual plate: &quot;ABC-1234&quot;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;OCR reads &quot;ABC-1234&quot; → ✅ Exact Match = Yes, Char Accuracy = 100%&lt;/li&gt;
&lt;li&gt;OCR reads &quot;ABC-1235&quot; → ❌ Exact Match = No, Char Accuracy = 87.5% (7/8 correct)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Complete OCR Performance by Region&lt;/h4&gt;

&lt;h5&gt;🌍 Universal (univ) - All Regions&lt;/h5&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Exact Match&lt;/th&gt;
&lt;th&gt;Char Accuracy&lt;/th&gt;
&lt;th&gt;FPS&lt;/th&gt;
&lt;th&gt;Size&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pico_fp32&lt;/td&gt;
&lt;td&gt;97.48%&lt;/td&gt;
&lt;td&gt;98.87%&lt;/td&gt;
&lt;td&gt;264&lt;/td&gt;
&lt;td&gt;20 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;micro_fp32&lt;/td&gt;
&lt;td&gt;97.54%&lt;/td&gt;
&lt;td&gt;98.86%&lt;/td&gt;
&lt;td&gt;260&lt;/td&gt;
&lt;td&gt;71 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;small_fp32&lt;/td&gt;
&lt;td&gt;97.51%&lt;/td&gt;
&lt;td&gt;98.85%&lt;/td&gt;
&lt;td&gt;291&lt;/td&gt;
&lt;td&gt;112 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;medium_fp32&lt;/td&gt;
&lt;td&gt;97.57%&lt;/td&gt;
&lt;td&gt;98.89%&lt;/td&gt;
&lt;td&gt;245&lt;/td&gt;
&lt;td&gt;164 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color: #e8f5e9;&quot;&gt;
&lt;td&gt;&lt;strong&gt;large_fp32&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;97.75%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;98.91%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;253&lt;/td&gt;
&lt;td&gt;179 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h5&gt;🇰🇷 Korean (kr) - Best Overall Accuracy&lt;/h5&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Exact Match&lt;/th&gt;
&lt;th&gt;Char Accuracy&lt;/th&gt;
&lt;th&gt;FPS&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pico_fp32&lt;/td&gt;
&lt;td&gt;98.99%&lt;/td&gt;
&lt;td&gt;99.77%&lt;/td&gt;
&lt;td&gt;272&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;micro_fp32&lt;/td&gt;
&lt;td&gt;99.21%&lt;/td&gt;
&lt;td&gt;99.80%&lt;/td&gt;
&lt;td&gt;250&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;small_fp32&lt;/td&gt;
&lt;td&gt;99.19%&lt;/td&gt;
&lt;td&gt;99.80%&lt;/td&gt;
&lt;td&gt;295&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;medium_fp32&lt;/td&gt;
&lt;td&gt;99.21%&lt;/td&gt;
&lt;td&gt;99.80%&lt;/td&gt;
&lt;td&gt;267&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color: #e8f5e9;&quot;&gt;
&lt;td&gt;&lt;strong&gt;large_fp32&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;99.27%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;99.82%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;265&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h5&gt;🇪🇺 Europe+ (eup) - EU + Additional Countries&lt;/h5&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Exact Match&lt;/th&gt;
&lt;th&gt;Char Accuracy&lt;/th&gt;
&lt;th&gt;FPS&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pico_fp32&lt;/td&gt;
&lt;td&gt;94.98%&lt;/td&gt;
&lt;td&gt;97.39%&lt;/td&gt;
&lt;td&gt;280&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;micro_fp32&lt;/td&gt;
&lt;td&gt;95.07%&lt;/td&gt;
&lt;td&gt;97.46%&lt;/td&gt;
&lt;td&gt;266&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;small_fp32&lt;/td&gt;
&lt;td&gt;94.98%&lt;/td&gt;
&lt;td&gt;97.43%&lt;/td&gt;
&lt;td&gt;304&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;medium_fp32&lt;/td&gt;
&lt;td&gt;95.03%&lt;/td&gt;
&lt;td&gt;97.46%&lt;/td&gt;
&lt;td&gt;278&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color: #e8f5e9;&quot;&gt;
&lt;td&gt;&lt;strong&gt;large_fp32&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;95.32%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;97.54%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;260&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h5&gt;🇺🇸 North America (na) - USA, Canada, Mexico&lt;/h5&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Exact Match&lt;/th&gt;
&lt;th&gt;Char Accuracy&lt;/th&gt;
&lt;th&gt;FPS&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pico_fp32&lt;/td&gt;
&lt;td&gt;71.21%&lt;/td&gt;
&lt;td&gt;88.43%&lt;/td&gt;
&lt;td&gt;268&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;micro_fp32&lt;/td&gt;
&lt;td&gt;71.21%&lt;/td&gt;
&lt;td&gt;87.67%&lt;/td&gt;
&lt;td&gt;269&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color: #e8f5e9;&quot;&gt;
&lt;td&gt;&lt;strong&gt;small_fp32&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;69.70%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;88.27%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;311&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;medium_fp32&lt;/td&gt;
&lt;td&gt;63.64%&lt;/td&gt;
&lt;td&gt;87.24%&lt;/td&gt;
&lt;td&gt;284&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;large_fp32&lt;/td&gt;
&lt;td&gt;69.70%&lt;/td&gt;
&lt;td&gt;86.25%&lt;/td&gt;
&lt;td&gt;271&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h5&gt;🇨🇳 China (cn)&lt;/h5&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Exact Match&lt;/th&gt;
&lt;th&gt;Char Accuracy&lt;/th&gt;
&lt;th&gt;FPS&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pico_fp32&lt;/td&gt;
&lt;td&gt;96.24%&lt;/td&gt;
&lt;td&gt;98.82%&lt;/td&gt;
&lt;td&gt;268&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;micro_fp32&lt;/td&gt;
&lt;td&gt;96.30%&lt;/td&gt;
&lt;td&gt;98.74%&lt;/td&gt;
&lt;td&gt;265&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;small_fp32&lt;/td&gt;
&lt;td&gt;96.36%&lt;/td&gt;
&lt;td&gt;98.88%&lt;/td&gt;
&lt;td&gt;301&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;medium_fp32&lt;/td&gt;
&lt;td&gt;96.36%&lt;/td&gt;
&lt;td&gt;98.89%&lt;/td&gt;
&lt;td&gt;276&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color: #e8f5e9;&quot;&gt;
&lt;td&gt;&lt;strong&gt;large_fp32&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;96.49%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;98.87%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;262&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h4&gt;OCR Model Averages (All Regions)&lt;/h4&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Avg Exact Match&lt;/th&gt;
&lt;th&gt;Avg Char Accuracy&lt;/th&gt;
&lt;th&gt;Avg FPS&lt;/th&gt;
&lt;th&gt;Size&lt;/th&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color: #fff3e0;&quot;&gt;
&lt;td&gt;&lt;strong&gt;small_fp32&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;91.54%&lt;/td&gt;
&lt;td&gt;96.64%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;300 FPS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;112 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pico_fp32&lt;/td&gt;
&lt;td&gt;91.78%&lt;/td&gt;
&lt;td&gt;96.65%&lt;/td&gt;
&lt;td&gt;270 FPS&lt;/td&gt;
&lt;td&gt;20 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;micro_fp32&lt;/td&gt;
&lt;td&gt;91.86%&lt;/td&gt;
&lt;td&gt;96.50%&lt;/td&gt;
&lt;td&gt;262 FPS&lt;/td&gt;
&lt;td&gt;71 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;medium_fp32&lt;/td&gt;
&lt;td&gt;90.36%&lt;/td&gt;
&lt;td&gt;96.45%&lt;/td&gt;
&lt;td&gt;270 FPS&lt;/td&gt;
&lt;td&gt;164 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color: #e8f5e9;&quot;&gt;
&lt;td&gt;&lt;strong&gt;large_fp32&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;91.70%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;96.27%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;262 FPS&lt;/td&gt;
&lt;td&gt;179 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h3&gt;🌍 Regional Vocabulary Support&lt;/h3&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Region&lt;/th&gt;
&lt;th&gt;Code&lt;/th&gt;
&lt;th&gt;Coverage&lt;/th&gt;
&lt;th&gt;Character Sets&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Universal&lt;/td&gt;
&lt;td&gt;&lt;code&gt;univ&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;All regions (default)&lt;/td&gt;
&lt;td&gt;All character sets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Korea&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kr&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;South Korea&lt;/td&gt;
&lt;td&gt;Hangul + Latin + Digits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Europe+&lt;/td&gt;
&lt;td&gt;&lt;code&gt;eup&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;EU + UK, Switzerland, Norway&lt;/td&gt;
&lt;td&gt;Latin + Cyrillic + Special&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;North America&lt;/td&gt;
&lt;td&gt;&lt;code&gt;na&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;USA, Canada, Mexico&lt;/td&gt;
&lt;td&gt;Latin + Digits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;China&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cn&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;China&lt;/td&gt;
&lt;td&gt;Chinese + Latin + Digits&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&lt;strong&gt;Pro Tip:&lt;/strong&gt; Always use specific regions for best accuracy. Only use &lt;code&gt;univ&lt;/code&gt; when the region is unknown!&lt;/p&gt;

&lt;h3&gt;🎯 How to Choose the Right Models&lt;/h3&gt;

&lt;h4&gt;Use Case 1: Parking Management&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Requirements:&lt;/strong&gt; Good accuracy, real-time performance, cost-effective&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# Recommended Configuration
detector = ma_anpr_detector_v14(
    &quot;micro_320p_fp32&quot;,  # 97% detection, 128 FPS
    user, key, sig,
    backend=&quot;cuda&quot;,
    conf_thres=0.25
)

ocr = ma_anpr_ocr_v14(
    &quot;small_fp32&quot;,       # 95%+ exact match, 300 FPS
    &quot;eup&quot;,              # Specific region
    user, key, sig
)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Excellent balance of speed and accuracy. Handles 90%+ of plates easily.&lt;/p&gt;

&lt;h4&gt;Use Case 2: Security Checkpoint (Critical)&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Requirements:&lt;/strong&gt; Maximum accuracy, can&#39;t miss plates&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# Recommended Configuration
detector = ma_anpr_detector_v14(
    &quot;large_640p_fp32&quot;,  # 99.31% detection (highest!)
    user, key, sig,
    backend=&quot;cuda&quot;,
    conf_thres=0.20     # Lower threshold for more detections
)

ocr = ma_anpr_ocr_v14(
    &quot;large_fp32&quot;,       # 95%+ exact match, best accuracy
    &quot;kr&quot;,               # Specific region for your area
    user, key, sig
)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Maximum detection and recognition accuracy. No compromises.&lt;/p&gt;

&lt;h4&gt;Use Case 3: Traffic Monitoring (High Volume)&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Requirements:&lt;/strong&gt; Maximum speed, process many cameras&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# Recommended Configuration
detector = ma_anpr_detector_v14(
    &quot;small_320p_fp32&quot;,  # 98% detection, 142 FPS (fastest!)
    user, key, sig,
    backend=&quot;cuda&quot;,
    conf_thres=0.25
)

ocr = ma_anpr_ocr_v14(
    &quot;small_fp32&quot;,       # 300 FPS (fastest OCR!)
    &quot;univ&quot;,             # Universal for mixed traffic
    user, key, sig
)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Fastest processing for high-volume applications. Can handle multiple streams.&lt;/p&gt;

&lt;h4&gt;Use Case 4: Mobile/Edge Device&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Requirements:&lt;/strong&gt; Small size, low power, on-device processing&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# Recommended Configuration
detector = ma_anpr_detector_v14(
    &quot;micro_320p_fp16&quot;,  # 97% detection, 42 MB (50% smaller!)
    user, key, sig,
    backend=&quot;cpu&quot;,      # CPU for mobile
    conf_thres=0.25
)

ocr = ma_anpr_ocr_v14(
    &quot;pico_fp32&quot;,        # 20 MB, 270 FPS
    &quot;kr&quot;,               # Specific region
    user, key, sig
)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Smallest models, excellent for mobile/edge. Total size: 62 MB.&lt;/p&gt;

&lt;h4&gt;Use Case 5: Law Enforcement (Difficult Conditions)&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Requirements:&lt;/strong&gt; Works in poor lighting, angles, damaged plates&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# Recommended Configuration
detector = ma_anpr_detector_v14(
    &quot;medium_640p_fp32&quot;, # 99.21% detection
    user, key, sig,
    backend=&quot;cuda&quot;,
    conf_thres=0.15     # Very low threshold for difficult cases
)

ocr = ma_anpr_ocr_v14(
    &quot;large_fp32&quot;,       # Best OCR accuracy
    &quot;na&quot;,               # Specific region
    user, key, sig
)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Handles difficult conditions better. Lower threshold catches more plates.&lt;/p&gt;

&lt;h3&gt;📈 Performance Comparison Chart&lt;/h3&gt;

&lt;h4&gt;Detector Models: Speed vs Accuracy&lt;/h4&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Category&lt;/th&gt;
&lt;th&gt;Fastest&lt;/th&gt;
&lt;th&gt;Balanced&lt;/th&gt;
&lt;th&gt;Most Accurate&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;320p&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;small_320p_fp32&lt;br /&gt;142 FPS, 98.00%&lt;/td&gt;
&lt;td&gt;micro_320p_fp32&lt;br /&gt;128 FPS, 97.13%&lt;/td&gt;
&lt;td&gt;large_320p_fp32&lt;br /&gt;131 FPS, 98.40%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;640p&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;small_640p_fp32&lt;br /&gt;70 FPS, 99.15%&lt;/td&gt;
&lt;td&gt;medium_640p_fp32&lt;br /&gt;66 FPS, 99.21%&lt;/td&gt;
&lt;td&gt;large_640p_fp32&lt;br /&gt;60 FPS, 99.31%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Mobile&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;pico_320p_fp16&lt;br /&gt;50+ FPS, 37 MB&lt;/td&gt;
&lt;td&gt;micro_320p_fp16&lt;br /&gt;56 FPS, 42 MB&lt;/td&gt;
&lt;td&gt;small_320p_fp16&lt;br /&gt;70+ FPS, 57 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h4&gt;OCR Models: Speed vs Accuracy&lt;/h4&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Priority&lt;/th&gt;
&lt;th&gt;Smallest&lt;/th&gt;
&lt;th&gt;Fastest&lt;/th&gt;
&lt;th&gt;Most Accurate&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Choice&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;pico_fp32&lt;br /&gt;20 MB, 270 FPS&lt;br /&gt;91.78% exact&lt;/td&gt;
&lt;td&gt;small_fp32&lt;br /&gt;112 MB, 300 FPS&lt;br /&gt;91.54% exact&lt;/td&gt;
&lt;td&gt;large_fp32&lt;br /&gt;179 MB, 262 FPS&lt;br /&gt;91.70% exact&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h3&gt;💡 Performance Tips&lt;/h3&gt;

&lt;h4&gt;1. GPU Acceleration is Essential&lt;/h4&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# CPU: ~1-2 FPS (slow!)
detector = ma_anpr_detector_v14(..., backend=&quot;cpu&quot;)

# CUDA (NVIDIA GPU): ~100+ FPS (fast!)
detector = ma_anpr_detector_v14(..., backend=&quot;cuda&quot;)

# DirectML (Windows GPU): ~50+ FPS
detector = ma_anpr_detector_v14(..., backend=&quot;directml&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; GPU is 50-100× faster than CPU!&lt;/p&gt;

&lt;h4&gt;2. Use Batch Processing&lt;/h4&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# Slow: Process one by one
for img in images:
    text, conf = ocr.predict(img)

# Fast: Process in batch (3-5× faster!)
results = ocr.predict(images)  # Pass list
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;3. Choose Resolution Wisely&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;320p&lt;/strong&gt;: Good quality images, controlled environment → Use 320p (2× faster)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;640p&lt;/strong&gt;: Poor lighting, far distance, damaged plates → Use 640p (higher accuracy)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;4. Tune Confidence Thresholds&lt;/h4&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# High precision (fewer false positives)
detector = ma_anpr_detector_v14(..., conf_thres=0.50)

# Balanced (recommended)
detector = ma_anpr_detector_v14(..., conf_thres=0.25)

# High recall (catch more plates, more false positives)
detector = ma_anpr_detector_v14(..., conf_thres=0.15)
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;5. Use Specific Regions&lt;/h4&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# ❌ Less accurate (universal)
ocr = ma_anpr_ocr_v14(&quot;small_fp32&quot;, &quot;univ&quot;, ...)  # ~92% exact match

# ✅ More accurate (specific region)
ocr = ma_anpr_ocr_v14(&quot;small_fp32&quot;, &quot;kr&quot;, ...)    # ~99% exact match!
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🚀 Quick Decision Guide&lt;/h3&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Your Priority&lt;/th&gt;
&lt;th&gt;Detector&lt;/th&gt;
&lt;th&gt;OCR&lt;/th&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color: #e8f5e9;&quot;&gt;
&lt;td&gt;&lt;strong&gt;Best Overall&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;micro_320p_fp32&lt;/td&gt;
&lt;td&gt;small_fp32&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Fastest&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;small_320p_fp32&lt;/td&gt;
&lt;td&gt;small_fp32&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Most Accurate&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;large_640p_fp32&lt;/td&gt;
&lt;td&gt;large_fp32&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Smallest&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;pico_320p_fp16&lt;/td&gt;
&lt;td&gt;pico_fp32&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Mobile&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;micro_320p_fp16&lt;/td&gt;
&lt;td&gt;pico_fp32&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Balanced&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;medium_320p_fp32&lt;/td&gt;
&lt;td&gt;medium_fp32&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h3&gt;📊 Benchmark Environment&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;GPU:&lt;/strong&gt; NVIDIA RTX 3060 (CUDA 11.8)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CPU:&lt;/strong&gt; Intel Core i7&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dataset:&lt;/strong&gt; Real-world license plate images&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Test Size:&lt;/strong&gt; 1000+ images per region&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Updated:&lt;/strong&gt; December 2025&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;🎓 Key Takeaways&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Two-stage pipeline&lt;/strong&gt;: Detector → OCR&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Mix and match&lt;/strong&gt; models for your needs&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;320p models&lt;/strong&gt;: 2× faster, excellent for most uses&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;640p models&lt;/strong&gt;: Highest accuracy for difficult cases&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;GPU acceleration&lt;/strong&gt;: 50-100× faster than CPU&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Specific regions&lt;/strong&gt;: Much better accuracy than universal&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Batch processing&lt;/strong&gt;: 3-5× faster for multiple images&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Best overall&lt;/strong&gt;: micro_320p_fp32 + small_fp32&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;💻 Example Configuration&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from marearts_anpr import ma_anpr_detector_v14, ma_anpr_ocr_v14
from marearts_anpr import marearts_anpr_from_image_file

# Initialize models (one time)
detector = ma_anpr_detector_v14(
    &quot;micro_320p_fp32&quot;,      # 97% detection, 128 FPS
    user_name, serial_key, signature,
    backend=&quot;cuda&quot;,          # GPU acceleration
    conf_thres=0.25          # Balanced threshold
)

ocr = ma_anpr_ocr_v14(
    &quot;small_fp32&quot;,            # 95%+ accuracy, 300 FPS
    &quot;eup&quot;,                   # Specific region for best accuracy
    user_name, serial_key, signature
)

# Process image
result = marearts_anpr_from_image_file(detector, ocr, &quot;plate.jpg&quot;)
print(result)

# Output:
# {
#   &quot;results&quot;: [
#     {
#       &quot;ocr&quot;: &quot;AB-123-CD&quot;,
#       &quot;ocr_conf&quot;: 98.5,
#       &quot;ltrb&quot;: [120, 230, 380, 290],
#       &quot;ltrb_conf&quot;: 95
#     }
#   ],
#   &quot;ltrb_proc_sec&quot;: 0.008,  # Detection time
#   &quot;ocr_proc_sec&quot;: 0.003     # OCR time
# }
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🔗 Resources&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;📊 &lt;strong&gt;Full Benchmarks:&lt;/strong&gt; See detailed results in GitHub docs&lt;/li&gt;
&lt;li&gt;📚 &lt;strong&gt;Model Guide:&lt;/strong&gt; Complete model documentation&lt;/li&gt;
&lt;li&gt;🧪 &lt;strong&gt;Try Free:&lt;/strong&gt; &lt;code&gt;ma-anpr test-api image.jpg&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;🛒 &lt;strong&gt;Get License:&lt;/strong&gt; &lt;a href=&quot;https://www.marearts.com/products/anpr&quot;&gt;MareArts ANPR&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;🎯 Conclusion&lt;/h3&gt;

&lt;p&gt;MareArts ANPR V14 offers 11 detector models and 5 OCR models, giving you 55+ possible combinations! The right choice depends on your specific requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Speed-critical?&lt;/strong&gt; → small_320p_fp32 + small_fp32&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Accuracy-critical?&lt;/strong&gt; → large_640p_fp32 + large_fp32&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Balanced?&lt;/strong&gt; → micro_320p_fp32 + small_fp32 (recommended!)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mobile?&lt;/strong&gt; → micro_320p_fp16 + pico_fp32&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start with the recommended configuration and tune based on your results. Happy optimizing! ⚡🚗&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;em&gt;Labels: ANPR, MachineLearning, ComputerVision, Performance, Benchmarks, Models, Metrics, DeepLearning, Optimization, GPU&lt;/em&gt;&lt;/p&gt;

</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/744853647301894963/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2025/12/marearts-anpr-v14-models-complete.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/744853647301894963'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/744853647301894963'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2025/12/marearts-anpr-v14-models-complete.html' title='MareArts ANPR V14 Models - Complete Performance Guide &amp; Benchmarks'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-6007457100329709981</id><published>2025-12-30T14:00:00.000-08:00</published><updated>2025-12-30T14:00:03.898-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ai"/><category scheme="http://www.blogger.com/atom/ns#" term="alpr"/><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="ANPR"/><category scheme="http://www.blogger.com/atom/ns#" term="ComputerVision"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="LicensePlateRecognition"/><category scheme="http://www.blogger.com/atom/ns#" term="lpr"/><category scheme="http://www.blogger.com/atom/ns#" term="MobileApp"/><category scheme="http://www.blogger.com/atom/ns#" term="OnDevice"/><category scheme="http://www.blogger.com/atom/ns#" term="ParkingManagement"/><category scheme="http://www.blogger.com/atom/ns#" term="Privacy"/><category scheme="http://www.blogger.com/atom/ns#" term="Security"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><title type='text'>MareArts ANPR Mobile App - Professional License Plate Recognition in Your Pocket</title><content type='html'>&lt;br /&gt;&lt;h2&gt;📱 Introducing MareArts ANPR Mobile App - AI-Powered License Plate Recognition&lt;/h2&gt;

&lt;p&gt;We&#39;re excited to announce the &lt;strong&gt;MareArts ANPR Mobile App&lt;/strong&gt; - bringing professional-grade license plate recognition to iOS! Experience the power of on-device AI for parking management, security checkpoints, and vehicle tracking, all in your pocket.&lt;/p&gt;

&lt;h3&gt;🎁 One License, Everything Included!&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;No additional license required!&lt;/strong&gt; When you purchase a MareArts ANPR license, you get:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;✅ Python SDK (unlimited desktop/server usage)&lt;/li&gt;
&lt;li&gt;✅ iOS Mobile App (unlimited mobile usage)&lt;/li&gt;
&lt;li&gt;✅ Road Objects Detection&lt;/li&gt;
&lt;li&gt;✅ All future updates&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;One license = Use everywhere!&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;📲 Download Now&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;iOS:&lt;/strong&gt; &lt;a href=&quot;https://apps.apple.com/us/app/marearts-anpr/id6753904859&quot;&gt;Download on App Store&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Android:&lt;/strong&gt; Coming Soon! 🚀&lt;/p&gt;
&lt;p&gt;Search &quot;marearts anpr&quot; in the App Store&lt;/p&gt;

&lt;h3&gt;🎉 Free Trial Available!&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;100 scans per day&lt;/strong&gt; - FREE forever!&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;No credit card&lt;/strong&gt; required&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;No registration&lt;/strong&gt; needed&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Try before you buy&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Login for unlimited&lt;/strong&gt; scans (with license)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;✨ Key Features&lt;/h3&gt;

&lt;h4&gt;🔒 100% Privacy First&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;On-Device AI Processing&lt;/strong&gt; - All recognition happens on your iPhone&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No Cloud Upload&lt;/strong&gt; - Your data stays on your device&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No Analytics Tracking&lt;/strong&gt; - We don&#39;t track your usage&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Local Storage&lt;/strong&gt; - Complete privacy and security&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;⚡ Lightning Fast&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Real-time Detection&lt;/strong&gt; - Instant plate recognition&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Continuous Scanning&lt;/strong&gt; - Auto-capture mode for busy entrances&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Optimized for iOS&lt;/strong&gt; - Smooth 60 FPS camera&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No Internet Needed&lt;/strong&gt; - Works completely offline&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;🌍 Multi-Region Support&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;🌍 &lt;strong&gt;Universal&lt;/strong&gt; - All regions (default)&lt;/li&gt;
&lt;li&gt;🇪🇺 &lt;strong&gt;Europe+&lt;/strong&gt; - EU, UK, Switzerland, Norway&lt;/li&gt;
&lt;li&gt;🇰🇷 &lt;strong&gt;Korea&lt;/strong&gt; - South Korea (한국)&lt;/li&gt;
&lt;li&gt;🇺🇸 &lt;strong&gt;North America&lt;/strong&gt; - USA, Canada, Mexico&lt;/li&gt;
&lt;li&gt;🇨🇳 &lt;strong&gt;China&lt;/strong&gt; - China (中国)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;🧭 Five Powerful Tabs&lt;/h3&gt;

&lt;h4&gt;1. 📷 Scan Page - Fast Recognition&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Camera Modes:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Single Capture&lt;/strong&gt; (⭕) - Take one photo at a time&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Continuous Mode&lt;/strong&gt; (🔄) - Auto-scan continuously&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cloud Mode&lt;/strong&gt; (☁️) - Use cloud API for processing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Swipe left/right&lt;/strong&gt; - Quick switch between modes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Smart Controls:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;🔦 Flash toggle for low light&lt;/li&gt;
&lt;li&gt;🔍 1x-5x zoom (pinch or tap)&lt;/li&gt;
&lt;li&gt;📷 Front/back camera switch&lt;/li&gt;
&lt;li&gt;✅ Tap to focus anywhere&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Live Feedback:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Green/Red boxes show detected plates&lt;/li&gt;
&lt;li&gt;Real-time plate number display&lt;/li&gt;
&lt;li&gt;Confidence percentage shown&lt;/li&gt;
&lt;li&gt;Whitelist/Blacklist status indicator&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;2. 🕐 Detections Page - Complete History&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Three View Modes:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📋 List View&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;All captured plates chronologically&lt;/li&gt;
&lt;li&gt;Grouped by: Today, Yesterday, This Week, etc.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Swipe left-to-right&lt;/strong&gt; - Quick status change menu&lt;/li&gt;
&lt;li&gt;Color badges: Green (whitelist), Red (blacklist), Orange (unknown)&lt;/li&gt;
&lt;li&gt;Shows: Plate number, time, location, thumbnail&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;📸 Full Preview&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Large plate image&lt;/li&gt;
&lt;li&gt;Edit plate number (tap ✏️)&lt;/li&gt;
&lt;li&gt;Detection + OCR confidence&lt;/li&gt;
&lt;li&gt;GPS location &amp;amp; address&lt;/li&gt;
&lt;li&gt;Quick actions: Copy, Delete, Add to Whitelist/Blacklist&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🗺️ Map View&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;See all plates on interactive map&lt;/li&gt;
&lt;li&gt;Smart clustering for nearby detections&lt;/li&gt;
&lt;li&gt;Satellite/Road view toggle&lt;/li&gt;
&lt;li&gt;Show all plate numbers as labels&lt;/li&gt;
&lt;li&gt;Search by plate number&lt;/li&gt;
&lt;li&gt;Tap markers for details&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;3. ✅ Rules Page - Whitelist &amp;amp; Blacklist&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Smart Access Control:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Whitelist (Green)&lt;/strong&gt; - Approved vehicles, success sound&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Blacklist (Red)&lt;/strong&gt; - Blocked vehicles, alert sound&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Search in Real-time&lt;/strong&gt; - Filter plates instantly&lt;/li&gt;
&lt;li&gt;Partial matching: &quot;ABC&quot; finds &quot;ABC-123&quot;&lt;/li&gt;
&lt;li&gt;Tab counters show totals&lt;/li&gt;
&lt;li&gt;Swipe left to delete&lt;/li&gt;
&lt;li&gt;+ button to add new plates&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use Cases:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;🏢 Parking: Whitelist residents, blacklist violators&lt;/li&gt;
&lt;li&gt;🔐 Security: Whitelist staff, blacklist banned vehicles&lt;/li&gt;
&lt;li&gt;🚚 Delivery: Track known vehicles&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;4. 📊 Stats Page - Analytics &amp;amp; Insights&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Overview Cards:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Total Scans (all-time)&lt;/li&gt;
&lt;li&gt;Today&#39;s count&lt;/li&gt;
&lt;li&gt;This Week / Month / Year&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Top 10 Vehicles:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Most frequently detected plates&lt;/li&gt;
&lt;li&gt;Tap to see all scans for that vehicle&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Time Period Selector:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Today&lt;/strong&gt; - Hourly breakdown&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;This Week&lt;/strong&gt; - Monday to today&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;This Month&lt;/strong&gt; - Current month&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Year&lt;/strong&gt; - Full year with year selector&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Custom Range&lt;/strong&gt; - Pick any dates&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Status Filter:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;View All, Whitelist only, Blacklist only, or Unknown&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;5. ⚙️ Settings Page - Fine-Tune Everything&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Account:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Login with email + signature → &lt;strong&gt;Infinite scans!&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Free trial: 100 scans/day (no login)&lt;/li&gt;
&lt;li&gt;Shows expiry date&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Notifications:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;🔊 Sound alerts (success/alert/unknown)&lt;/li&gt;
&lt;li&gt;📳 Vibration patterns (different for whitelist/blacklist)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Detection Settings:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Sync Thresholds&lt;/strong&gt; - Link detection + OCR together&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Detection Threshold&lt;/strong&gt; (60-95%) - Minimum confidence&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OCR Threshold&lt;/strong&gt; (60-95%) - Text recognition confidence&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Max Detections&lt;/strong&gt; (1-10) - Plates per scan&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ignore Duplicates&lt;/strong&gt; (0-60s) - Prevent repeated saves&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Plate Region&lt;/strong&gt; - Select specific region for accuracy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Storage:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Save images toggle&lt;/li&gt;
&lt;li&gt;Clear history&lt;/li&gt;
&lt;li&gt;Data retention: 7-365 days or Never&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Location:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Enable GPS for map view&lt;/li&gt;
&lt;li&gt;Shows address with detections&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;🎯 Real-World Use Cases&lt;/h3&gt;

&lt;h4&gt;🏢 Parking Management&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;1. Add residents to Whitelist
2. Scan vehicles at entrance
3. Green = Allowed, Red = Blocked
4. Review violations in history
5. View statistics monthly
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;🔐 Security Checkpoint&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;1. Add approved vehicles to Whitelist
2. Add banned vehicles to Blacklist
3. Use Continuous Mode at gate
4. Audio/vibration alerts instantly
5. GPS tracking of all entries
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;🚗 Vehicle Tracking&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;1. Scan vehicles continuously
2. View complete history
3. Use Map to see locations
4. Export data for reports
5. Track Top 10 frequent visitors
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;🚚 Delivery Management&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;1. Track delivery vehicle arrivals
2. Time-stamped records
3. GPS location logging
4. Statistics for optimization
5. Whitelist known carriers
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;💡 Pro Tips for Best Results&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;✅ Best Practices:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Distance:&lt;/strong&gt; 2-3 meters from vehicle&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Angle:&lt;/strong&gt; Perpendicular to plate (90 degrees)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lighting:&lt;/strong&gt; Good outdoor light (daytime best)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Focus:&lt;/strong&gt; Tap plate area to focus before scanning&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stability:&lt;/strong&gt; Hold steady while capturing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;❌ Avoid:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Too far away (&amp;gt;5 meters)&lt;/li&gt;
&lt;li&gt;Extreme angles&lt;/li&gt;
&lt;li&gt;Low light conditions&lt;/li&gt;
&lt;li&gt;Motion blur (moving vehicle)&lt;/li&gt;
&lt;li&gt;Dirty or damaged plates&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;⚙️ Settings Recommendations:&lt;/strong&gt;&lt;/p&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Use Case&lt;/th&gt;
&lt;th&gt;Detection&lt;/th&gt;
&lt;th&gt;OCR&lt;/th&gt;
&lt;th&gt;Max Plates&lt;/th&gt;
&lt;th&gt;Region&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;High Accuracy&lt;/strong&gt;&lt;br /&gt;(Parking/Security)&lt;/td&gt;
&lt;td&gt;90%&lt;/td&gt;
&lt;td&gt;90%&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Specific&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;High Recall&lt;/strong&gt;&lt;br /&gt;(Traffic Monitoring)&lt;/td&gt;
&lt;td&gt;70%&lt;/td&gt;
&lt;td&gt;70%&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Universal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Balanced&lt;/strong&gt;&lt;br /&gt;(General Use)&lt;/td&gt;
&lt;td&gt;80%&lt;/td&gt;
&lt;td&gt;80%&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Specific&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h3&gt;🔄 Latest Update (v1.5.16)&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What&#39;s New:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;✨ Year selector in Stats page&lt;/li&gt;
&lt;li&gt;📅 Custom date range picker&lt;/li&gt;
&lt;li&gt;🔍 Search in Rules page (real-time filtering)&lt;/li&gt;
&lt;li&gt;👆 Swipe navigation between modes&lt;/li&gt;
&lt;li&gt;🎨 UI improvements&lt;/li&gt;
&lt;li&gt;🐛 Bug fixes and performance enhancements&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;🆚 Free vs Paid License&lt;/h3&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Free Trial&lt;/th&gt;
&lt;th&gt;Paid License&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Daily Scans&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;100/day&lt;/td&gt;
&lt;td&gt;Unlimited ∞&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;All Features&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;5 Regions&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Whitelist/Blacklist&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;History &amp;amp; Stats&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Map View&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Python SDK&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Commercial Use&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Support&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Community&lt;/td&gt;
&lt;td&gt;Priority&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h3&gt;🌟 Why Choose MareArts ANPR Mobile App?&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Professional Grade&lt;/strong&gt; - Same AI as enterprise SDK&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;100% Privacy&lt;/strong&gt; - All processing on-device&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Lightning Fast&lt;/strong&gt; - Real-time recognition&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Free Trial&lt;/strong&gt; - 100 scans/day forever&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Multi-Region&lt;/strong&gt; - Works worldwide&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Complete Solution&lt;/strong&gt; - Whitelist, history, map, stats&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;One License&lt;/strong&gt; - Mobile + SDK included&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Regular Updates&lt;/strong&gt; - New features monthly&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;📊 Technical Specs&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Platform:&lt;/strong&gt; iOS 14.0+ (Android coming soon)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AI Engine:&lt;/strong&gt; On-device CoreML&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Processing Time:&lt;/strong&gt; ~0.1s per frame&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Accuracy:&lt;/strong&gt; 95%+ (optimal conditions)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Storage:&lt;/strong&gt; ~200MB (with models)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internet:&lt;/strong&gt; Not required (offline capable)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Camera:&lt;/strong&gt; All iOS cameras supported&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;🚀 Get Started in 3 Steps&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Step 1: Download from App Store
Search &quot;marearts anpr&quot; → Install

# Step 2: Open app and start scanning
Tap Scan → Point at license plate → Capture!

# Step 3 (Optional): Login for unlimited
Settings → Login → Enter email + signature → ∞ scans!
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;💼 Perfect For:&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;🏢 &lt;strong&gt;Parking Lot Managers&lt;/strong&gt; - Automate access control&lt;/li&gt;
&lt;li&gt;🔐 &lt;strong&gt;Security Guards&lt;/strong&gt; - Quick vehicle verification&lt;/li&gt;
&lt;li&gt;🏠 &lt;strong&gt;Residential Communities&lt;/strong&gt; - Resident/visitor tracking&lt;/li&gt;
&lt;li&gt;🏗️ &lt;strong&gt;Construction Sites&lt;/strong&gt; - Authorized vehicle entry&lt;/li&gt;
&lt;li&gt;🏨 &lt;strong&gt;Hotels&lt;/strong&gt; - Valet parking management&lt;/li&gt;
&lt;li&gt;🚚 &lt;strong&gt;Logistics&lt;/strong&gt; - Delivery vehicle tracking&lt;/li&gt;
&lt;li&gt;👮 &lt;strong&gt;Law Enforcement&lt;/strong&gt; - Field plate scanning&lt;/li&gt;
&lt;li&gt;🎓 &lt;strong&gt;Universities&lt;/strong&gt; - Campus parking control&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;📞 Support &amp;amp; Resources&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;📧 &lt;strong&gt;Email:&lt;/strong&gt; hello@marearts.com&lt;/li&gt;
&lt;li&gt;🌐 &lt;strong&gt;Website:&lt;/strong&gt; &lt;a href=&quot;https://www.marearts.com&quot;&gt;https://www.marearts.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;🛒 &lt;strong&gt;Buy License:&lt;/strong&gt; &lt;a href=&quot;https://www.marearts.com/products/anpr&quot;&gt;ANPR Solution&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;📚 &lt;strong&gt;Full Guide:&lt;/strong&gt; &lt;a href=&quot;https://github.com/MareArts/MareArts-ANPR/blob/main/mobile_app/APP_GUIDE.md&quot;&gt;APP_GUIDE.md&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;🐛 &lt;strong&gt;Report Issues:&lt;/strong&gt; GitHub Issues&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;🎁 Special Offer&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Buy one license, get everything:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;✅ Python SDK (desktop/server)&lt;/li&gt;
&lt;li&gt;✅ iOS Mobile App (unlimited scans)&lt;/li&gt;
&lt;li&gt;✅ Road Objects Detection&lt;/li&gt;
&lt;li&gt;✅ All future updates&lt;/li&gt;
&lt;li&gt;✅ Priority support&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;One payment, lifetime access!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;💬 What Users Are Saying&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&quot;Perfect for our parking lot! 100 free scans/day is enough for testing, and the paid version is unlimited.&quot; - Parking Manager&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;p&gt;&quot;Finally, professional ANPR on mobile! On-device processing means no privacy concerns.&quot; - Security Director&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;p&gt;&quot;The whitelist/blacklist feature saves us so much time at our security gate.&quot; - Facility Manager&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;p&gt;&quot;Map view is genius! We can see exactly where each vehicle was spotted.&quot; - Operations Manager&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;🎯 Start Today!&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;📲 &lt;strong&gt;Download:&lt;/strong&gt; Search &quot;marearts anpr&quot; on App Store&lt;/li&gt;
&lt;li&gt;📷 &lt;strong&gt;Try Free:&lt;/strong&gt; 100 scans/day, no credit card&lt;/li&gt;
&lt;li&gt;🚀 &lt;strong&gt;Upgrade:&lt;/strong&gt; Login for unlimited scans&lt;/li&gt;
&lt;li&gt;💼 &lt;strong&gt;Deploy:&lt;/strong&gt; Use in production with confidence&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Professional license plate recognition is now in your pocket!&lt;/strong&gt; 📱🚗&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/6007457100329709981/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2025/12/marearts-anpr-mobile-app-professional.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/6007457100329709981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/6007457100329709981'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2025/12/marearts-anpr-mobile-app-professional.html' title='MareArts ANPR Mobile App - Professional License Plate Recognition in Your Pocket'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-4504379595969683783</id><published>2025-12-30T13:57:00.000-08:00</published><updated>2025-12-30T13:57:40.986-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="alpr"/><category scheme="http://www.blogger.com/atom/ns#" term="ANPR"/><category scheme="http://www.blogger.com/atom/ns#" term="ComputerVision"/><category scheme="http://www.blogger.com/atom/ns#" term="Free"/><category scheme="http://www.blogger.com/atom/ns#" term="FreeAPI"/><category scheme="http://www.blogger.com/atom/ns#" term="LicensePlateRecognition"/><category scheme="http://www.blogger.com/atom/ns#" term="lpr"/><category scheme="http://www.blogger.com/atom/ns#" term="MachineLearning"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial"/><title type='text'>FREE ANPR/ALPR/LPR API - Try Before You Buy (1000 Requests/Day)</title><content type='html'>&lt;br /&gt;&lt;h2&gt;🎁 FREE License Plate Recognition API - No Credit Card Required!&lt;/h2&gt;

&lt;p&gt;Want to try ANPR (Automatic Number Plate Recognition) / ALPR (Automatic License Plate Recognition) / LPR (License Plate Recognition) without buying a license? We offer a &lt;strong&gt;completely FREE test API&lt;/strong&gt; with 1000 requests per day!&lt;/p&gt;

&lt;h3&gt;✨ What You Get (FREE!)&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;1000 requests/day&lt;/strong&gt; - Perfect for testing and evaluation&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;No credit card&lt;/strong&gt; required&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;No registration&lt;/strong&gt; needed&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;5 regions&lt;/strong&gt; supported: Korea, Europe, USA/Canada, China, Universal&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Multiple models&lt;/strong&gt; to test (pico to large)&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Works instantly&lt;/strong&gt; - just install and run!&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;🚀 Quick Start (30 Seconds)&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Install
pip install marearts-anpr

# Test immediately (NO CONFIG NEEDED!)
ma-anpr test-api your-plate.jpg --region eup

# That&#39;s it! 🎉
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🌍 Supported Regions&lt;/h3&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Region Code&lt;/th&gt;
&lt;th&gt;Coverage&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kr&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;South Korea&lt;/td&gt;
&lt;td&gt;123가4567&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;eup&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Europe (EU standards)&lt;/td&gt;
&lt;td&gt;AB-123-CD&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;na&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;USA, Canada, Mexico&lt;/td&gt;
&lt;td&gt;ABC-1234&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;cn&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;China&lt;/td&gt;
&lt;td&gt;京A·12345&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;univ&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Universal (all)&lt;/td&gt;
&lt;td&gt;Any format&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h3&gt;💻 Usage Examples&lt;/h3&gt;

&lt;h4&gt;Command Line (Easiest!)&lt;/h4&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# European plates
ma-anpr test-api eu-plate.jpg --region eup

# Korean plates
ma-anpr test-api kr-plate.jpg --region kr

# US plates
ma-anpr test-api us-plate.jpg --region na

# Chinese plates
ma-anpr test-api cn-plate.jpg --region cn

# Unknown region? Use universal
ma-anpr test-api unknown-plate.jpg --region univ
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Python Script&lt;/h4&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;#!/usr/bin/env python3
import subprocess

def test_free_anpr(image_path, region=&#39;eup&#39;):
    &quot;&quot;&quot;Test free ANPR API - no credentials needed!&quot;&quot;&quot;
    
    cmd = f&#39;ma-anpr test-api &quot;{image_path}&quot; --region {region}&#39;
    result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
    
    if result.returncode == 0:
        print(result.stdout)
        return True
    else:
        print(f&quot;Error: {result.stderr}&quot;)
        return False

# Test European plate
test_free_anpr(&quot;plate.jpg&quot;, &quot;eup&quot;)

# Test Korean plate
test_free_anpr(&quot;plate2.jpg&quot;, &quot;kr&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Test Multiple Regions&lt;/h4&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Test same image with different regions
for region in eup kr na cn univ; do
    echo &quot;Testing $region...&quot;
    ma-anpr test-api plate.jpg --region $region
done
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🎯 Advanced Options&lt;/h3&gt;

&lt;h4&gt;Try Different Models&lt;/h4&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# List all available models
ma-anpr test-api --list-models

# Try different detector models
ma-anpr test-api plate.jpg --region eup --detector small_640p_fp32
ma-anpr test-api plate.jpg --region eup --detector medium_640p_fp32
ma-anpr test-api plate.jpg --region eup --detector large_640p_fp32

# Try different OCR models
ma-anpr test-api plate.jpg --region eup --ocr small_fp32
ma-anpr test-api plate.jpg --region eup --ocr medium_fp32
ma-anpr test-api plate.jpg --region eup --ocr large_fp32
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Batch Testing&lt;/h4&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Test all images in a folder
for img in ./plates/*.jpg; do
    echo &quot;Processing $img...&quot;
    ma-anpr test-api &quot;$img&quot; --region eup
done
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;📊 Sample Output&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;results&quot;: [
    {
      &quot;ocr&quot;: &quot;AB-123-CD&quot;,
      &quot;ocr_conf&quot;: 98.5,
      &quot;ltrb&quot;: [120, 230, 380, 290],
      &quot;ltrb_conf&quot;: 95
    }
  ],
  &quot;ltrb_proc_sec&quot;: 0.15,
  &quot;ocr_proc_sec&quot;: 0.03,
  &quot;status&quot;: &quot;success&quot;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🆓 FREE vs PAID Comparison&lt;/h3&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;FREE Test API&lt;/th&gt;
&lt;th&gt;Paid License&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Requests/Day&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;1000&lt;/td&gt;
&lt;td&gt;Unlimited&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Speed&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~0.5s (cloud)&lt;/td&gt;
&lt;td&gt;~0.02s (local GPU)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Internet Required&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No (offline OK)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Configuration&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;One-time setup&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Regions&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;All 5&lt;/td&gt;
&lt;td&gt;All 5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Models&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;All&lt;/td&gt;
&lt;td&gt;All&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Price&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$0&lt;/td&gt;
&lt;td&gt;Contact sales&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h3&gt;🎓 Use Cases for Free API&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Evaluation:&lt;/strong&gt; Try before buying a license&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Prototyping:&lt;/strong&gt; Build POC applications&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Testing:&lt;/strong&gt; Test accuracy on your specific plates&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Education:&lt;/strong&gt; Learn ANPR/ALPR/LPR technology&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Small Projects:&lt;/strong&gt; Personal projects under 1000/day&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Region Testing:&lt;/strong&gt; Find which region works best&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Model Comparison:&lt;/strong&gt; Compare different model sizes&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;📈 When to Upgrade to Paid License?&lt;/h3&gt;

&lt;p&gt;Consider upgrading when you need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;🚀 &lt;strong&gt;Unlimited requests&lt;/strong&gt; (no daily limit)&lt;/li&gt;
&lt;li&gt;⚡ &lt;strong&gt;10-100x faster&lt;/strong&gt; processing (local GPU)&lt;/li&gt;
&lt;li&gt;🔒 &lt;strong&gt;Offline operation&lt;/strong&gt; (no internet needed)&lt;/li&gt;
&lt;li&gt;🏢 &lt;strong&gt;Commercial deployment&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;📹 &lt;strong&gt;Real-time video&lt;/strong&gt; processing&lt;/li&gt;
&lt;li&gt;🎯 &lt;strong&gt;High-volume&lt;/strong&gt; applications (&amp;gt;1000/day)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;💡 Pro Tips&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# 1. Use specific regions for best accuracy
ma-anpr test-api plate.jpg --region eup  # ✅ Better
ma-anpr test-api plate.jpg --region univ # ⚠️ OK but less accurate

# 2. Test different models to find best speed/accuracy balance
ma-anpr test-api plate.jpg --region eup --detector small_640p_fp32   # Faster
ma-anpr test-api plate.jpg --region eup --detector large_640p_fp32   # More accurate

# 3. Check remaining quota
ma-anpr test-api --check-quota

# 4. Get help
ma-anpr test-api --help

# 5. See all options
ma-anpr test-api --list-models
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🔍 Troubleshooting&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Rate limit exceeded?&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Wait until midnight UTC (resets daily)
# OR upgrade to paid license for unlimited requests
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;No plates detected?&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Try different detector models
ma-anpr test-api plate.jpg --region eup --detector large_640p_fp32

# Try universal region
ma-anpr test-api plate.jpg --region univ
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Wrong text recognized?&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Make sure you&#39;re using correct region!
ma-anpr test-api plate.jpg --region kr   # For Korean plates
ma-anpr test-api plate.jpg --region eup  # For European plates

# Try larger OCR model
ma-anpr test-api plate.jpg --region eup --ocr large_fp32
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;📖 Complete Example Script&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;#!/usr/bin/env python3
&quot;&quot;&quot;
Free ANPR Test Script
Test license plate recognition with different regions and models
&quot;&quot;&quot;
import subprocess
import json

def test_anpr_free(image_path, region=&#39;eup&#39;, detector=&#39;medium_640p_fp32&#39;, ocr=&#39;medium_fp32&#39;):
    &quot;&quot;&quot;Test free ANPR API&quot;&quot;&quot;
    
    cmd = [
        &#39;ma-anpr&#39;, &#39;test-api&#39;, image_path,
        &#39;--region&#39;, region,
        &#39;--detector&#39;, detector,
        &#39;--ocr&#39;, ocr
    ]
    
    result = subprocess.run(cmd, capture_output=True, text=True)
    
    if result.returncode == 0:
        try:
            data = json.loads(result.stdout)
            return data
        except:
            return result.stdout
    else:
        return {&quot;error&quot;: result.stderr}

# Test European plate with different models
image = &quot;eu-plate.jpg&quot;

print(&quot;Testing different detector models...&quot;)
for detector in [&#39;small_640p_fp32&#39;, &#39;medium_640p_fp32&#39;, &#39;large_640p_fp32&#39;]:
    result = test_anpr_free(image, &#39;eup&#39;, detector)
    print(f&quot;{detector}: {result}&quot;)

print(&quot;\nTesting different regions...&quot;)
for region in [&#39;eup&#39;, &#39;kr&#39;, &#39;na&#39;, &#39;univ&#39;]:
    result = test_anpr_free(image, region)
    print(f&quot;{region}: {result}&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🎯 Real-World Example&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Parking lot monitoring (Europe)
ma-anpr test-api parking-cam.jpg --region eup

# Toll booth (USA)
ma-anpr test-api toll-booth.jpg --region na

# Security gate (Korea)
ma-anpr test-api security-cam.jpg --region kr

# Traffic enforcement (China)
ma-anpr test-api traffic.jpg --region cn

# Multi-national (airport parking)
ma-anpr test-api airport.jpg --region univ
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🌟 Why Choose MareArts ANPR?&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;FREE tier available&lt;/strong&gt; - Try before you buy!&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;State-of-the-art AI&lt;/strong&gt; - Latest deep learning models&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Multi-region support&lt;/strong&gt; - Works worldwide&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Fast processing&lt;/strong&gt; - ~0.02s with GPU&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Easy integration&lt;/strong&gt; - Python, HTTP API, CLI&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Regular updates&lt;/strong&gt; - New models and features&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Commercial ready&lt;/strong&gt; - Production-grade quality&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;🚀 Get Started Now!&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Install (takes 10 seconds)
pip install marearts-anpr

# Test (takes 20 seconds)
ma-anpr test-api your-plate.jpg --region eup

# Celebrate! 🎉
# You just recognized your first license plate!
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;📞 Need More?&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;🌐 Website: &lt;a href=&quot;https://www.marearts.com&quot;&gt;https://www.marearts.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;🛒 Purchase: &lt;a href=&quot;https://www.marearts.com/products/anpr&quot;&gt;https://www.marearts.com/products/anpr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;📚 Documentation: Full examples included with package&lt;/li&gt;
&lt;li&gt;💬 Support: Technical support with paid license&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;💬 What People Are Saying&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&quot;Finally, an ANPR API I can test without entering my credit card!&quot; - Developer&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;p&gt;&quot;1000 requests/day is perfect for my small parking lot project.&quot; - Small Business Owner&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;p&gt;&quot;Tested all 5 regions before buying. Confident in my purchase!&quot; - System Integrator&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;🎁 Summary&lt;/h3&gt;

&lt;p&gt;MareArts ANPR offers a &lt;strong&gt;completely FREE test API&lt;/strong&gt; with 1000 requests per day. No credit card, no registration, no strings attached. Just install and start recognizing license plates!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Install: &lt;code&gt;pip install marearts-anpr&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;✅ Test: &lt;code&gt;ma-anpr test-api plate.jpg --region eup&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;✅ Evaluate: Try all regions and models&lt;/li&gt;
&lt;li&gt;✅ Upgrade: When ready for unlimited use&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start your ANPR/ALPR/LPR journey today - &lt;strong&gt;completely FREE!&lt;/strong&gt; 🚗📸&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/4504379595969683783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2025/12/free-anpralprlpr-api-try-before-you-buy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/4504379595969683783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/4504379595969683783'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2025/12/free-anpralprlpr-api-try-before-you-buy.html' title='FREE ANPR/ALPR/LPR API - Try Before You Buy (1000 Requests/Day)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-3864069417130345198</id><published>2025-12-30T13:55:00.759-08:00</published><updated>2025-12-30T13:55:51.281-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Advanced"/><category scheme="http://www.blogger.com/atom/ns#" term="alpr"/><category scheme="http://www.blogger.com/atom/ns#" term="ANPR"/><category scheme="http://www.blogger.com/atom/ns#" term="ComputerVision"/><category scheme="http://www.blogger.com/atom/ns#" term="GPU"/><category scheme="http://www.blogger.com/atom/ns#" term="lpr"/><category scheme="http://www.blogger.com/atom/ns#" term="MachineLearning"/><category scheme="http://www.blogger.com/atom/ns#" term="Optimization"/><category scheme="http://www.blogger.com/atom/ns#" term="Performance"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><category scheme="http://www.blogger.com/atom/ns#" term="VideoProcessing"/><title type='text'>MareArts ANPR V14 - Advanced Manual Processing &amp; Performance Tuning</title><content type='html'>&amp;nbsp;&lt;h2&gt;⚡ MareArts ANPR V14 - Advanced Manual Processing&lt;/h2&gt;

&lt;p&gt;Ready to take control? In this advanced guide, I&#39;ll show you how to manually process detections, measure performance, and optimize for your specific use case.&lt;/p&gt;

&lt;h3&gt;🎯 Why Manual Processing?&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Full control over detection pipeline&lt;/li&gt;
&lt;li&gt;Custom filtering and post-processing&lt;/li&gt;
&lt;li&gt;Performance measurement and optimization&lt;/li&gt;
&lt;li&gt;Integration with existing computer vision pipelines&lt;/li&gt;
&lt;li&gt;Custom confidence thresholds per stage&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;🔧 Manual Detection &amp;amp; OCR Pipeline&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from marearts_anpr import ma_anpr_detector_v14, ma_anpr_ocr_v14
import cv2
from PIL import Image
import time

# Initialize models
detector = ma_anpr_detector_v14(
    &quot;medium_640p_fp32&quot;,
    user_name, serial_key, signature,
    backend=&quot;cpu&quot;,
    conf_thres=0.25,
    iou_thres=0.5
)

ocr = ma_anpr_ocr_v14(&quot;medium_fp32&quot;, &quot;eup&quot;, user_name, serial_key, signature)

# Load image
img = cv2.imread(&quot;plate.jpg&quot;)

# Step 1: Detect license plates
start = time.time()
detections = detector.detector(img)
detection_time = time.time() - start

print(f&quot;Detection time: {detection_time:.4f}s&quot;)
print(f&quot;Found {len(detections)} plate(s)&quot;)

# Step 2: Process each detection
results = []
ocr_time = 0

for i, box_info in enumerate(detections):
    # Get bounding box
    bbox = box_info[&#39;bbox&#39;]  # [x1, y1, x2, y2]
    score = box_info[&#39;score&#39;]  # Detection confidence
    
    # Crop plate region
    x1, y1, x2, y2 = int(bbox[0]), int(bbox[1]), int(bbox[2]), int(bbox[3])
    crop = img[y1:y2, x1:x2]
    
    if crop.size == 0:
        continue
    
    # Convert to PIL for OCR
    pil_img = Image.fromarray(crop)
    if pil_img.mode != &quot;RGB&quot;:
        pil_img = pil_img.convert(&quot;RGB&quot;)
    
    # Run OCR
    start = time.time()
    text, confidence = ocr.predict(pil_img)
    elapsed = time.time() - start
    ocr_time += elapsed
    
    print(f&quot;Plate {i+1}: {text} ({confidence}%) - {elapsed:.4f}s&quot;)
    
    results.append({
        &quot;ocr&quot;: text,
        &quot;ocr_conf&quot;: confidence,
        &quot;bbox&quot;: [x1, y1, x2, y2],
        &quot;det_conf&quot;: int(score * 100)
    })

print(f&quot;\nTotal time: {detection_time + ocr_time:.4f}s&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;📊 Detection Object Structure&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# detector.detector(img) returns list of dictionaries:
[
    {
        &#39;bbox&#39;: [x1, y1, x2, y2],  # Bounding box coordinates
        &#39;score&#39;: 0.95,              # Detection confidence (0-1)
        &#39;class&#39;: &#39;license_plate&#39;    # Object class
    },
    ...
]

# ocr.predict(pil_image) returns tuple:
(&quot;ABC1234&quot;, 98.5)  # (text, confidence_percentage)
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🚀 Backend Performance Comparison&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;backends = [&quot;cpu&quot;, &quot;cuda&quot;]  # Add &quot;directml&quot; on Windows

for backend_name in backends:
    try:
        print(f&quot;\n🔧 Testing {backend_name}...&quot;)
        
        # Initialize with specific backend
        test_detector = ma_anpr_detector_v14(
            &quot;medium_640p_fp32&quot;,
            user_name, serial_key, signature,
            backend=backend_name,
            conf_thres=0.25
        )
        
        # Measure performance
        start = time.time()
        detections = test_detector.detector(img)
        elapsed = time.time() - start
        
        print(f&quot;Detected {len(detections)} plates in {elapsed:.4f}s&quot;)
        print(f&quot;Speed: {1/elapsed:.1f} FPS&quot;)
        
    except Exception as e:
        print(f&quot;⚠️ {backend_name} not available: {e}&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;⚙️ Performance Results (Typical)&lt;/h3&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Backend&lt;/th&gt;
&lt;th&gt;Detection&lt;/th&gt;
&lt;th&gt;OCR&lt;/th&gt;
&lt;th&gt;Total&lt;/th&gt;
&lt;th&gt;FPS&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CPU (i7)&lt;/td&gt;
&lt;td&gt;~0.15s&lt;/td&gt;
&lt;td&gt;~0.03s&lt;/td&gt;
&lt;td&gt;~0.18s&lt;/td&gt;
&lt;td&gt;~5.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CUDA (RTX 3060)&lt;/td&gt;
&lt;td&gt;~0.008s&lt;/td&gt;
&lt;td&gt;~0.002s&lt;/td&gt;
&lt;td&gt;~0.01s&lt;/td&gt;
&lt;td&gt;~100&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; GPU acceleration = 18x faster! 🚀&lt;/p&gt;

&lt;h3&gt;🎛️ Custom Filtering&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# Filter detections by confidence
min_detection_conf = 0.50
min_ocr_conf = 80.0

filtered_results = []

for box_info in detections:
    if box_info[&#39;score&#39;] &amp;lt; min_detection_conf:
        continue  # Skip low confidence detections
    
    # Process with OCR...
    text, conf = ocr.predict(plate_crop)
    
    if conf &amp;lt; min_ocr_conf:
        continue  # Skip low confidence OCR
    
    filtered_results.append({
        &quot;text&quot;: text,
        &quot;confidence&quot;: conf,
        &quot;bbox&quot;: bbox
    })

print(f&quot;After filtering: {len(filtered_results)} high-confidence plates&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🎨 Custom Visualization&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import cv2

# Draw boxes and text on image
for result in results:
    x1, y1, x2, y2 = result[&#39;bbox&#39;]
    text = result[&#39;ocr&#39;]
    conf = result[&#39;ocr_conf&#39;]
    
    # Draw rectangle
    cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
    
    # Draw text
    label = f&quot;{text} ({conf}%)&quot;
    cv2.putText(img, label, (x1, y1-10), 
                cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)

cv2.imwrite(&quot;result.jpg&quot;, img)
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;📹 Video Processing Pipeline&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import cv2

# Open video
cap = cv2.VideoCapture(&quot;traffic.mp4&quot;)

frame_count = 0
plate_history = {}

while cap.isOpened():
    ret, frame = cap.read()
    if not ret:
        break
    
    frame_count += 1
    
    # Process every N frames (skip frames for speed)
    if frame_count % 5 != 0:
        continue
    
    # Detect plates
    detections = detector.detector(frame)
    
    for det in detections:
        bbox = det[&#39;bbox&#39;]
        x1, y1, x2, y2 = int(bbox[0]), int(bbox[1]), int(bbox[2]), int(bbox[3])
        crop = frame[y1:y2, x1:x2]
        
        if crop.size == 0:
            continue
        
        # OCR
        pil_crop = Image.fromarray(cv2.cvtColor(crop, cv2.COLOR_BGR2RGB))
        text, conf = ocr.predict(pil_crop)
        
        # Track plates (simple tracking by position)
        plate_id = f&quot;{x1//50}_{y1//50}&quot;
        
        if plate_id not in plate_history:
            plate_history[plate_id] = []
        plate_history[plate_id].append(text)
        
        # Draw
        cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
        cv2.putText(frame, text, (x1, y1-10), 
                    cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
    
    cv2.imshow(&#39;ANPR&#39;, frame)
    if cv2.waitKey(1) &amp;amp; 0xFF == ord(&#39;q&#39;):
        break

cap.release()
cv2.destroyAllWindows()

# Print detected plates
print(&quot;\nDetected plates:&quot;)
for plate_id, texts in plate_history.items():
    # Most common text for this plate
    most_common = max(set(texts), key=texts.count)
    print(f&quot;  {most_common} (seen {len(texts)} times)&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;💾 Batch Processing from Directory&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import os
from pathlib import Path

image_dir = Path(&quot;./images&quot;)
results_all = {}

for img_path in image_dir.glob(&quot;*.jpg&quot;):
    print(f&quot;Processing {img_path.name}...&quot;)
    
    img = cv2.imread(str(img_path))
    detections = detector.detector(img)
    
    plates = []
    for det in detections:
        bbox = det[&#39;bbox&#39;]
        x1, y1, x2, y2 = int(bbox[0]), int(bbox[1]), int(bbox[2]), int(bbox[3])
        crop = img[y1:y2, x1:x2]
        
        if crop.size &amp;gt; 0:
            pil_crop = Image.fromarray(cv2.cvtColor(crop, cv2.COLOR_BGR2RGB))
            text, conf = ocr.predict(pil_crop)
            plates.append({&quot;text&quot;: text, &quot;conf&quot;: conf})
    
    results_all[img_path.name] = plates

# Save results
import json
with open(&quot;results.json&quot;, &quot;w&quot;) as f:
    json.dump(results_all, f, indent=2)

print(f&quot;\nProcessed {len(results_all)} images&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🎓 Advanced Tips&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;GPU Memory:&lt;/strong&gt; Use &lt;code&gt;cuda&lt;/code&gt; backend for 10-100x speedup&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Confidence Tuning:&lt;/strong&gt; Lower &lt;code&gt;conf_thres&lt;/code&gt; to 0.15-0.20 for difficult images&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IOU Threshold:&lt;/strong&gt; Increase &lt;code&gt;iou_thres&lt;/code&gt; to reduce duplicate detections&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Batch Processing:&lt;/strong&gt; Process multiple crops at once with &lt;code&gt;ocr.predict([img1, img2, ...])&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Frame Skipping:&lt;/strong&gt; Process every Nth frame in videos for speed&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multi-threading:&lt;/strong&gt; Run detector and OCR in separate threads&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;🔍 Troubleshooting&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;No detections?&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Lower &lt;code&gt;conf_thres&lt;/code&gt; to 0.15&lt;/li&gt;
&lt;li&gt;Try larger model (&lt;code&gt;large_640p_fp32&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Check image quality and resolution&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Wrong OCR results?&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Verify correct region (&lt;code&gt;kr&lt;/code&gt;, &lt;code&gt;eup&lt;/code&gt;, &lt;code&gt;na&lt;/code&gt;, &lt;code&gt;cn&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Try larger OCR model (&lt;code&gt;large_fp32&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Check plate crop quality&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Slow performance?&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use GPU backend (&lt;code&gt;cuda&lt;/code&gt; or &lt;code&gt;directml&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Use smaller models (&lt;code&gt;small_640p_fp32&lt;/code&gt;, &lt;code&gt;small_fp32&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Skip video frames&lt;/li&gt;
&lt;li&gt;Batch process multiple images&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;💡 Conclusion&lt;/h3&gt;

&lt;p&gt;Manual processing gives you complete control over the ANPR pipeline. Use it for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;✅ Custom filtering and validation&lt;/li&gt;
&lt;li&gt;✅ Performance optimization&lt;/li&gt;
&lt;li&gt;✅ Video stream processing&lt;/li&gt;
&lt;li&gt;✅ Integration with existing CV pipelines&lt;/li&gt;
&lt;li&gt;✅ Advanced visualization and tracking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy optimizing! ⚡🚗&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/3864069417130345198/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2025/12/marearts-anpr-v14-advanced-manual.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/3864069417130345198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/3864069417130345198'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2025/12/marearts-anpr-v14-advanced-manual.html' title='MareArts ANPR V14 - Advanced Manual Processing &amp; Performance Tuning'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-3912211318130371490</id><published>2025-12-30T13:54:14.772-08:00</published><updated>2025-12-30T13:54:57.637-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="alpr"/><category scheme="http://www.blogger.com/atom/ns#" term="Alps"/><category scheme="http://www.blogger.com/atom/ns#" term="ANPR"/><category scheme="http://www.blogger.com/atom/ns#" term="ComputerVision"/><category scheme="http://www.blogger.com/atom/ns#" term="LicensePlateRecognition"/><category scheme="http://www.blogger.com/atom/ns#" term="lpr"/><category scheme="http://www.blogger.com/atom/ns#" term="MachineLearning"/><category scheme="http://www.blogger.com/atom/ns#" term="OpenCV"/><category scheme="http://www.blogger.com/atom/ns#" term="PIL"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial"/><title type='text'>MareArts ANPR V14 - Easy 3-Method Integration (File, OpenCV, PIL)</title><content type='html'>&lt;br /&gt;&lt;h2&gt;🚀 MareArts ANPR V14 - Getting Started in 3 Easy Ways&lt;/h2&gt;

&lt;p&gt;Welcome to MareArts ANPR V14! Today I&#39;ll show you how to process license plates using three different methods: from files, OpenCV, or PIL. Plus, the new multi-region switching feature that saves memory.&lt;/p&gt;

&lt;h3&gt;📦 Quick Setup&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install marearts-anpr
ma-anpr config  # Enter your credentials
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🎯 Basic Usage - Three Input Methods&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from marearts_anpr import ma_anpr_detector_v14, ma_anpr_ocr_v14
from marearts_anpr import marearts_anpr_from_image_file, marearts_anpr_from_cv2, marearts_anpr_from_pil
import cv2
from PIL import Image

# Initialize detector and OCR (once)
detector = ma_anpr_detector_v14(
    &quot;medium_640p_fp32&quot;,
    user_name, serial_key, signature,
    backend=&quot;cpu&quot;,
    conf_thres=0.25
)

ocr = ma_anpr_ocr_v14(&quot;medium_fp32&quot;, &quot;eup&quot;, user_name, serial_key, signature)

# Method 1: From file (easiest!)
result = marearts_anpr_from_image_file(detector, ocr, &quot;plate.jpg&quot;)
print(result)

# Method 2: From OpenCV
img = cv2.imread(&quot;plate.jpg&quot;)
result = marearts_anpr_from_cv2(detector, ocr, img)
print(result)

# Method 3: From PIL
pil_img = Image.open(&quot;plate.jpg&quot;)
result = marearts_anpr_from_pil(detector, ocr, pil_img)
print(result)
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🌍 NEW: Dynamic Region Switching (Saves 180MB!)&lt;/h3&gt;

&lt;p&gt;Previously, you needed separate OCR instances for each region. Now use &lt;code&gt;set_region()&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# Initialize once with any region
ocr = ma_anpr_ocr_v14(&quot;medium_fp32&quot;, &quot;eup&quot;, user_name, serial_key, signature)

# Switch regions instantly!
ocr.set_region(&#39;eup&#39;)   # European plates
result = marearts_anpr_from_image_file(detector, ocr, &quot;eu-plate.jpg&quot;)

ocr.set_region(&#39;kr&#39;)    # Korean plates  
result = marearts_anpr_from_image_file(detector, ocr, &quot;kr-plate.jpg&quot;)

ocr.set_region(&#39;na&#39;)    # North American plates
result = marearts_anpr_from_image_file(detector, ocr, &quot;us-plate.jpg&quot;)

ocr.set_region(&#39;cn&#39;)    # Chinese plates
ocr.set_region(&#39;univ&#39;)  # Universal
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Memory savings:&lt;/strong&gt; Single instance vs multiple = ~180MB saved per additional region!&lt;/p&gt;

&lt;h3&gt;📊 Available Regions&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;kr&lt;/code&gt; - Korean plates (123가4567)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;eup&lt;/code&gt; - European plates (EU standards)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;na&lt;/code&gt; - North American plates (USA, Canada, Mexico)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;cn&lt;/code&gt; - Chinese plates (京A·12345)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;univ&lt;/code&gt; - Universal (all regions, slightly lower accuracy)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;🎨 Batch Processing&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;# Detect plates from multiple images
img1 = cv2.imread(&quot;plate1.jpg&quot;)
img2 = cv2.imread(&quot;plate2.jpg&quot;)

detections1 = detector.detector(img1)
detections2 = detector.detector(img2)

# Collect plate crops
plates = []
for det in detections1:
    bbox = det[&#39;bbox&#39;]
    crop = img1[int(bbox[1]):int(bbox[3]), int(bbox[0]):int(bbox[2])]
    plates.append(Image.fromarray(cv2.cvtColor(crop, cv2.COLOR_BGR2RGB)))

for det in detections2:
    bbox = det[&#39;bbox&#39;]
    crop = img2[int(bbox[1]):int(bbox[3]), int(bbox[0]):int(bbox[2])]
    plates.append(Image.fromarray(cv2.cvtColor(crop, cv2.COLOR_BGR2RGB)))

# Process all plates at once!
results = ocr.predict(plates)  # Pass list of images

for i, (text, conf) in enumerate(results):
    print(f&quot;Plate {i+1}: {text} ({conf}%)&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🔧 Model Options&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Detector models:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;pico_640p_fp32&lt;/code&gt; - Smallest, fastest&lt;/li&gt;
&lt;li&gt;&lt;code&gt;micro_640p_fp32&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;small_640p_fp32&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;medium_640p_fp32&lt;/code&gt; - Recommended balance&lt;/li&gt;
&lt;li&gt;&lt;code&gt;large_640p_fp32&lt;/code&gt; - Most accurate&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;OCR models:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;pico_fp32&lt;/code&gt; - Fastest&lt;/li&gt;
&lt;li&gt;&lt;code&gt;micro_fp32&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;small_fp32&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;medium_fp32&lt;/code&gt; - Recommended&lt;/li&gt;
&lt;li&gt;&lt;code&gt;large_fp32&lt;/code&gt; - Best accuracy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Backends:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;cpu&lt;/code&gt; - Works everywhere&lt;/li&gt;
&lt;li&gt;&lt;code&gt;cuda&lt;/code&gt; - NVIDIA GPU (10-100x faster!)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;directml&lt;/code&gt; - Windows GPU&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;📝 Complete Example&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;from marearts_anpr import ma_anpr_detector_v14, ma_anpr_ocr_v14
from marearts_anpr import marearts_anpr_from_image_file
import os

# Load credentials
user_name = os.getenv(&#39;MAREARTS_ANPR_USERNAME&#39;)
serial_key = os.getenv(&#39;MAREARTS_ANPR_SERIAL_KEY&#39;)
signature = os.getenv(&#39;MAREARTS_ANPR_SIGNATURE&#39;)

# Initialize models
detector = ma_anpr_detector_v14(
    &quot;medium_640p_fp32&quot;,
    user_name, serial_key, signature,
    backend=&quot;cpu&quot;,
    conf_thres=0.25,
    iou_thres=0.5
)

ocr = ma_anpr_ocr_v14(&quot;medium_fp32&quot;, &quot;eup&quot;, user_name, serial_key, signature)

# Process European plate
print(&quot;Processing European plate...&quot;)
result = marearts_anpr_from_image_file(detector, ocr, &quot;eu-plate.jpg&quot;)
print(result)

# Switch to Korean region
ocr.set_region(&#39;kr&#39;)
print(&quot;\nProcessing Korean plate...&quot;)
result = marearts_anpr_from_image_file(detector, ocr, &quot;kr-plate.jpg&quot;)
print(result)
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;💡 Key Takeaways&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;✅ Three input methods: file, OpenCV, PIL&lt;/li&gt;
&lt;li&gt;✅ Dynamic region switching saves memory&lt;/li&gt;
&lt;li&gt;✅ Batch processing for efficiency&lt;/li&gt;
&lt;li&gt;✅ Multiple model sizes for different needs&lt;/li&gt;
&lt;li&gt;✅ GPU acceleration available&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;🔗 Try It Free!&lt;/h3&gt;

&lt;p&gt;No license yet? Try the free API (1000 requests/day):&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;ma-anpr test-api your-plate.jpg --region eup
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Happy coding! 🚗📸&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;em&gt;Labels:&lt;/em&gt;&lt;/p&gt;

</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/3912211318130371490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2025/12/marearts-anpr-v14-easy-3-method.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/3912211318130371490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/3912211318130371490'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2025/12/marearts-anpr-v14-easy-3-method.html' title='MareArts ANPR V14 - Easy 3-Method Integration (File, OpenCV, PIL)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-1073703461449443129</id><published>2025-12-30T13:43:00.000-08:00</published><updated>2025-12-30T13:43:50.038-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ANPR"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="ComputerVision"/><category scheme="http://www.blogger.com/atom/ns#" term="DeepLearning"/><category scheme="http://www.blogger.com/atom/ns#" term="FastAPI"/><category scheme="http://www.blogger.com/atom/ns#" term="HTTPServer"/><category scheme="http://www.blogger.com/atom/ns#" term="Integration"/><category scheme="http://www.blogger.com/atom/ns#" term="MachineLearning"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><category scheme="http://www.blogger.com/atom/ns#" term="VisualStudio"/><title type='text'>MareArts ANPR HTTP Server Integration - Load Once, Process Fast</title><content type='html'>&lt;h2&gt;🚀 MareArts ANPR HTTP Server - Easy Integration for Any Platform&lt;/h2&gt;

&lt;p&gt;One of the biggest challenges in ANPR (Automatic Number Plate Recognition) integration is the model loading time. Loading deep learning models can take 20+ seconds, which is impractical if you reload them for every image. Today, I&#39;m sharing our solution: a lightweight HTTP server that loads models once and processes images from memory.&lt;/p&gt;

&lt;h3&gt;📊 The Problem: Model Loading Overhead&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Model loading:&lt;/strong&gt; ~22 seconds (one time)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Image processing:&lt;/strong&gt; ~0.03 seconds per image&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Traditional approach:&lt;/strong&gt; Load models for EVERY image = slow!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Server approach:&lt;/strong&gt; Load models ONCE, process thousands of images = fast!&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;✨ The Solution: Simple HTTP Server&lt;/h3&gt;

&lt;p&gt;Our &lt;code&gt;simple_server.py&lt;/code&gt; creates a FastAPI server that:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Loads ANPR models once at startup&lt;/li&gt;
&lt;li&gt;Accepts images through 3 different methods (file upload, raw bytes, base64)&lt;/li&gt;
&lt;li&gt;Processes images directly from memory (no disk I/O)&lt;/li&gt;
&lt;li&gt;Perfect for integration with C#, Visual Studio, or any HTTP client&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;🔧 Server Implementation&lt;/h3&gt;

&lt;p&gt;Here&#39;s the core server code:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;#!/usr/bin/env python3
from fastapi import FastAPI, File, UploadFile, Request
from fastapi.responses import JSONResponse
from marearts_anpr import ma_anpr_detector_v14, ma_anpr_ocr_v14, marearts_anpr_from_cv2
import cv2
import numpy as np

# ============================================================================
# LOAD MODELS (Once at startup)
# ============================================================================

detector = ma_anpr_detector_v14(
    &quot;medium_640p_fp32&quot;, USER, KEY, SIG,
    backend=&quot;cpu&quot;,  # or &quot;cuda&quot; for GPU
    conf_thres=0.20
)

ocr = ma_anpr_ocr_v14(&quot;small_fp32&quot;, &quot;eup&quot;, USER, KEY, SIG, backend=&quot;cpu&quot;)

# ============================================================================
# CREATE SERVER
# ============================================================================

app = FastAPI(title=&quot;MareArts ANPR Server&quot;)

@app.post(&quot;/detect&quot;)
async def detect_plate_file(image: UploadFile = File(...)):
    &quot;&quot;&quot;Method 1: Upload image file (multipart/form-data)&quot;&quot;&quot;
    image_bytes = await image.read()
    return process_image_bytes(image_bytes)

@app.post(&quot;/detect/binary&quot;)
async def detect_plate_binary(request: Request):
    &quot;&quot;&quot;Method 2: Send raw image bytes&quot;&quot;&quot;
    image_bytes = await request.body()
    return process_image_bytes(image_bytes)

@app.post(&quot;/detect/base64&quot;)
async def detect_plate_base64(data: Base64Image):
    &quot;&quot;&quot;Method 3: Send base64 encoded image&quot;&quot;&quot;
    image_bytes = base64.b64decode(data.image)
    return process_image_bytes(image_bytes)

def process_image_bytes(image_bytes):
    &quot;&quot;&quot;Process image from bytes&quot;&quot;&quot;
    nparr = np.frombuffer(image_bytes, np.uint8)
    img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
    result = marearts_anpr_from_cv2(detector, ocr, img)
    return result
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;💻 Client Examples&lt;/h3&gt;

&lt;h4&gt;Python Client (test_server.py)&lt;/h4&gt;

&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import requests

def test_server(image_path, server_url=&quot;http://localhost:8000&quot;):
    # Health check
    response = requests.get(f&quot;{server_url}/health&quot;)
    print(response.json())
    
    # Detect plates
    with open(image_path, &#39;rb&#39;) as f:
        files = {&#39;image&#39;: f}
        response = requests.post(f&quot;{server_url}/detect&quot;, files=files)
    
    result = response.json()
    if result.get(&#39;results&#39;):
        print(f&quot;✅ Detected {len(result[&#39;results&#39;])} plate(s):&quot;)
        for plate in result[&#39;results&#39;]:
            print(f&quot;  • {plate[&#39;ocr&#39;]} ({plate[&#39;ocr_conf&#39;]}%)&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;cURL Command Line&lt;/h4&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Method 1: File upload
curl -X POST http://localhost:8000/detect -F &quot;image=@plate.jpg&quot;

# Method 2: Binary data
curl -X POST http://localhost:8000/detect/binary --data-binary &quot;@plate.jpg&quot;

# Health check
curl http://localhost:8000/health
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;C# / Visual Studio Integration&lt;/h4&gt;

&lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;using System.Net.Http;

// Example 1: Send raw bytes
var client = new HttpClient();
var content = new ByteArrayContent(imageBytes);
content.Headers.ContentType = new MediaTypeHeaderValue(&quot;application/octet-stream&quot;);
var response = await client.PostAsync(&quot;http://localhost:8000/detect/binary&quot;, content);

// Example 2: Send base64 JSON
var base64Image = Convert.ToBase64String(imageBytes);
var json = JsonSerializer.Serialize(new { image = base64Image });
var content = new StringContent(json, Encoding.UTF8, &quot;application/json&quot;);
var response = await client.PostAsync(&quot;http://localhost:8000/detect/base64&quot;, content);
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🎯 Usage Guide&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Install dependencies&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install marearts-anpr fastapi uvicorn python-multipart
ma-anpr config  # Configure your credentials
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Start the server&lt;/strong&gt; (Terminal 1)&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;python simple_server.py
# Models load once (~22s), then server waits for requests
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Send images&lt;/strong&gt; (Terminal 2 or your application)&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;python test_server.py your_image.jpg
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;🌟 Key Benefits&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Load Once, Use Forever:&lt;/strong&gt; Models load at startup, not per request&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Memory Processing:&lt;/strong&gt; No disk I/O, process images from RAM&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multiple Input Methods:&lt;/strong&gt; File upload, raw bytes, or base64&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cross-Platform:&lt;/strong&gt; Works with Python, C#, JavaScript, or any HTTP client&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Production Ready:&lt;/strong&gt; Built on FastAPI with async support&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Easy Integration:&lt;/strong&gt; RESTful API with JSON responses&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;📈 Performance Comparison&lt;/h3&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;First Image&lt;/th&gt;
&lt;th&gt;Subsequent Images&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Traditional (load per image)&lt;/td&gt;
&lt;td&gt;~22 seconds&lt;/td&gt;
&lt;td&gt;~22 seconds each&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTP Server (load once)&lt;/td&gt;
&lt;td&gt;~22 seconds&lt;/td&gt;
&lt;td&gt;~0.03 seconds each&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; 700x faster for subsequent images! 🚀&lt;/p&gt;

&lt;h3&gt;🔗 Available Endpoints&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;POST /detect&lt;/code&gt; - Upload file (multipart/form-data)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;POST /detect/binary&lt;/code&gt; - Send raw bytes (application/octet-stream)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;POST /detect/base64&lt;/code&gt; - Send base64 JSON&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GET /&lt;/code&gt; - Server info&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GET /health&lt;/code&gt; - Health check&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;🎓 When to Use This&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;✅ Integrating ANPR into C# / Visual Studio projects&lt;/li&gt;
&lt;li&gt;✅ Building web applications with ANPR&lt;/li&gt;
&lt;li&gt;✅ Processing multiple images efficiently&lt;/li&gt;
&lt;li&gt;✅ Microservice architecture&lt;/li&gt;
&lt;li&gt;✅ Real-time video processing&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;📦 Complete Example Package&lt;/h3&gt;

&lt;p&gt;All code is available in our SDK:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;simple_server.py&lt;/code&gt; - HTTP server (202 lines)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;test_server.py&lt;/code&gt; - Python client test (52 lines)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;README.md&lt;/code&gt; - Complete documentation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Install: &lt;code&gt;pip install marearts-anpr&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;🔐 Configuration&lt;/h3&gt;

&lt;p&gt;The server uses environment variables for credentials:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Configure once
ma-anpr config

# Credentials are stored in ~/.marearts/.marearts_env
# Server automatically loads from environment variables
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;💡 Conclusion&lt;/h3&gt;

&lt;p&gt;This HTTP server approach makes ANPR integration incredibly simple. Whether you&#39;re building a C# desktop application, a web service, or a microservice architecture, you can now integrate license plate recognition with just a few HTTP calls. No need to worry about Python integration complexity - just send HTTP requests!&lt;/p&gt;

&lt;p&gt;The key insight: &lt;strong&gt;separate model loading from image processing&lt;/strong&gt;. Load once, process thousands of times.&lt;/p&gt;

&lt;p&gt;Happy coding! 🚗📸&lt;/p&gt;

</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/1073703461449443129/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2025/12/marearts-anpr-http-server-integration.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/1073703461449443129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/1073703461449443129'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2025/12/marearts-anpr-http-server-integration.html' title='MareArts ANPR HTTP Server Integration - Load Once, Process Fast'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-4077435025860372390</id><published>2025-12-16T01:46:00.000-08:00</published><updated>2025-12-16T01:46:13.014-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++20"/><category scheme="http://www.blogger.com/atom/ns#" term="consteval"/><category scheme="http://www.blogger.com/atom/ns#" term="constexpr"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><title type='text'>Shows difference between functions, concepts, and constexpr variables</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;.&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// study.marearts.com: When to use () and when not to in C++&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Shows difference between functions, concepts, and constexpr variables&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #9b9b9b;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d69d85;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #9b9b9b;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d69d85;&quot;&gt;&amp;lt;concepts&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// CASE 1: FUNCTION - NEEDS ()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Regular function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;isPositiveFunction&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #7f7f7f;&quot;&gt;x&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt; x &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// constexpr function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;isPositiveConstexpr&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #7f7f7f;&quot;&gt;x&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt; x &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// consteval function (C++20)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;consteval&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;IsIntegerFunction&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::is_integral_v&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example1&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;\n=== CASE 1: FUNCTIONS - MUST USE () ===&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;caret-color: rgb(87, 166, 74); color: #57a64a;&quot;&gt;study.marearts.com&lt;/span&gt;&lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Functions NEED ()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #c8c8c8;&quot;&gt;isPositiveFunction&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;)) {&lt;span style=&quot;color: #57a64a;&quot;&gt;  // ← () required&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;✓ 5 is positive (function call)&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; (&lt;span style=&quot;color: #c8c8c8;&quot;&gt;IsIntegerFunction&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;()) {&lt;span style=&quot;color: #57a64a;&quot;&gt;  // ← () required&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;✓ int is integer (consteval function call)&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // ❌ This would be ERROR:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // if (isPositiveFunction) { }  // ERROR: can&#39;t use function without calling it&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// CASE 2: CONCEPT - NO ()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Concept (C++20)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;concept&lt;/span&gt; IsInteger &lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::is_integral_v&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example2&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;\n=== CASE 2: CONCEPTS - NO () ===&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;caret-color: rgb(87, 166, 74); color: #57a64a;&quot;&gt;study.marearts.com&lt;/span&gt;&lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Concepts don&#39;t use ()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; (IsInteger&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;) {&lt;span style=&quot;color: #57a64a;&quot;&gt;  // ← NO () - it&#39;s a concept, not function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;✓ int is integer (concept check)&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // ❌ This would be ERROR:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // if constexpr (IsInteger&amp;lt;int&amp;gt;()) { }  // ERROR: concept is not a function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// CASE 3: CONSTEXPR VARIABLE - NO ()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// constexpr variable&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;bool&lt;/span&gt; is_integer_variable &lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::is_integral_v&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example3&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;\n=== CASE 3: CONSTEXPR VARIABLES - NO () ===&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;caret-color: rgb(87, 166, 74); color: #57a64a;&quot;&gt;study.marearts.com&lt;/span&gt;&lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // constexpr variables don&#39;t use ()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; (is_integer_variable&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;) {&lt;span style=&quot;color: #57a64a;&quot;&gt;  // ← NO () - it&#39;s a variable, not function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;✓ int is integer (constexpr variable)&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // ❌ This would be ERROR:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // if constexpr (is_integer_variable&amp;lt;int&amp;gt;()) { }  // ERROR: variable is not callable&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// COMPARISON IN SAME CONTEXT&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// All three doing the same thing, different ways:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;consteval&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;IsPositiveFunction&lt;/span&gt;() { &lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(T) &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; }&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Function&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;concept&lt;/span&gt; IsPositiveConcept &lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(T) &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Concept&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;bool&lt;/span&gt; is_positive_variable &lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(T) &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Variable&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example4&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;\n=== COMPARISON: FUNCTION vs CONCEPT vs VARIABLE ===&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;caret-color: rgb(87, 166, 74); color: #57a64a;&quot;&gt;study.marearts.com&lt;/span&gt;&lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Function needs ()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; (&lt;span style=&quot;color: #c8c8c8;&quot;&gt;IsPositiveFunction&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;()) {&lt;span style=&quot;color: #57a64a;&quot;&gt;  // ← () YES&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;✓ Function: use ()&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Concept doesn&#39;t use ()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; (IsPositiveConcept&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;) {&lt;span style=&quot;color: #57a64a;&quot;&gt;  // ← () NO&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;✓ Concept: no ()&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Variable doesn&#39;t use ()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; (is_positive_variable&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;) {&lt;span style=&quot;color: #57a64a;&quot;&gt;  // ← () NO&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;✓ Variable: no ()&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// DISPATCHER PATTERN EXAMPLE&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Like CK Builder dispatcher!&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Old way: consteval functions (need ())&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;consteval&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;IsSpecialAlgorithmFunction&lt;/span&gt;() { &lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(T) &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// New way: concepts (no ())&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;concept&lt;/span&gt; IsSpecialAlgorithmConcept &lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(T) &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;dispatch_old_way&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; (&lt;span style=&quot;color: #c8c8c8;&quot;&gt;IsSpecialAlgorithmFunction&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;T&lt;/span&gt;&amp;gt;()) {&lt;span style=&quot;color: #57a64a;&quot;&gt;  // ← () YES (function)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;Old dispatcher: Special algorithm (function)&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;else&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;Old dispatcher: Normal algorithm&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;dispatch_new_way&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; (IsSpecialAlgorithmConcept&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;) {&lt;span style=&quot;color: #57a64a;&quot;&gt;  // ← () NO (concept)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;New dispatcher: Special algorithm (concept)&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;else&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;New dispatcher: Normal algorithm&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example5&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;\n=== DISPATCHER PATTERN (Like CK Builder) ===&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;dispatch_old_way&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt;&amp;gt;();&lt;span style=&quot;color: #57a64a;&quot;&gt;   // Old way with functions&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;dispatch_new_way&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt;&amp;gt;();&lt;span style=&quot;color: #57a64a;&quot;&gt;   // New way with concepts&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// MAIN&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;main&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;=== When to Use () in C++ ===&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;caret-color: rgb(87, 166, 74); color: #57a64a;&quot;&gt;study.marearts.com&lt;/span&gt;&lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example1&lt;/span&gt;();&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Functions&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example2&lt;/span&gt;();&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Concepts&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example3&lt;/span&gt;();&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Variables&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example4&lt;/span&gt;();&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Comparison&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example5&lt;/span&gt;();&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Dispatcher pattern&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;\n=== SUMMARY ===&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;FUNCTION:   Use ()  → IsXXX&amp;lt;T&amp;gt;()&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;CONCEPT:    No ()   → IsXXX&amp;lt;T&amp;gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;VARIABLE:   No ()   → is_xxx&amp;lt;T&amp;gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::endl;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;TO COMPILE:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;g++ -std=c++20 when_to_use_parentheses.cpp -o when_to_use_parentheses&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;./when_to_use_parentheses&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;OUTPUT:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;Functions need ()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;Concepts don&#39;t need ()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;Variables don&#39;t need ()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;*/&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;..&lt;/p&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## Compile-Time vs Runtime&quot; data-section-index=&quot;1&quot; id=&quot;markdown-section-894dc136-1568-43ea-a8ce-94cf357a70f3-1&quot; style=&quot;background-color: #252526; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Compile&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;-Time vs Runtime&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;div class=&quot;monaco-scrollable-element  mac&quot; role=&quot;presentation&quot; style=&quot;background-color: #252526; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; margin: 1em 0px; orphans: 2; overflow: hidden; position: relative; scrollbar-width: none; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2; width: 910.013px;&quot;&gt;&lt;div style=&quot;overflow: hidden;&quot;&gt;&lt;table class=&quot;markdown-table&quot; style=&quot;border-collapse: collapse; font-size: inherit;&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; text-align: left; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;Feature&lt;/span&gt;&lt;/th&gt;&lt;th style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; text-align: left; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;When&amp;nbsp;Evaluated&lt;/span&gt;&lt;/th&gt;&lt;th style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; text-align: left; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;Use&amp;nbsp;Case&lt;/span&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;font-weight: 600;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; line-height: 1.4; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;concept&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;✅&amp;nbsp;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;font-weight: 600;&quot;&gt;Compile-time&amp;nbsp;ONLY&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;Type&amp;nbsp;constraints&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;font-weight: 600;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; line-height: 1.4; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;constexpr&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;⚠️&amp;nbsp;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;font-weight: 600;&quot;&gt;Compile OR&amp;nbsp;runtime&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;Flexible&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;font-weight: 600;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; line-height: 1.4; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;consteval&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;✅&amp;nbsp;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;font-weight: 600;&quot;&gt;Compile-time&amp;nbsp;ONLY&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;Force&amp;nbsp;compile-time&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;bottom: 0px; color: #d4d4d4; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 910px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 910px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;color: #d4d4d4; height: 130px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 130px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 10px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

### 1. Concept - Always Compile Time ✅&quot; data-section-index=&quot;4&quot; id=&quot;markdown-section-894dc136-1568-43ea-a8ce-94cf357a70f3-4&quot; style=&quot;background-color: #252526; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h3 style=&quot;animation: 0.25s fade-in; font-size: 1.15em; line-height: 1.25; margin-bottom: 8px; margin-top: 18px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;. Concept&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;- Always&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;Compile Time&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;✅&lt;/span&gt;&lt;/h3&gt;&lt;/section&gt;&lt;p&gt;template &amp;lt;typename T&amp;gt;&lt;/p&gt;&lt;p&gt;concept IsInteger = std::is_integral_v&amp;lt;T&amp;gt;;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;// Checked at COMPILE TIME:&lt;/p&gt;&lt;p&gt;if constexpr (IsInteger&amp;lt;int&amp;gt;) { &amp;nbsp;// ← Compiler checks this&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; // This code exists in binary&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;else {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; // This code REMOVED from binary&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
**Compiler decides** which branch to include in the compiled program.&quot; data-section-index=&quot;7&quot; id=&quot;markdown-section-894dc136-1568-43ea-a8ce-94cf357a70f3-7&quot; style=&quot;background-color: #252526; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Compiler&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;decides&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;which&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;branch&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;to include&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;in&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;the compile&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;d program&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;.&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

### 2. constexpr - Can Be Either&quot; data-section-index=&quot;8&quot; id=&quot;markdown-section-894dc136-1568-43ea-a8ce-94cf357a70f3-8&quot; style=&quot;background-color: #252526; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h3 style=&quot;animation: 0.25s fade-in; font-size: 1.15em; line-height: 1.25; margin-bottom: 8px; margin-top: 18px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;2. const&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;expr - Can&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;Be Either&lt;/span&gt;&lt;/h3&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```cpp
constexpr int add(int a, int b) {
    return a + b;
}

// COMPILE TIME:
constexpr int result1 = add(5, 3);  // ← Computed during compilation
static_assert(result1 == 8);         // ← Can use in static_assert

// RUNTIME:
int x = getUserInput();
int result2 = add(x, 3);  // ← Computed during program execution
```&quot; data-section-index=&quot;9&quot; id=&quot;markdown-section-894dc136-1568-43ea-a8ce-94cf357a70f3-9&quot; style=&quot;background-color: #252526; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;a1f86a02-af95-4a4f-971a-64933ec317cc&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px !important; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 219.661px; width: 322.012px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-radius: 8px; border: 0.833333px solid color(srgb 0.8 0.8 0.8 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #1e1e1e; animation: auto !important; background: 0% 0% repeat rgb(30, 30, 30); box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;2892&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto !important; height: 210px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac  showUnused showDeprecated vs-dark&quot; data-uri=&quot;composer-code-block-anysphere://gadmlypuci&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto !important; height: 210px; overflow-wrap: normal; overflow: visible; position: relative; width: 308px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto !important; height: 210px; overflow: hidden; position: relative; width: 308px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto !important; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 29px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor !important; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 150px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot; wrap=&quot;off&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto !important; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; contain: strict; height: 210px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto !important; height: 210px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 210px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 78px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 96px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 114px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 132px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 150px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto !important; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 168px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 186px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto !important; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto !important; height: 210px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 308px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto !important; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 519px;&quot;&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 518.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 518.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 42px; width: 518.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 60px; width: 518.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 78px; width: 518.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 96px; width: 518.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 114px; width: 518.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 132px; width: 518.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 150px; width: 518.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 168px; width: 518.997px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 186px; width: 518.997px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 210px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 519px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 518.997px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk17&quot; style=&quot;animation: auto !important; color: #c8c8c8;&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk23&quot; style=&quot;animation: auto !important; color: #7f7f7f;&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk23&quot; style=&quot;animation: auto !important; color: #7f7f7f;&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 518.997px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;a&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;b;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 42px; width: 518.997px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 60px; width: 518.997px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto !important;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 78px; width: 518.997px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;//&amp;nbsp;COMPILE&amp;nbsp;TIME:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 96px; width: 518.997px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;result1&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk17&quot; style=&quot;animation: auto !important; color: #c8c8c8;&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto !important; color: #b5cea8;&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto !important; color: #b5cea8;&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;←&amp;nbsp;Computed&amp;nbsp;during&amp;nbsp;compilation&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 114px; width: 518.997px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;static_assert&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;(result1&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto !important; color: #b5cea8;&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;←&amp;nbsp;Can&amp;nbsp;use&amp;nbsp;in&amp;nbsp;static_assert&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 132px; width: 518.997px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto !important;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 150px; width: 518.997px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;//&amp;nbsp;RUNTIME:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 168px; width: 518.997px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;x&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk17&quot; style=&quot;animation: auto !important; color: #c8c8c8;&quot;&gt;getUserInput&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 186px; width: 518.997px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;result2&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk17&quot; style=&quot;animation: auto !important; color: #c8c8c8;&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;(x,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto !important; color: #b5cea8;&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;←&amp;nbsp;Computed&amp;nbsp;during&amp;nbsp;program&amp;nbsp;execution&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto !important; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor  monaco-mouse-cursor-text &quot; style=&quot;animation: auto !important; background-color: #aeafad; border-color: rgb(174, 175, 173); box-sizing: border-box; color: #515052; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 29px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 150px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; bottom: 0px; height: 6px; left: 0px; opacity: 0 !important; pointer-events: none; position: absolute; transition: opacity 0.8s linear; visibility: hidden; width: 308px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 182px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; box-shadow: none; height: 210px; opacity: 0 !important; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 210px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; width: 308px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto !important; left: 0px; position: absolute; top: 0px; width: 308px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; height: 210px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto !important; height: 210px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;504&quot; style=&quot;animation: auto !important; height: 210px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;504&quot; style=&quot;animation: auto !important; height: 210px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto !important; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto !important; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(30, 30, 30) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto !important; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto !important; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center  &quot; style=&quot;align-items: center; animation: auto !important; border-style: none; color: #cccccc; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
**Compiler decides** based on context!&quot; data-section-index=&quot;11&quot; id=&quot;markdown-section-894dc136-1568-43ea-a8ce-94cf357a70f3-11&quot; style=&quot;background-color: #252526; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;Compiler decides&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;base&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;d on context&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;!&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

### 3. consteval - MUST Be Compile Time ✅&quot; data-section-index=&quot;12&quot; id=&quot;markdown-section-894dc136-1568-43ea-a8ce-94cf357a70f3-12&quot; style=&quot;background-color: #252526; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h3 style=&quot;animation: 0.25s fade-in; font-size: 1.15em; line-height: 1.25; margin-bottom: 8px; margin-top: 18px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;3. consteval&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;- MUST Be Compile Time&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;✅&lt;/span&gt;&lt;/h3&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```cpp
consteval int square(int x) {
    return x * x;
}

// COMPILE TIME:
constexpr int result = square(5);  // ✅ OK - computed at compile time

// RUNTIME:
int x = getUserInput();
int result2 = square(x);  // ❌ ERROR! consteval can&#39;t run at runtime
```&quot; data-section-index=&quot;13&quot; id=&quot;markdown-section-894dc136-1568-43ea-a8ce-94cf357a70f3-13&quot; style=&quot;background-color: #252526; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;5db5f807-af46-400e-b01d-f289aa38f4ab&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px !important; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 201.66px; width: 322.012px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-radius: 8px; border: 0.833333px solid color(srgb 0.8 0.8 0.8 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #1e1e1e; animation: auto !important; background: 0% 0% repeat rgb(30, 30, 30); box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;2893&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto !important; height: 192px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac  showUnused showDeprecated vs-dark&quot; data-uri=&quot;composer-code-block-anysphere://kqfduxbsvz&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto !important; height: 192px; overflow-wrap: normal; overflow: visible; position: relative; width: 308px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto !important; height: 192px; overflow: hidden; position: relative; width: 308px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto !important; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor !important; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot; wrap=&quot;off&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto !important; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; contain: strict; height: 192px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto !important; height: 192px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 192px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto !important; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 78px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 96px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 114px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 132px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 150px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 168px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto !important; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto !important; height: 192px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 308px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto !important; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 531px;&quot;&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 530.996px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 530.996px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 42px; width: 530.996px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 60px; width: 530.996px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 78px; width: 530.996px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 96px; width: 530.996px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 114px; width: 530.996px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 132px; width: 530.996px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 150px; width: 530.996px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 168px; width: 530.996px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 192px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 531px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 530.996px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;consteval&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk17&quot; style=&quot;animation: auto !important; color: #c8c8c8;&quot;&gt;square&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk23&quot; style=&quot;animation: auto !important; color: #7f7f7f;&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 530.996px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;x&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;x;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 42px; width: 530.996px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 60px; width: 530.996px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto !important;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 78px; width: 530.996px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;//&amp;nbsp;COMPILE&amp;nbsp;TIME:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 96px; width: 530.996px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;result&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk17&quot; style=&quot;animation: auto !important; color: #c8c8c8;&quot;&gt;square&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto !important; color: #b5cea8;&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;✅&amp;nbsp;OK&amp;nbsp;-&amp;nbsp;computed&amp;nbsp;at&amp;nbsp;compile&amp;nbsp;time&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 114px; width: 530.996px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto !important;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 132px; width: 530.996px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;//&amp;nbsp;RUNTIME:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 150px; width: 530.996px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;x&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk17&quot; style=&quot;animation: auto !important; color: #c8c8c8;&quot;&gt;getUserInput&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 168px; width: 530.996px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk5&quot; style=&quot;animation: auto !important; color: #569cd6;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;result2&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk17&quot; style=&quot;animation: auto !important; color: #c8c8c8;&quot;&gt;square&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;(x);&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;❌&amp;nbsp;ERROR!&amp;nbsp;consteval&amp;nbsp;can&#39;t&amp;nbsp;run&amp;nbsp;at&amp;nbsp;runtime&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto !important; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor  monaco-mouse-cursor-text &quot; style=&quot;animation: auto !important; background-color: #aeafad; border-color: rgb(174, 175, 173); box-sizing: border-box; color: #515052; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; bottom: 0px; height: 6px; left: 0px; opacity: 0 !important; pointer-events: none; position: absolute; transition: opacity 0.8s linear; visibility: hidden; width: 308px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 178px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; box-shadow: none; height: 192px; opacity: 0 !important; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 192px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; width: 308px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto !important; left: 0px; position: absolute; top: 0px; width: 308px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; height: 192px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto !important; height: 192px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;460&quot; style=&quot;animation: auto !important; height: 192px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;460&quot; style=&quot;animation: auto !important; height: 192px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto !important; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto !important; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(30, 30, 30) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto !important; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto !important; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center  &quot; style=&quot;align-items: center; animation: auto !important; border-style: none; color: #cccccc; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;p&gt;&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/4077435025860372390/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2025/12/shows-difference-between-functions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/4077435025860372390'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/4077435025860372390'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2025/12/shows-difference-between-functions.html' title='Shows difference between functions, concepts, and constexpr variables'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-745331514990387276</id><published>2025-12-15T05:51:00.000-08:00</published><updated>2025-12-15T05:51:20.599-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="c++ 20"/><category scheme="http://www.blogger.com/atom/ns#" term="comma operator"/><category scheme="http://www.blogger.com/atom/ns#" term="consteval"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><title type='text'>C++20, consteval and comma operator example code</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;.&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// (study.&lt;/span&gt;&lt;span style=&quot;caret-color: rgb(214, 157, 133); color: #d69d85;&quot;&gt;marearts.com)&lt;/span&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;: Compile-time Validation Pattern with consteval + static_assert&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// C++20 required for consteval&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #9b9b9b;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d69d85;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// EXAMPLE 1: Simple consteval function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// consteval = MUST run at compile time (C++20 feature)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;consteval&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;add&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #7f7f7f;&quot;&gt;a&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #7f7f7f;&quot;&gt;b&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #7f7f7f;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #7f7f7f;&quot;&gt;b&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example1&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // This is evaluated at COMPILE TIME!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;result&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;add&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;);&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Compiler computes: 5 + 3 = 8&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;(study.&lt;/span&gt;&lt;span style=&quot;caret-color: rgb(214, 157, 133); color: #d69d85;&quot;&gt;marearts.com) &lt;/span&gt;&lt;span style=&quot;color: #d69d85;&quot;&gt;Example 1 : 5 + 3 = &quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;result&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// EXAMPLE 2: Comma operator&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;printMessage&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;Message printed!&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Returns nothing (void)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example2&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Comma operator: (A, B) evaluates A, then returns B&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;x&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #c8c8c8;&quot;&gt;printMessage&lt;/span&gt;()&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;42&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    //       ↓                ↓&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    //   Calls function    Returns 42&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;(study.&lt;/span&gt;&lt;span style=&quot;caret-color: rgb(214, 157, 133); color: #d69d85;&quot;&gt;marearts.com) &lt;/span&gt;&lt;span style=&quot;color: #d69d85;&quot;&gt;Example 2: x = &quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;x&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;endl&lt;/span&gt;;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // x = 42&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// EXAMPLE 3: consteval with static_assert (VALIDATION!)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Validation function - checks if number is positive&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;N&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;consteval&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;ValidatePositive&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;static_assert&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;N&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;ERROR: Number must be positive!&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // If N &amp;lt;= 0, compilation FAILS here with error message&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // If N &amp;gt; 0, function completes&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Example struct that validates its template parameter&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Number&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;PositiveNumber&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // This line forces validation at compile time!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // If Number is negative, compilation fails&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;auto&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;kValidation&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #c8c8c8;&quot;&gt;ValidatePositive&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Number&lt;/span&gt;&amp;gt;()&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    //                                   ↓                           ↓&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    //                           Run checks (compile time)      Return 0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dadada;&quot;&gt;value&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Number&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;print&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;Positive number: &quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dadada;&quot;&gt;value&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example3&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;\n&lt;/span&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;(study.&lt;/span&gt;&lt;span style=&quot;caret-color: rgb(214, 157, 133); color: #d69d85;&quot;&gt;marearts.com) &lt;/span&gt;&lt;span style=&quot;color: #d69d85;&quot;&gt;Example 3: Compile-time validation&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // ✅ This COMPILES (5 &amp;gt; 0)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #4ec9b0;&quot;&gt;PositiveNumber&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;good&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;good&lt;/span&gt;.&lt;span style=&quot;color: #c8c8c8;&quot;&gt;print&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // ❌ This would FAIL to compile (uncomment to see error!)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // PositiveNumber&amp;lt;-3&amp;gt; bad;  &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Error: static assertion failed: ERROR: Number must be positive!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;✓ Validation passed at compile time!&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// EXAMPLE 4: Real-world pattern (like our code!)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;enum&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;OperationType&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #b8d7a3;&quot;&gt;PASS_THROUGH&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #b8d7a3;&quot;&gt;ADD_ONE&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #b8d7a3;&quot;&gt;MULTIPLY_TWO&lt;/span&gt;&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Configuration struct (like our ConvSignature)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;OperationType&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Op&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Config&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;OperationType&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;operation&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Op&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Validation: Only allow PASS_THROUGH&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;auto&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Cfg&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;consteval&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;ValidateConfig&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;static_assert&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Cfg&lt;/span&gt;.&lt;span style=&quot;color: #dadada;&quot;&gt;operation&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;OperationType&lt;/span&gt;::&lt;span style=&quot;color: #b8d7a3;&quot;&gt;PASS_THROUGH&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;                  &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;ERROR: Simple implementation only supports PASS_THROUGH!&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Simple implementation (like our ReferenceForwardFactory)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;auto&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;CONFIG&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;SimpleProcessor&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Validate at compile time!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;auto&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;kValidation&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #c8c8c8;&quot;&gt;ValidateConfig&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;CONFIG&lt;/span&gt;&amp;gt;()&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;process&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #7f7f7f;&quot;&gt;x&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;Processing &quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #7f7f7f;&quot;&gt;x&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot; (PassThrough only)&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example4&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;\nExample 4: Real-world validation pattern&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // ✅ This COMPILES (uses PASS_THROUGH)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Config&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;OperationType&lt;/span&gt;::&lt;span style=&quot;color: #b8d7a3;&quot;&gt;PASS_THROUGH&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;good_config&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    SimpleProcessor&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;good_config&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;processor&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;processor&lt;/span&gt;.&lt;span style=&quot;color: #c8c8c8;&quot;&gt;process&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;42&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // ❌ This would FAIL to compile (uncomment to see error!)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // constexpr Config&amp;lt;OperationType::ADD_ONE&amp;gt; bad_config;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // SimpleProcessor&amp;lt;bad_config&amp;gt; bad_processor;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Error: static assertion failed: Simple implementation only supports PASS_THROUGH!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;✓ Config validation passed!&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// MAIN&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;main&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;=== Compile-Time Validation Study ===&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example1&lt;/span&gt;();&lt;span style=&quot;color: #57a64a;&quot;&gt;  // consteval basics&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example2&lt;/span&gt;();&lt;span style=&quot;color: #57a64a;&quot;&gt;  // comma operator&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example3&lt;/span&gt;();&lt;span style=&quot;color: #57a64a;&quot;&gt;  // consteval + static_assert&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;example4&lt;/span&gt;();&lt;span style=&quot;color: #57a64a;&quot;&gt;  // real-world pattern&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d69d85;&quot;&gt;&quot;\n✓ All examples passed!&quot;&lt;/span&gt; &lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #c8c8c8;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #c8c8c8;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;p&gt;..&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;KEY CONCEPTS:&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;1. consteval (C++20):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;   - Function MUST execute at compile time&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;   - Cannot be called at runtime&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;2. static_assert (C++11):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;   - Checks condition at compile time&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;   - If false, compilation FAILS with error message&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;3. Comma operator:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;   - (A, B) executes A, then returns B&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;   - Used to &quot;call void function&quot; in member initialization&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;4. The Pattern:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;   static constexpr auto kValidation = (ValidateFunction&amp;lt;&amp;gt;(), 0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;   - Forces compile-time validation&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;   - Returns 0 if validation passes&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;   - Compilation fails if validation fails&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;TO COMPILE:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;g++ -std=c++20 compile_time_validation.cpp -o compile_time_validation&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;./compile_time_validation&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;pre style=&quot;background-color: #1e1e1e; color: color(srgb 0.8 0.8 0.8 / 0.6); font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; font-variant-ligatures: normal; line-height: 18px; margin: 0px; orphans: 2; padding: 0px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-wrap-mode: wrap; widows: 2; word-break: break-all;&quot;&gt;=== Compile-Time Validation Study ===
Example 1: 5 + 3 = 8
Message printed!
Example 2: x = 42

Example 3: Compile-time validation
Positive number: 5
✓ Validation passed at compile time!

Example 4: Real-world validation pattern
Processing 42 (PassThrough only)
✓ Config validation passed!

✓ All examples passed!&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## Summary: C++ Version Requirements&quot; data-section-index=&quot;1&quot; id=&quot;markdown-section-cef777e5-0536-4f93-9fa0-04eac9a79d27-1&quot; style=&quot;background-color: #1e1e1e; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Summary&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;: C&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;++ Version&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;Requirements&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;div class=&quot;monaco-scrollable-element  mac&quot; role=&quot;presentation&quot; style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; margin: 1em 0px; orphans: 2; overflow: hidden; position: relative; scrollbar-width: none; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2; width: 577.012px;&quot;&gt;&lt;div style=&quot;overflow: hidden;&quot;&gt;&lt;table class=&quot;markdown-table&quot; style=&quot;border-collapse: collapse; font-size: inherit;&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; text-align: left; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;Feature&lt;/span&gt;&lt;/th&gt;&lt;th style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; text-align: left; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;C++ Version&lt;/span&gt;&lt;/th&gt;&lt;th style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; text-align: left; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;What&amp;nbsp;It&amp;nbsp;Does&lt;/span&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;font-weight: 600;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; line-height: 1.4; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;consteval&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;font-weight: 600;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;C++20&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;Function&amp;nbsp;MUST run&amp;nbsp;at compile time&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;font-weight: 600;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; line-height: 1.4; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;static_assert&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;font-weight: 600;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;C++11&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;Compile-time assertion check&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;font-weight: 600;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; line-height: 1.4; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;constexpr&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;font-weight: 600;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;C++11&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;CAN run&amp;nbsp;at compile time&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;font-weight: 600;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;Comma operator&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;font-weight: 600;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;C++98&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(69, 69, 69); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; line-height: 1.4; word-break: break-all;&quot;&gt;(A, B)&lt;/span&gt;&amp;nbsp;returns B&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 577px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 577px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;height: 162px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 162px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 10px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
**Our pattern needs:** **C++20** (for `consteval`)&quot; data-section-index=&quot;4&quot; id=&quot;markdown-section-cef777e5-0536-4f93-9fa0-04eac9a79d27-4&quot; style=&quot;background-color: #1e1e1e; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Our&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;pattern&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;needs&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;C++20&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;(for&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.27451 0.27451 0.27451 / 0.52); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;consteval&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;)&lt;/span&gt;&lt;/section&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## Quick Reference&quot; data-section-index=&quot;5&quot; id=&quot;markdown-section-cef777e5-0536-4f93-9fa0-04eac9a79d27-5&quot; style=&quot;background-color: #1e1e1e; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Quick Reference&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

### ✅ Good Case (Passes):
```cpp
PositiveNumber&amp;lt;5&amp;gt; good;
// ValidatePositive&amp;lt;5&amp;gt;() runs → 5 &amp;gt; 0 ✓ → Returns 0 → Compiles ✓
```&quot; data-section-index=&quot;6&quot; id=&quot;markdown-section-cef777e5-0536-4f93-9fa0-04eac9a79d27-6&quot; style=&quot;background-color: #1e1e1e; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h3 style=&quot;animation: 0.25s fade-in; font-size: 1.15em; line-height: 1.25; margin-bottom: 8px; margin-top: 18px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;✅ Goo&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;d Case (Passes&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&lt;/span&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;53d1ca0c-65ee-4642-8439-c7c1b7627346&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px !important; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 57.6562px; width: 577.012px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-radius: 8px; border: 0.833333px solid color(srgb 0.8 0.8 0.8 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #1e1e1e; animation: auto !important; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;1702&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto !important; height: 48px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac  showUnused showDeprecated vs-dark&quot; data-uri=&quot;composer-code-block-anysphere://tzwkaytljq&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto !important; height: 48px; overflow-wrap: normal; overflow: visible; position: relative; width: 563px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto !important; height: 48px; overflow: hidden; position: relative; width: 563px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto !important; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 166px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor !important; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot; wrap=&quot;off&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto !important; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; contain: strict; height: 48px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 48px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto !important; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto !important; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto !important; height: 48px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 563px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto !important; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 563px;&quot;&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 562.995px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 562.995px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 48px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 563px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 562.995px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;PositiveNumber&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto !important; color: #b5cea8;&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;good;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 562.995px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;//&amp;nbsp;ValidatePositive&amp;lt;5&amp;gt;()&amp;nbsp;runs&amp;nbsp;→&amp;nbsp;5&amp;nbsp;&amp;gt;&amp;nbsp;0&amp;nbsp;✓&amp;nbsp;→&amp;nbsp;Returns&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;0&amp;nbsp;→&amp;nbsp;Compiles&amp;nbsp;✓&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto !important; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor  monaco-mouse-cursor-text &quot; style=&quot;animation: auto !important; background-color: #aeafad; border-color: rgb(174, 175, 173); box-sizing: border-box; color: #515052; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 166px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; bottom: 0px; height: 6px; left: 0px; opacity: 0 !important; pointer-events: none; position: absolute; visibility: hidden; width: 563px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 563px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; box-shadow: none; height: 48px; opacity: 0 !important; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 48px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; width: 563px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto !important; left: 0px; position: absolute; top: 0px; width: 563px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto !important; height: 48px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;115&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;115&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto !important; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto !important; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(30, 30, 30) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto !important; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto !important; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center  &quot; style=&quot;align-items: center; animation: auto !important; border-style: none; color: #cccccc; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h3&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

### ❌ Bad Case (Fails):
```cpp
PositiveNumber&amp;lt;-3&amp;gt; bad;
// ValidatePositive&amp;lt;-3&amp;gt;() runs → -3 &amp;gt; 0 ✗ → ERROR! Stops compilation ❌
```&quot; data-section-index=&quot;7&quot; id=&quot;markdown-section-cef777e5-0536-4f93-9fa0-04eac9a79d27-7&quot; style=&quot;background-color: #1e1e1e; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h3 style=&quot;animation: 0.25s fade-in; font-size: 1.15em; line-height: 1.25; margin-bottom: 8px; margin-top: 18px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;❌ Bad Case&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;(Fails):&lt;/span&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;d3392a62-09cd-4148-b6ed-f1cb6c1b5dc1&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px !important; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 57.6562px; width: 577.012px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-radius: 8px; border: 0.833333px solid color(srgb 0.8 0.8 0.8 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #1e1e1e; animation: auto !important; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;1703&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto !important; height: 48px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac  showUnused showDeprecated vs-dark&quot; data-uri=&quot;composer-code-block-anysphere://wtowrdrjcv&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto !important; height: 48px; overflow-wrap: normal; overflow: visible; position: relative; width: 563px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto !important; height: 48px; overflow: hidden; position: relative; width: 563px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto !important; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor !important; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot; wrap=&quot;off&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto !important; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; contain: strict; height: 48px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 48px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto !important; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto !important; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto !important; height: 48px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 563px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto !important; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 563px;&quot;&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 562.995px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 562.995px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 48px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 563px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 562.995px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;PositiveNumber&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto !important; color: #b5cea8;&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;good;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 562.995px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;//&amp;nbsp;ValidatePositive&amp;lt;5&amp;gt;()&amp;nbsp;runs&amp;nbsp;→&amp;nbsp;5&amp;nbsp;&amp;gt;&amp;nbsp;0&amp;nbsp;✓&amp;nbsp;→&amp;nbsp;Returns&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;0&amp;nbsp;→&amp;nbsp;Compiles&amp;nbsp;✓&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto !important; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor  monaco-mouse-cursor-text &quot; style=&quot;animation: auto !important; background-color: #aeafad; border-color: rgb(174, 175, 173); box-sizing: border-box; color: #515052; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; bottom: 0px; height: 6px; left: 0px; opacity: 0 !important; pointer-events: none; position: absolute; visibility: hidden; width: 563px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 563px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; box-shadow: none; height: 48px; opacity: 0 !important; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 48px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; width: 563px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto !important; left: 0px; position: absolute; top: 0px; width: 563px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto !important; height: 48px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;115&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;115&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto !important; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto !important; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(30, 30, 30) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto !important; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto !important; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center  &quot; style=&quot;align-items: center; animation: auto !important; border-style: none; color: #cccccc; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h3&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## To Experiment&quot; data-section-index=&quot;8&quot; id=&quot;markdown-section-cef777e5-0536-4f93-9fa0-04eac9a79d27-8&quot; style=&quot;background-color: #1e1e1e; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;To&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;Experiment&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
**Try uncommenting line 75 in the study file:**&quot; data-section-index=&quot;10&quot; id=&quot;markdown-section-cef777e5-0536-4f93-9fa0-04eac9a79d27-10&quot; style=&quot;background-color: #1e1e1e; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Try&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;uncomm&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;enting line&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;75&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;in the&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;study&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;file&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
```cpp
PositiveNumber&amp;lt;-3&amp;gt; bad;  // Uncomment this line
```&quot; data-section-index=&quot;11&quot; id=&quot;markdown-section-cef777e5-0536-4f93-9fa0-04eac9a79d27-11&quot; style=&quot;background-color: #1e1e1e; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;b2c377d0-85ab-49a0-87d5-0c395961190b&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px !important; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 57.6562px; width: 577.012px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-radius: 8px; border: 0.833333px solid color(srgb 0.8 0.8 0.8 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #1e1e1e; animation: auto !important; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;1704&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto !important; height: 48px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac  showUnused showDeprecated vs-dark&quot; data-uri=&quot;composer-code-block-anysphere://ohheerixve&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto !important; height: 48px; overflow-wrap: normal; overflow: visible; position: relative; width: 563px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto !important; height: 48px; overflow: hidden; position: relative; width: 563px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto !important; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor !important; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot; wrap=&quot;off&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto !important; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; contain: strict; height: 48px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 48px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto !important; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto !important; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto !important; height: 48px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 563px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto !important; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 563px;&quot;&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 562.995px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 562.995px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 48px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 563px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 562.995px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;PositiveNumber&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto !important; color: #b5cea8;&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk16&quot; style=&quot;animation: auto !important; color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;bad;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 24px; width: 562.995px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;//&amp;nbsp;ValidatePositive&amp;lt;-3&amp;gt;()&amp;nbsp;runs&amp;nbsp;→&amp;nbsp;-3&amp;nbsp;&amp;gt;&amp;nbsp;0&amp;nbsp;✗&amp;nbsp;→&amp;nbsp;ERROR!&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto !important; color: #57a64a;&quot;&gt;Stops&amp;nbsp;compilation&amp;nbsp;❌&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto !important; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor  monaco-mouse-cursor-text &quot; style=&quot;animation: auto !important; background-color: #aeafad; border-color: rgb(174, 175, 173); box-sizing: border-box; color: #515052; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; bottom: 0px; height: 6px; left: 0px; opacity: 0 !important; pointer-events: none; position: absolute; visibility: hidden; width: 563px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 563px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; box-shadow: none; height: 48px; opacity: 0 !important; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 48px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; width: 563px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto !important; left: 0px; position: absolute; top: 0px; width: 563px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto !important; height: 48px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;115&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;115&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto !important; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto !important; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(30, 30, 30) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto !important; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto !important; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center  &quot; style=&quot;align-items: center; animation: auto !important; border-style: none; color: #cccccc; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
Then compile:&quot; data-section-index=&quot;13&quot; id=&quot;markdown-section-cef777e5-0536-4f93-9fa0-04eac9a79d27-13&quot; style=&quot;background-color: #1e1e1e; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Then&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;compile&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
```bash
cd /workspace/____ck_task_3233/study_c++
g++ -std=c++20 compile_time_validation.cpp -o compile_time_validation
```&quot; data-section-index=&quot;14&quot; id=&quot;markdown-section-cef777e5-0536-4f93-9fa0-04eac9a79d27-14&quot; style=&quot;background-color: #1e1e1e; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;d9cbc2e2-76b0-4520-9599-dba207ead56c&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px !important; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 39.6615px; width: 577.012px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-radius: 8px; border: 0.833333px solid color(srgb 0.8 0.8 0.8 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #1e1e1e; animation: auto !important; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;1705&quot; data-mode-id=&quot;worktree-shellscript&quot; style=&quot;animation: auto !important; height: 30px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac  showUnused showDeprecated vs-dark&quot; data-uri=&quot;composer-code-block-anysphere://curfnfnjsp&quot; role=&quot;code&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; --vscode-editor-placeholder-foreground: rgba(255, 255, 255, 0.34); animation: auto !important; height: 30px; overflow-wrap: normal; overflow: visible; position: relative; width: 563px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto !important; height: 30px; overflow: hidden; position: relative; width: 563px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto !important; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 339px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor !important; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot; wrap=&quot;off&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto !important; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; contain: strict; height: 30px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 30px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto !important; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto !important; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs-dark mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;--root-dark-color: #000; --root-light-color: #fff; animation: auto !important; height: 30px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 563px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto !important; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 563px;&quot;&gt;&lt;div style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 562.995px;&quot;&gt;&lt;div class=&quot;cslr selected-text top-left-radius bottom-left-radius top-right-radius bottom-right-radius&quot; style=&quot;animation: auto !important; background-color: #3a3d41; border-radius: 3px; bottom: 0px; left: 0px; position: absolute; top: 0px; width: 339px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 30px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 563px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto !important; height: 18px; position: absolute; top: 6px; width: 562.995px;&quot;&gt;&lt;span style=&quot;animation: auto !important; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk17&quot; style=&quot;animation: auto !important; color: #c8c8c8;&quot;&gt;PositiveNumber&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;lt;-3&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto !important; color: #d69d85;&quot;&gt;bad&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk17&quot; style=&quot;animation: auto !important; color: #c8c8c8;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto !important; color: #d69d85;&quot;&gt;Uncomment&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto !important; color: #d69d85;&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto !important;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk11&quot; style=&quot;animation: auto !important; color: #d69d85;&quot;&gt;line&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto !important; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer has-selection cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor  monaco-mouse-cursor-text &quot; style=&quot;animation: auto !important; background-color: #aeafad; border-color: rgb(174, 175, 173); box-sizing: border-box; color: #515052; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 339px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; bottom: 0px; height: 6px; left: 0px; opacity: 0 !important; pointer-events: none; position: absolute; visibility: hidden; width: 563px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 563px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; box-shadow: none; height: 30px; opacity: 0 !important; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.4); contain: strict; height: 30px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; width: 563px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto !important; left: 0px; position: absolute; top: 0px; width: 563px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto !important; height: 30px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;72&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;72&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto !important; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto !important; background: 0% 0% repeat rgba(121, 121, 121, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto !important; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto !important;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto !important; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(30, 30, 30) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto !important; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto !important; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center  &quot; style=&quot;align-items: center; animation: auto !important; border-style: none; color: #cccccc; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto !important; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
**You&#39;ll see the compile error!**&quot; data-section-index=&quot;16&quot; id=&quot;markdown-section-cef777e5-0536-4f93-9fa0-04eac9a79d27-16&quot; style=&quot;background-color: #1e1e1e; border-radius: 4px; color: #d4d4d4; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;You&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&#39;ll&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;see the compile error&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;!&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/745331514990387276/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2025/12/c20-consteval-and-comma-operator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/745331514990387276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/745331514990387276'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2025/12/c20-consteval-and-comma-operator.html' title='C++20, consteval and comma operator example code'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-6790271611427512443</id><published>2025-12-12T06:24:00.000-08:00</published><updated>2025-12-12T09:33:01.234-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++ 20"/><category scheme="http://www.blogger.com/atom/ns#" term="constexpr"/><category scheme="http://www.blogger.com/atom/ns#" term="requires"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><title type='text'>Why Can&#39;t We Use Functions in &quot;requires&quot;? #04_why_not_both.cpp</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;.&lt;/p&gt;&lt;div style=&quot;background-color: #181818; color: #e4e4e4; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Example 4: Why Can&#39;t We Use Functions in &quot;requires&quot;?&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// This shows the difference between concepts and constexpr functions&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;#include&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;#include&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;lt;concepts&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Define types&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;Dog&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #aaa0fa;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;MareArts.com&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;Cat&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #aaa0fa;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Whiskers&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// METHOD 1: Using CONCEPT (works in requires)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;concept&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;HasName&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;requires&lt;/span&gt;(T t) &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;t&lt;/span&gt;.&lt;span style=&quot;color: #aaa0fa;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&lt;/span&gt; std::convertible_to&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;lt;const&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;requires&lt;/span&gt; HasName&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;  // ✅ Works! Concept in requires clause&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #efb080; font-weight: bold;&quot;&gt;printNameWithConcept&lt;/span&gt;(&lt;span style=&quot;color: #efb080;&quot;&gt;T&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd; font-style: italic;&quot;&gt;animal&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Name: &quot;&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;animal&lt;/span&gt;.&lt;span style=&quot;color: #aaa0fa;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// METHOD 2: Using CONSTEXPR FUNCTION (doesn&#39;t work in requires!)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;consteval&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #efb080; font-weight: bold;&quot;&gt;hasNameFunction&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;requires&lt;/span&gt;(T t) &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;t&lt;/span&gt;.&lt;span style=&quot;color: #aaa0fa;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&lt;/span&gt; std::convertible_to&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;lt;const&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ❌ This won&#39;t compile!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// template &amp;lt;typename T&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;//     requires hasNameFunction&amp;lt;T&amp;gt;()  // ❌ ERROR: Can&#39;t use function in requires!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// void printNameWithFunction(T animal) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;//     std::cout &amp;lt;&amp;lt; &quot;Name: &quot; &amp;lt;&amp;lt; animal.name &amp;lt;&amp;lt; &quot;\n&quot;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// }&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// METHOD 3: Using CONSTEXPR FUNCTION with &quot;if constexpr&quot; (works!)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #efb080; font-weight: bold;&quot;&gt;printNameIfConstexpr&lt;/span&gt;(&lt;span style=&quot;color: #efb080;&quot;&gt;T&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd; font-style: italic;&quot;&gt;animal&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    // ✅ Works! Function in &quot;if constexpr&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;constexpr&lt;/span&gt; (&lt;span style=&quot;font-weight: bold;&quot;&gt;hasNameFunction&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;T&lt;/span&gt;&amp;gt;()) &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Name: &quot;&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd; font-style: italic;&quot;&gt;animal&lt;/span&gt;.&lt;span style=&quot;color: #aaa0fa;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;No name!&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// WHY THE DIFFERENCE?&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&quot;requires&quot; clause:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    - Part of template declaration&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    - Needs a CONCEPT (compile-time constraint)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    - Determines if template can even exist&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    - Syntax: template &amp;lt;...&amp;gt; requires CONCEPT&amp;lt;T&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&quot;if constexpr&quot;:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    - Inside function body&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    - Can use ANY compile-time expression&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    - Chooses which code branch to keep&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    - Syntax: if constexpr (EXPRESSION)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;*/&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Main&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #efb080; font-weight: bold;&quot;&gt;main&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #87c3ff;&quot;&gt;Dog&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;dog&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #87c3ff;&quot;&gt;Cat&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;cat&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;=== Using Concept in &#39;requires&#39; ===&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;font-weight: bold;&quot;&gt;printNameWithConcept&lt;/span&gt;(&lt;span style=&quot;color: #87c3ff;&quot;&gt;dog&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;font-weight: bold;&quot;&gt;printNameWithConcept&lt;/span&gt;(&lt;span style=&quot;color: #87c3ff;&quot;&gt;cat&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;=== Using Function in &#39;if constexpr&#39; ===&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;font-weight: bold;&quot;&gt;printNameIfConstexpr&lt;/span&gt;(&lt;span style=&quot;color: #87c3ff;&quot;&gt;dog&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;font-weight: bold;&quot;&gt;printNameIfConstexpr&lt;/span&gt;(&lt;span style=&quot;color: #87c3ff;&quot;&gt;cat&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #ebc88d;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;SUMMARY - Where Can You Use What?&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;┌──────────────────────────┬──────────────┬──────────────────┐&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│                          │  &quot;requires&quot;  │  &quot;if constexpr&quot;  │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;├──────────────────────────┼──────────────┼──────────────────┤&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│ Concept                  │      ✅      │        ✅        │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│ Constexpr Function       │      ❌      │        ✅        │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│ Any compile-time expr    │      ❌      │        ✅        │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;└──────────────────────────┴──────────────┴──────────────────┘&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;This is why:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;- Factories use concepts in &quot;requires&quot; (IsReferenceAlgorithm concept)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;- Dispatcher uses constexpr functions in &quot;if constexpr&quot; (IsReferenceAlgorithm())&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;After refactoring:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;- We removed the concept (not needed anymore)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;- Kept the constexpr function (used in dispatcher)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;- Removed algorithm checks from factory &quot;requires&quot; clauses&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;*/&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;.&lt;/p&gt;&lt;div style=&quot;background-color: #181818; color: #e4e4e4; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;### 4. Why Not Both? (04_why_not_both.cpp)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;**What it teaches:**&lt;/span&gt; Why we can&#39;t mix them up&lt;/div&gt;&lt;br /&gt;&lt;div&gt;```&lt;/div&gt;&lt;div&gt;┌──────────────────────────┬──────────────┬──────────────────┐&lt;/div&gt;&lt;div&gt;│                          │  &quot;requires&quot;  │  &quot;if constexpr&quot;  │&lt;/div&gt;&lt;div&gt;├──────────────────────────┼──────────────┼──────────────────┤&lt;/div&gt;&lt;div&gt;│ Concept                  │      ✅      │        ✅        │&lt;/div&gt;&lt;div&gt;│ Constexpr Function       │      ❌      │        ✅        │&lt;/div&gt;&lt;div&gt;└──────────────────────────┴──────────────┴──────────────────┘&lt;/div&gt;&lt;div&gt;```&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;**Key Point:**&lt;/span&gt; Constexpr functions DON&#39;T work in &lt;span style=&quot;color: #e394dc;&quot;&gt;`requires`&lt;/span&gt; clauses!&lt;/div&gt;&lt;/div&gt;&lt;p&gt;..&lt;/p&gt;&lt;p&gt;Now #1~#4 series is done.&lt;/p&gt;&lt;div style=&quot;background-color: #181818; color: #e4e4e4; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;g++&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;-std=c++20&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;01_concept_basics.cpp&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;-o&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;01_concepts&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;g++&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;-std=c++20&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;02_constexpr_functions.cpp&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;-o&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;02_constexpr&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;g++&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;-std=c++20&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;03_dispatcher_pattern.cpp&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;-o&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;03_dispatcher&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;g++&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;-std=c++20&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;04_why_not_both.cpp&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;-o&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;04_why&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;recap!&lt;/p&gt;&lt;div style=&quot;background-color: #181818; color: #e4e4e4; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;## Key Takeaways 🎯&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;1.&lt;/span&gt; &lt;span style=&quot;color: #f8c762;&quot;&gt;**Concepts**&lt;/span&gt; check if types have certain features&lt;/div&gt;&lt;div&gt;   &lt;span style=&quot;color: #d6d6dd;&quot;&gt;-&lt;/span&gt; Used in &lt;span style=&quot;color: #e394dc;&quot;&gt;`requires`&lt;/span&gt; clauses&lt;/div&gt;&lt;div&gt;   &lt;span style=&quot;color: #d6d6dd;&quot;&gt;-&lt;/span&gt; Like: &lt;span style=&quot;color: #e394dc;&quot;&gt;`requires HasName&amp;lt;T&amp;gt;`&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;2.&lt;/span&gt; &lt;span style=&quot;color: #f8c762;&quot;&gt;**Constexpr functions**&lt;/span&gt; run at compile time&lt;/div&gt;&lt;div&gt;   &lt;span style=&quot;color: #d6d6dd;&quot;&gt;-&lt;/span&gt; Used in &lt;span style=&quot;color: #e394dc;&quot;&gt;`if constexpr`&lt;/span&gt; statements&lt;/div&gt;&lt;div&gt;   &lt;span style=&quot;color: #d6d6dd;&quot;&gt;-&lt;/span&gt; Like: &lt;span style=&quot;color: #e394dc;&quot;&gt;`if constexpr (isDog&amp;lt;T&amp;gt;())`&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;3.&lt;/span&gt; &lt;span style=&quot;color: #f8c762;&quot;&gt;**Dispatcher pattern**&lt;/span&gt; separates concerns:&lt;/div&gt;&lt;div&gt;   &lt;span style=&quot;color: #d6d6dd;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #f8c762;&quot;&gt;**Dispatcher**&lt;/span&gt; checks algorithm type (using &lt;span style=&quot;color: #e394dc;&quot;&gt;`if constexpr`&lt;/span&gt; + constexpr functions)&lt;/div&gt;&lt;div&gt;   &lt;span style=&quot;color: #d6d6dd;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #f8c762;&quot;&gt;**Factory**&lt;/span&gt; checks direction only (using &lt;span style=&quot;color: #e394dc;&quot;&gt;`requires`&lt;/span&gt; + concepts)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;4.&lt;/span&gt; &lt;span style=&quot;color: #f8c762;&quot;&gt;**You can&#39;t mix them:**&lt;/span&gt;&lt;/div&gt;&lt;div&gt;   &lt;span style=&quot;color: #d6d6dd;&quot;&gt;-&lt;/span&gt; Constexpr functions DON&#39;T work in &lt;span style=&quot;color: #e394dc;&quot;&gt;`requires`&lt;/span&gt; clauses&lt;/div&gt;&lt;div&gt;   &lt;span style=&quot;color: #d6d6dd;&quot;&gt;-&lt;/span&gt; That&#39;s why we removed the algorithm check from factory &lt;span style=&quot;color: #e394dc;&quot;&gt;`requires`&lt;/span&gt; clauses!&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Thank you!&lt;/p&gt;&lt;p&gt;study.marearts.com&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/6790271611427512443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2025/12/why-cant-we-use-functions-in-requires.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/6790271611427512443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/6790271611427512443'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2025/12/why-cant-we-use-functions-in-requires.html' title='Why Can&#39;t We Use Functions in &quot;requires&quot;? #04_why_not_both.cpp'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-8839340665930277884</id><published>2025-12-12T06:06:00.000-08:00</published><updated>2025-12-12T09:34:13.179-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++ 20"/><category scheme="http://www.blogger.com/atom/ns#" term="consteval"/><category scheme="http://www.blogger.com/atom/ns#" term="constexpr"/><category scheme="http://www.blogger.com/atom/ns#" term="dispatcher pattern"/><category scheme="http://www.blogger.com/atom/ns#" term="enum class"/><category scheme="http://www.blogger.com/atom/ns#" term="template"/><title type='text'>Dispatcher Pattern Example  #03_dispatcher_pattern.cpp</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;.&lt;/p&gt;&lt;div style=&quot;background-color: #181818; color: #e4e4e4; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Example 3: The Dispatcher Pattern (Like CK Convolution!)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// This is exactly how the convolution dispatcher works!&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;#include&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #a8cc7c;&quot;&gt;#include&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&amp;lt;concepts&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Step 1: Define algorithm types&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;enum&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;AlgorithmType&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #d6d6dd;&quot;&gt;SIMPLE&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #d6d6dd;&quot;&gt;FAST&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #d6d6dd;&quot;&gt;PARALLEL&lt;/span&gt;&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Simple algorithm&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;SimpleAlgorithm&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;AlgorithmType&lt;/span&gt; &lt;span style=&quot;color: #cccccc;&quot;&gt;type&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;AlgorithmType&lt;/span&gt;::&lt;span style=&quot;color: #d6d6dd;&quot;&gt;SIMPLE&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Fast algorithm&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;FastAlgorithm&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;AlgorithmType&lt;/span&gt; &lt;span style=&quot;color: #cccccc;&quot;&gt;type&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;AlgorithmType&lt;/span&gt;::&lt;span style=&quot;color: #d6d6dd;&quot;&gt;FAST&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #aaa0fa;&quot;&gt;optimization_level&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ebc88d;&quot;&gt;3&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Parallel algorithm&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;ParallelAlgorithm&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;AlgorithmType&lt;/span&gt; &lt;span style=&quot;color: #cccccc;&quot;&gt;type&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;AlgorithmType&lt;/span&gt;::&lt;span style=&quot;color: #d6d6dd;&quot;&gt;PARALLEL&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #aaa0fa;&quot;&gt;num_threads&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ebc88d;&quot;&gt;8&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Step 2: Algorithm detection functions (like IsReferenceAlgorithm!)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Check if algorithm is Simple&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;consteval&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #efb080; font-weight: bold;&quot;&gt;IsSimpleAlgorithm&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;is_same_v&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;SimpleAlgorithm&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Check if algorithm is Fast&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;consteval&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #efb080; font-weight: bold;&quot;&gt;IsFastAlgorithm&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;is_same_v&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;FastAlgorithm&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Check if algorithm is Parallel&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;consteval&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #efb080; font-weight: bold;&quot;&gt;IsParallelAlgorithm&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;is_same_v&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #efb080;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;ParallelAlgorithm&lt;/span&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Step 3: Factories (only check direction, not algorithm!)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;enum&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Direction&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #d6d6dd;&quot;&gt;FORWARD&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #d6d6dd;&quot;&gt;BACKWARD&lt;/span&gt;&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Factory for Simple Algorithm&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;Direction&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #87c3ff;&quot;&gt;requires&lt;/span&gt; (&lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Direction&lt;/span&gt;::&lt;span style=&quot;color: #d6d6dd;&quot;&gt;FORWARD&lt;/span&gt;)&lt;span style=&quot;font-style: italic;&quot;&gt;  // ← Only check direction!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;SimpleFactory&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #efb080; font-weight: bold;&quot;&gt;process&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;SimpleFactory: Processing with basic algorithm&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Factory for Fast Algorithm&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;Direction&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #87c3ff;&quot;&gt;requires&lt;/span&gt; (&lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Direction&lt;/span&gt;::&lt;span style=&quot;color: #d6d6dd;&quot;&gt;FORWARD&lt;/span&gt;)&lt;span style=&quot;font-style: italic;&quot;&gt;  // ← Only check direction!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;FastFactory&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #efb080; font-weight: bold;&quot;&gt;process&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;FastFactory: Processing with optimized algorithm&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Factory for Parallel Algorithm&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;Direction&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #87c3ff;&quot;&gt;requires&lt;/span&gt; (&lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Direction&lt;/span&gt;::&lt;span style=&quot;color: #d6d6dd;&quot;&gt;FORWARD&lt;/span&gt;)&lt;span style=&quot;font-style: italic;&quot;&gt;  // ← Only check direction!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;ParallelFactory&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #efb080; font-weight: bold;&quot;&gt;process&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;ParallelFactory: Processing with parallel algorithm&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Step 4: DISPATCHER - Routes to correct factory&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;Direction&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #efb080; font-weight: bold;&quot;&gt;dispatch&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;=== DISPATCHER START (MareArts.com)===&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    // Check direction first&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;constexpr&lt;/span&gt; (&lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Direction&lt;/span&gt;::&lt;span style=&quot;color: #d6d6dd;&quot;&gt;FORWARD&lt;/span&gt;) &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Direction: FORWARD&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;        &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;        // Check algorithm type (like the conv dispatcher!)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;constexpr&lt;/span&gt; (&lt;span style=&quot;font-weight: bold;&quot;&gt;IsSimpleAlgorithm&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;()) &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;  // ← Check algorithm here!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;            &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Algorithm: SIMPLE&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;            SimpleFactory&amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;::&lt;span style=&quot;color: #efb080;&quot;&gt;process&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #82d2ce;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;constexpr&lt;/span&gt; (&lt;span style=&quot;font-weight: bold;&quot;&gt;IsFastAlgorithm&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;()) &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;  // ← Check algorithm here!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;            &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Algorithm: FAST&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;            FastFactory&amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;::&lt;span style=&quot;color: #efb080;&quot;&gt;process&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #82d2ce;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;constexpr&lt;/span&gt; (&lt;span style=&quot;font-weight: bold;&quot;&gt;IsParallelAlgorithm&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;()) &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;  // ← Check algorithm here!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;            &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Algorithm: PARALLEL&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;            ParallelFactory&amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;::&lt;span style=&quot;color: #efb080;&quot;&gt;process&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #82d2ce;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;            // Force compile error for unknown algorithms&lt;/span&gt;&lt;/div&gt;&lt;div&gt;            []&amp;lt;bool &lt;span style=&quot;color: #efb080;&quot;&gt;flag&lt;/span&gt; = false&amp;gt;() { &lt;span style=&quot;color: #82d2ce;&quot;&gt;static_assert&lt;/span&gt;(&lt;span style=&quot;color: #efb080;&quot;&gt;flag&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Unknown algorithm!&quot;&lt;/span&gt;); }();&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Direction: BACKWARD&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;Not implemented yet!&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;=== DISPATCHER END ===&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Main - Try different algorithms!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #efb080; font-weight: bold;&quot;&gt;main&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;=== Dispatcher Pattern Example ===&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #87c3ff;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #cccccc;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #d6d6dd;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;This is exactly how CK convolution dispatcher works!&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #e394dc;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    // Try Simple algorithm&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;font-weight: bold;&quot;&gt;dispatch&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;Direction&lt;/span&gt;::&lt;span style=&quot;color: #d6d6dd;&quot;&gt;FORWARD&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;SimpleAlgorithm&lt;/span&gt;&amp;gt;();&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    // Try Fast algorithm&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;font-weight: bold;&quot;&gt;dispatch&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;Direction&lt;/span&gt;::&lt;span style=&quot;color: #d6d6dd;&quot;&gt;FORWARD&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;FastAlgorithm&lt;/span&gt;&amp;gt;();&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    // Try Parallel algorithm&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;font-weight: bold;&quot;&gt;dispatch&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;Direction&lt;/span&gt;::&lt;span style=&quot;color: #d6d6dd;&quot;&gt;FORWARD&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #87c3ff;&quot;&gt;ParallelAlgorithm&lt;/span&gt;&amp;gt;();&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #ebc88d;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;DISPATCHER PATTERN SUMMARY:&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;┌─────────────────────────────────────────┐&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│          USER CODE                      │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│  dispatch&amp;lt;FORWARD, SimpleAlgorithm&amp;gt;()   │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;└─────────────────────────────────────────┘&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;                 ↓&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;┌─────────────────────────────────────────┐&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│          DISPATCHER                     │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│  ✅ Check direction (if constexpr)      │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│  ✅ Check algorithm (if constexpr)      │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│     - IsSimpleAlgorithm()               │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│     - IsFastAlgorithm()                 │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│     - IsParallelAlgorithm()             │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│  ✅ Route to correct factory            │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;└─────────────────────────────────────────┘&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;                 ↓&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;┌─────────────────────────────────────────┐&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│          FACTORY                        │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│  requires (DIR == FORWARD)              │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│  ❌ NO algorithm check!                 │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;│  ✅ Just build the thing                │&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;└─────────────────────────────────────────┘&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;KEY POINTS:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;1. Dispatcher uses consteval functions with &quot;if constexpr&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;2. Factories use concepts with &quot;requires&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;3. Algorithm checking happens in dispatcher, not factory&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;4. This is EXACTLY the CK convolution pattern!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;*/&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;..&lt;/p&gt;&lt;div style=&quot;background-color: #181818; color: #e4e4e4; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;### 3. Dispatcher Pattern (03_dispatcher_pattern.cpp) ⭐ MOST IMPORTANT&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;**What it teaches:**&lt;/span&gt; Exactly how CK convolution works!&lt;/div&gt;&lt;br /&gt;&lt;div&gt;```cpp&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Detection functions (like IsReferenceAlgorithm!)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;consteval&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;IsSimpleAlgorithm&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;return&lt;/span&gt; std::is_same_v&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; SimpleAlgorithm&lt;span style=&quot;color: #82d2ce;&quot;&gt;&amp;gt;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Dispatcher - checks algorithm and routes&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;Direction&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;dispatch&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;constexpr&lt;/span&gt; (DIR &lt;span style=&quot;color: #82d2ce;&quot;&gt;==&lt;/span&gt; Direction::FORWARD) &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;        // Check algorithm type here!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;constexpr&lt;/span&gt; (&lt;span style=&quot;color: #efb080;&quot;&gt;IsSimpleAlgorithm&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;()) &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;            SimpleFactory&amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;::&lt;span style=&quot;color: #efb080;&quot;&gt;process&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #82d2ce;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;constexpr&lt;/span&gt; (&lt;span style=&quot;color: #efb080;&quot;&gt;IsFastAlgorithm&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;()) &lt;span style=&quot;color: #d6d6dd;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;            FastFactory&amp;lt;&lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;::&lt;span style=&quot;color: #efb080;&quot;&gt;process&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #d6d6dd;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;// Factory - only checks direction!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;Direction&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;DIR&lt;/span&gt;&lt;span style=&quot;color: #d6d6dd;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #82d2ce;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;Algorithm&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #82d2ce;&quot;&gt;requires&lt;/span&gt; (DIR &lt;span style=&quot;color: #82d2ce;&quot;&gt;==&lt;/span&gt; Direction::FORWARD)&lt;span style=&quot;font-style: italic;&quot;&gt;  // Only check direction&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #82d2ce;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #efb080;&quot;&gt;SimpleFactory&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;    // NO algorithm check here!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;div&gt;```&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;**Output:**&lt;/span&gt;&lt;/div&gt;&lt;div&gt;```&lt;/div&gt;&lt;div&gt;=== DISPATCHER START ===&lt;/div&gt;&lt;div&gt;Direction: FORWARD&lt;/div&gt;&lt;div&gt;Algorithm: SIMPLE&lt;/div&gt;&lt;div&gt;SimpleFactory: Processing with basic algorithm&lt;/div&gt;&lt;div&gt;=== DISPATCHER END ===&lt;/div&gt;&lt;div&gt;```&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #f8c762;&quot;&gt;**Key Point:**&lt;/span&gt; This is EXACTLY the CK pattern!&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Study.marearts.com!!!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/8839340665930277884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2025/12/03dispatcherpatterncpp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/8839340665930277884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/8839340665930277884'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2025/12/03dispatcherpatterncpp.html' title='Dispatcher Pattern Example  #03_dispatcher_pattern.cpp'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8995455167205656082.post-2455174639429686304</id><published>2025-12-12T05:57:00.000-08:00</published><updated>2025-12-12T09:35:01.292-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++ 20"/><category scheme="http://www.blogger.com/atom/ns#" term="constant"/><category scheme="http://www.blogger.com/atom/ns#" term="consteval"/><category scheme="http://www.blogger.com/atom/ns#" term="constexpr"/><category scheme="http://www.blogger.com/atom/ns#" term="if constexpr"/><category scheme="http://www.blogger.com/atom/ns#" term="Total"/><title type='text'>c++ constexpr #02_constexpr_functions.cpp</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;..&lt;/p&gt;&lt;div style=&quot;background-color: #fdf6e3; color: #657b83; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// Example 2: Understanding constexpr/consteval Functions&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// These functions run at COMPILE TIME and return results the compiler can use&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #859900;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #b58900;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #2aa198;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// CONSTEXPR: Function evaluated at compile time&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// Regular function - runs at runtime&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;isDogRuntime&lt;/span&gt;(&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;char*&lt;/span&gt; type) {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #859900;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;type&lt;/span&gt;[&lt;span style=&quot;color: #d33682;&quot;&gt;0&lt;/span&gt;] &lt;span style=&quot;color: #859900;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&#39;D&#39;&lt;/span&gt;;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;  // Check if starts with &#39;D&#39;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// Constexpr function - can run at compile time!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;isDogCompileTime&lt;/span&gt;(&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;char*&lt;/span&gt; type) {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #859900;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;type&lt;/span&gt;[&lt;span style=&quot;color: #d33682;&quot;&gt;0&lt;/span&gt;] &lt;span style=&quot;color: #859900;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&#39;D&#39;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// Consteval (C++20) - MUST run at compile time&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;consteval&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;isDogMustCompileTime&lt;/span&gt;(&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;char*&lt;/span&gt; type) {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #859900;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;type&lt;/span&gt;[&lt;span style=&quot;color: #d33682;&quot;&gt;0&lt;/span&gt;] &lt;span style=&quot;color: #859900;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&#39;D&#39;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// Animal types&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #cb4b16;&quot;&gt;Dog&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;type&lt;/span&gt; &lt;span style=&quot;color: #859900;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;marearts.com Dog&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #cb4b16;&quot;&gt;Cat&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;type&lt;/span&gt; &lt;span style=&quot;color: #859900;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;marearts.com Cat&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #cb4b16;&quot;&gt;Bird&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: #859900;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;type&lt;/span&gt; &lt;span style=&quot;color: #859900;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;marearts.com Bird&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// Using constexpr functions with &quot;if constexpr&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #cb4b16;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;describeAnimal&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;    // if constexpr - evaluated at COMPILE TIME&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #859900;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt; (&lt;span style=&quot;color: #268bd2;&quot;&gt;isDogCompileTime&lt;/span&gt;(&lt;span style=&quot;color: #cb4b16;&quot;&gt;T&lt;/span&gt;::type)) {&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #cb4b16;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #268bd2;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #859900;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;This is a DOG - has 4 legs, barks&lt;/span&gt;&lt;span style=&quot;color: #cb4b16;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #859900;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #859900;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt; (&lt;span style=&quot;color: #cb4b16;&quot;&gt;T&lt;/span&gt;::&lt;span style=&quot;color: #268bd2;&quot;&gt;type&lt;/span&gt;[&lt;span style=&quot;color: #d33682;&quot;&gt;0&lt;/span&gt;] &lt;span style=&quot;color: #859900;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&#39;C&#39;&lt;/span&gt;) {&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;  // Can use any compile-time expression&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #cb4b16;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #268bd2;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #859900;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;This is a CAT - has 4 legs, meows&lt;/span&gt;&lt;span style=&quot;color: #cb4b16;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #859900;&quot;&gt;else&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #cb4b16;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #268bd2;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #859900;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;This is a BIRD - has 2 legs, flies&lt;/span&gt;&lt;span style=&quot;color: #cb4b16;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// Difference: regular if vs if constexpr&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #cb4b16;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;regularIf&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;    // Regular if - runs at RUNTIME, all branches must be valid&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #859900;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #268bd2;&quot;&gt;isDogRuntime&lt;/span&gt;(&lt;span style=&quot;color: #cb4b16;&quot;&gt;T&lt;/span&gt;::type)) {&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #cb4b16;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #268bd2;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #859900;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;Runtime check: Dog&lt;/span&gt;&lt;span style=&quot;color: #cb4b16;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #cb4b16;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;constexprIf&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;    // if constexpr - evaluated at COMPILE TIME, only chosen branch exists&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #859900;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt; (&lt;span style=&quot;color: #268bd2;&quot;&gt;isDogCompileTime&lt;/span&gt;(&lt;span style=&quot;color: #cb4b16;&quot;&gt;T&lt;/span&gt;::type)) {&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #cb4b16;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #268bd2;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #859900;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;Compile-time check: Dog&lt;/span&gt;&lt;span style=&quot;color: #cb4b16;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// Main&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// ==========================================&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;main&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #cb4b16;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #268bd2;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #859900;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;=== Using constexpr functions with &#39;if constexpr&#39; ===&lt;/span&gt;&lt;span style=&quot;color: #cb4b16;&quot;&gt;\n\n&lt;/span&gt;&lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #268bd2;&quot;&gt;describeAnimal&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #cb4b16;&quot;&gt;Dog&lt;/span&gt;&amp;gt;();&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #268bd2;&quot;&gt;describeAnimal&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #cb4b16;&quot;&gt;Cat&lt;/span&gt;&amp;gt;();&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #268bd2;&quot;&gt;describeAnimal&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #cb4b16;&quot;&gt;Bird&lt;/span&gt;&amp;gt;();&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #cb4b16;&quot;&gt;std&lt;/span&gt;::&lt;span style=&quot;color: #268bd2;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #859900;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #cb4b16;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #2aa198;&quot;&gt;=== Difference between regular if and if constexpr ===&lt;/span&gt;&lt;span style=&quot;color: #cb4b16;&quot;&gt;\n\n&lt;/span&gt;&lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #268bd2;&quot;&gt;regularIf&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #cb4b16;&quot;&gt;Dog&lt;/span&gt;&amp;gt;();&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #268bd2;&quot;&gt;constexprIf&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #cb4b16;&quot;&gt;Dog&lt;/span&gt;&amp;gt;();&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;    // With constexpr, the check happens at COMPILE TIME!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;    // The compiler removes the unused branches - they don&#39;t even exist in final code!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #859900;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #d33682;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;KEY POINTS:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;1. constexpr/consteval functions run at COMPILE TIME&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;2. &quot;if constexpr&quot; uses compile-time checks&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;3. Only the chosen branch exists in final code (very efficient!)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;4. Can&#39;t use constexpr functions in &quot;requires&quot; clauses - they need concepts&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;5. But CAN use constexpr functions in &quot;if constexpr&quot; - that&#39;s the dispatcher pattern!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;*/&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;..&lt;/p&gt;&lt;p&gt;------------------------------------------------------------&lt;/p&gt;&lt;p&gt;How to build&lt;/p&gt;&lt;p&gt;&amp;gt; g++ -std=c++20 02_constexpr_functions.cpp -o 02_constexpr_functions&lt;/p&gt;&lt;p&gt;&amp;gt;./02_constexpr&lt;/p&gt;&lt;p&gt;=== Using constexpr functions with &#39;if constexpr&#39; ===&lt;/p&gt;&lt;p&gt;This is a DOG - has 4 legs, barks&lt;/p&gt;&lt;p&gt;This is a CAT - has 4 legs, meows&lt;/p&gt;&lt;p&gt;This is a BIRD - has 2 legs, flies&lt;/p&gt;&lt;p&gt;=== Difference between regular if and if constexpr ===&lt;/p&gt;&lt;p&gt;Runtime check: Dog&lt;/p&gt;&lt;p&gt;Compile-time check: Dog&lt;/p&gt;&lt;p&gt;------------------------------------------------------------------------------------------------------------------------&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #fdf6e3; color: #657b83; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; line-height: 18px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #268bd2; font-weight: bold;&quot;&gt;### 2. Constexpr Functions (02_constexpr_functions.cpp)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #d33682; font-weight: bold;&quot;&gt;**What it teaches:**&lt;/span&gt; Functions that run at compile time&lt;/div&gt;&lt;br /&gt;&lt;div&gt;```cpp&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// Constexpr function - evaluated at compile time&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;isDog&lt;/span&gt;(&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;char*&lt;/span&gt; type) {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #859900;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;type&lt;/span&gt;[&lt;span style=&quot;color: #d33682;&quot;&gt;0&lt;/span&gt;] &lt;span style=&quot;color: #859900;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&#39;D&#39;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;// Use in if constexpr&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;template&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;typename&lt;/span&gt; &lt;span style=&quot;color: #cb4b16;&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #268bd2;&quot;&gt;describe&lt;/span&gt;() {&lt;/div&gt;&lt;div&gt;    &lt;span style=&quot;color: #859900;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt; (&lt;span style=&quot;color: #268bd2;&quot;&gt;isDog&lt;/span&gt;(&lt;span style=&quot;color: #cb4b16;&quot;&gt;T&lt;/span&gt;::type)) {&lt;span style=&quot;color: #93a1a1; font-style: italic;&quot;&gt;  // ✅ Function works here!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span style=&quot;color: #cb4b16;&quot;&gt;std&lt;/span&gt;::cout &lt;span style=&quot;color: #859900;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #2aa198;&quot;&gt;&quot;It&#39;s a dog!&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;```&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;OK then what is different constexpr and consteval and anything else?&amp;nbsp;&lt;/p&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## 1. `constexpr` (C++11)&quot; data-section-index=&quot;1&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-1&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;1.&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;constexpr&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;(C++1&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;1)&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
Can run at compile time OR runtime, depending on context:&quot; data-section-index=&quot;2&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-2&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Can&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;run at compile time OR&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;runtime&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;, depending&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;on context&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```15:18:/workspace/____ck_task_3233/study_c++/dispatcher_pattern/02_constexpr_functions.cpp
// Constexpr function - can run at compile time!
constexpr bool isDogCompileTime(const char* type) {
    return type[0] == &#39;D&#39;;
}
```&quot; data-section-index=&quot;3&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-3&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;180690e2-3c95-4be1-8439-ea77ef31235d&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 122.487px; width: 646.009px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.380392 0.380392 0.380392 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;composer-code-block-header&quot; style=&quot;align-items: center; animation: 0.25s fade-in; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; border-bottom-color: color(srgb 0.380392 0.380392 0.380392 / 0.12); border-bottom-style: solid; border-bottom-width: 0.833333px; cursor: pointer; display: flex; gap: 6px; height: 28px; justify-content: space-between; max-width: 100%; overflow: hidden; padding: 0px 8px 0px 6px; position: sticky; scrollbar-width: none; transition: background 0.1s ease-in-out; z-index: 2;&quot;&gt;&lt;div class=&quot;composer-code-block-file-info&quot; style=&quot;align-items: center; animation: 0.25s fade-in; box-sizing: border-box; display: flex; flex: 1 1 0%; gap: 6px; min-width: 0px; overflow: auto hidden; scrollbar-width: none;&quot;&gt;&lt;span class=&quot;composer-primary-toolcall-icon&quot; style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; height: 16px; justify-content: center; width: 16px;&quot;&gt;&lt;div class=&quot;show-file-icons&quot; style=&quot;animation: 0.25s fade-in; height: 18px;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; height: 17.9948px; justify-content: center; position: relative; width: 15.9961px;&quot;&gt;&lt;div class=&quot;monaco-icon-label file-icon cpp-lang-file-icon height-override-important file-icon-override&quot; style=&quot;animation: 0.25s fade-in; display: flex; height: 17.9948px; overflow: hidden; text-overflow: ellipsis;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;span class=&quot;composer-code-block-filename&quot; style=&quot;animation: 0.25s fade-in; direction: rtl; font-size: 12px; line-height: 14.4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in; direction: ltr; unicode-bidi: embed;&quot;&gt;02_constexpr_functions.cpp&lt;span style=&quot;animation: 0.25s fade-in; color: #717171; margin-left: 6px; opacity: 0.8;&quot;&gt;Lines 15-18&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #fdf6e3; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: calc(100% - 6px); pointer-events: none; position: absolute; right: 0px; top: 0px; width: 644.342px; z-index: 1;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-clickable=&quot;true&quot; data-keybinding-context=&quot;91&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto; cursor: pointer; height: 84px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs&quot; data-uri=&quot;composer-code-block-anysphere://wpmeebssyo&quot; role=&quot;code&quot; style=&quot;--vscode-editor-placeholder-foreground: rgba(0, 0, 0, 0.47); animation: auto; cursor: pointer; height: 84px; overflow-wrap: normal; overflow: visible; position: relative; width: 632px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; overflow: hidden; position: relative; width: 632px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; cursor: pointer; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; height: 84px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 84px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; cursor: pointer; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 632px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 84px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 632px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; cursor: pointer; font-style: italic;&quot;&gt;//&amp;nbsp;Constexpr&amp;nbsp;function&amp;nbsp;-&amp;nbsp;can&amp;nbsp;run&amp;nbsp;at&amp;nbsp;compile&amp;nbsp;time!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2; cursor: pointer;&quot;&gt;isDogCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;char*&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;type)&amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2; cursor: pointer;&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto; color: #d33682; cursor: pointer;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;]&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198; cursor: pointer;&quot;&gt;&#39;D&#39;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: #657b83; border-color: rgb(101, 123, 131); box-sizing: border-box; color: #9a847c; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; cursor: pointer; height: 6px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 632px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; cursor: pointer; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 632px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; cursor: pointer; height: 84px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; cursor: pointer; height: 84px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; cursor: pointer; left: 0px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;201&quot; style=&quot;animation: auto !important; cursor: pointer !important; height: 84px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;201&quot; style=&quot;animation: auto !important; cursor: pointer !important; height: 84px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.2); cursor: pointer; height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
**Flexible:** The compiler decides when to evaluate it.&quot; data-section-index=&quot;5&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-5&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Flexible&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;The&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;compiler decides&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;when&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;to evaluate it&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;.&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## 2. `consteval` (C++20)&quot; data-section-index=&quot;6&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-6&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;2.&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;consteval&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;(C++20)&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
MUST run at compile time - stricter than `constexpr`:&quot; data-section-index=&quot;7&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-7&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;MUST run&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;at compile time&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;- stri&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;cter than&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;constexpr&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```20:23:/workspace/____ck_task_3233/study_c++/dispatcher_pattern/02_constexpr_functions.cpp
// Consteval (C++20) - MUST run at compile time
consteval bool isDogMustCompileTime(const char* type) {
    return type[0] == &#39;D&#39;;
}
```&quot; data-section-index=&quot;8&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-8&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;22cb94c9-2e82-4a48-873f-fe82deb99fe6&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 122.487px; width: 646.009px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.380392 0.380392 0.380392 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;composer-code-block-header&quot; style=&quot;align-items: center; animation: 0.25s fade-in; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; border-bottom-color: color(srgb 0.380392 0.380392 0.380392 / 0.12); border-bottom-style: solid; border-bottom-width: 0.833333px; cursor: pointer; display: flex; gap: 6px; height: 28px; justify-content: space-between; max-width: 100%; overflow: hidden; padding: 0px 8px 0px 6px; position: sticky; scrollbar-width: none; transition: background 0.1s ease-in-out; z-index: 2;&quot;&gt;&lt;div class=&quot;composer-code-block-file-info&quot; style=&quot;align-items: center; animation: 0.25s fade-in; box-sizing: border-box; display: flex; flex: 1 1 0%; gap: 6px; min-width: 0px; overflow: auto hidden; scrollbar-width: none;&quot;&gt;&lt;span class=&quot;composer-primary-toolcall-icon&quot; style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; height: 16px; justify-content: center; width: 16px;&quot;&gt;&lt;div class=&quot;show-file-icons&quot; style=&quot;animation: 0.25s fade-in; height: 18px;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; height: 17.9948px; justify-content: center; position: relative; width: 15.9961px;&quot;&gt;&lt;div class=&quot;monaco-icon-label file-icon cpp-lang-file-icon height-override-important file-icon-override&quot; style=&quot;animation: 0.25s fade-in; display: flex; height: 17.9948px; overflow: hidden; text-overflow: ellipsis;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;span class=&quot;composer-code-block-filename&quot; style=&quot;animation: 0.25s fade-in; direction: rtl; font-size: 12px; line-height: 14.4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in; direction: ltr; unicode-bidi: embed;&quot;&gt;02_constexpr_functions.cpp&lt;span style=&quot;animation: 0.25s fade-in; color: #717171; margin-left: 6px; opacity: 0.8;&quot;&gt;Lines 20-23&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #fdf6e3; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: calc(100% - 6px); pointer-events: none; position: absolute; right: 0px; top: 0px; width: 644.342px; z-index: 1;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-clickable=&quot;true&quot; data-keybinding-context=&quot;92&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto; cursor: pointer; height: 84px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs&quot; data-uri=&quot;composer-code-block-anysphere://ueisbmxjan&quot; role=&quot;code&quot; style=&quot;--vscode-editor-placeholder-foreground: rgba(0, 0, 0, 0.47); animation: auto; cursor: pointer; height: 84px; overflow-wrap: normal; overflow: visible; position: relative; width: 632px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; overflow: hidden; position: relative; width: 632px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; cursor: pointer; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; height: 84px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 84px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; cursor: pointer; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 632px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 84px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 632px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; cursor: pointer; font-style: italic;&quot;&gt;//&amp;nbsp;Consteval&amp;nbsp;(C++20)&amp;nbsp;-&amp;nbsp;MUST&amp;nbsp;run&amp;nbsp;at&amp;nbsp;compile&amp;nbsp;time&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;consteval&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2; cursor: pointer;&quot;&gt;isDogMustCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;char*&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;type)&amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2; cursor: pointer;&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto; color: #d33682; cursor: pointer;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;]&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198; cursor: pointer;&quot;&gt;&#39;D&#39;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: #657b83; border-color: rgb(101, 123, 131); box-sizing: border-box; color: #9a847c; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; cursor: pointer; height: 6px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 632px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; cursor: pointer; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 632px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; cursor: pointer; height: 84px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; cursor: pointer; height: 84px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; cursor: pointer; left: 0px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;201&quot; style=&quot;animation: auto !important; cursor: pointer !important; height: 84px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;201&quot; style=&quot;animation: auto !important; cursor: pointer !important; height: 84px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.2); cursor: pointer; height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
**Strict:** Compile error if it can&#39;t be evaluated at compile time.&quot; data-section-index=&quot;10&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-10&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;Strict:&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;Compile&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;error&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;if it&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;can&#39;t be evaluated at compile time&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;.&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## 3. `constinit` (C++20)&quot; data-section-index=&quot;11&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-11&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;3.&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;constinit&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;(C++20&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;)&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
Ensures **variables** are initialized at compile time (doesn&#39;t apply to functions):&quot; data-section-index=&quot;12&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-12&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Ensures&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;variables&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;are initialized at compile time (doesn&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&#39;t apply&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;to functions):&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```cpp
constinit int value = 42;  // Must be initialized at compile time
```&quot; data-section-index=&quot;13&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-13&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;655942a0-3266-48b1-b5f9-e43980b67bf6&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 39.6615px; width: 646.009px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.380392 0.380392 0.380392 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #fdf6e3; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;93&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto; height: 30px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs&quot; data-uri=&quot;composer-code-block-anysphere://isnktonglx&quot; role=&quot;code&quot; style=&quot;--vscode-editor-placeholder-foreground: rgba(0, 0, 0, 0.47); animation: auto; height: 30px; overflow-wrap: normal; overflow: visible; position: relative; width: 632px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 30px; overflow: hidden; position: relative; width: 632px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 30px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 30px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 30px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 30px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 632px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 30px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 632px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;constinit&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;value&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto; color: #d33682;&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Must&amp;nbsp;be&amp;nbsp;initialized&amp;nbsp;at&amp;nbsp;compile&amp;nbsp;time&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: #657b83; border-color: rgb(101, 123, 131); box-sizing: border-box; color: #9a847c; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 6px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 632px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 632px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 30px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 30px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 30px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 30px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;72&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;72&quot; style=&quot;animation: auto !important; height: 30px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(253, 246, 227) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center&quot; style=&quot;align-items: center; animation: auto; border-style: none; color: #616161; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## Bonus: `if constexpr` (C++17)&quot; data-section-index=&quot;14&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-14&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Bonus&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;constexpr&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;(C++1&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;7)&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
Not a function specifier, but a compile-time conditional statement:&quot; data-section-index=&quot;15&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-15&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Not&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;a function specifier&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;, but a&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;compile&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;-time conditional&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;statement&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```47:57:/workspace/____ck_task_3233/study_c++/dispatcher_pattern/02_constexpr_functions.cpp
    // if constexpr - evaluated at COMPILE TIME
    if constexpr (isDogCompileTime(T::type)) {
        std::cout &amp;lt;&amp;lt; &amp;quot;This is a DOG - has 4 legs, barks\n&amp;quot;;
    }
    else if constexpr (T::type[0] == &#39;C&#39;) {  // Can use any compile-time expression
        std::cout &amp;lt;&amp;lt; &amp;quot;This is a CAT - has 4 legs, meows\n&amp;quot;;
    }
    else {
        std::cout &amp;lt;&amp;lt; &amp;quot;This is a BIRD - has 2 legs, flies\n&amp;quot;;
    }
```&quot; data-section-index=&quot;16&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-16&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;dd81687d-2d3d-4a47-9ff7-edf2e248f8c3&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 230.488px; width: 646.009px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.380392 0.380392 0.380392 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;composer-code-block-header&quot; style=&quot;align-items: center; animation: 0.25s fade-in; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; border-bottom-color: color(srgb 0.380392 0.380392 0.380392 / 0.12); border-bottom-style: solid; border-bottom-width: 0.833333px; cursor: pointer; display: flex; gap: 6px; height: 28px; justify-content: space-between; max-width: 100%; overflow: hidden; padding: 0px 8px 0px 6px; position: sticky; scrollbar-width: none; transition: background 0.1s ease-in-out; z-index: 2;&quot;&gt;&lt;div class=&quot;composer-code-block-file-info&quot; style=&quot;align-items: center; animation: 0.25s fade-in; box-sizing: border-box; display: flex; flex: 1 1 0%; gap: 6px; min-width: 0px; overflow: auto hidden; scrollbar-width: none;&quot;&gt;&lt;span class=&quot;composer-primary-toolcall-icon&quot; style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; height: 16px; justify-content: center; width: 16px;&quot;&gt;&lt;div class=&quot;show-file-icons&quot; style=&quot;animation: 0.25s fade-in; height: 18px;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; height: 17.9948px; justify-content: center; position: relative; width: 15.9961px;&quot;&gt;&lt;div class=&quot;monaco-icon-label file-icon cpp-lang-file-icon height-override-important file-icon-override&quot; style=&quot;animation: 0.25s fade-in; display: flex; height: 17.9948px; overflow: hidden; text-overflow: ellipsis;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;span class=&quot;composer-code-block-filename&quot; style=&quot;animation: 0.25s fade-in; direction: rtl; font-size: 12px; line-height: 14.4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in; direction: ltr; unicode-bidi: embed;&quot;&gt;02_constexpr_functions.cpp&lt;span style=&quot;animation: 0.25s fade-in; color: #717171; margin-left: 6px; opacity: 0.8;&quot;&gt;Lines 47-57&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #fdf6e3; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: calc(100% - 6px); pointer-events: none; position: absolute; right: 0px; top: 0px; width: 644.342px; z-index: 1;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-clickable=&quot;true&quot; data-keybinding-context=&quot;94&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto; cursor: pointer; height: 192px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs&quot; data-uri=&quot;composer-code-block-anysphere://tpqvprwphq&quot; role=&quot;code&quot; style=&quot;--vscode-editor-placeholder-foreground: rgba(0, 0, 0, 0.47); animation: auto; cursor: pointer; height: 192px; overflow-wrap: normal; overflow: visible; position: relative; width: 632px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; cursor: pointer; height: 192px; overflow: hidden; position: relative; width: 632px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; cursor: pointer; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; height: 192px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; cursor: pointer; height: 192px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 192px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; cursor: pointer; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 78px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 96px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 114px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 132px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 150px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 168px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; height: 192px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 632px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 78px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 96px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 114px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 132px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 150px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 168px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 192px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 632px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; cursor: pointer; font-style: italic;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;if&amp;nbsp;constexpr&amp;nbsp;-&amp;nbsp;evaluated&amp;nbsp;at&amp;nbsp;COMPILE&amp;nbsp;TIME&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2; cursor: pointer;&quot;&gt;isDogCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot; style=&quot;animation: auto; color: #cb4b16; cursor: pointer;&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;::type))&amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk10&quot; style=&quot;animation: auto; color: #cb4b16; cursor: pointer;&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;::cout&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198; cursor: pointer;&quot;&gt;&quot;This&amp;nbsp;is&amp;nbsp;a&amp;nbsp;DOG&amp;nbsp;-&amp;nbsp;has&amp;nbsp;4&amp;nbsp;legs,&amp;nbsp;barks&lt;/span&gt;&lt;span class=&quot;mtk10&quot; style=&quot;animation: auto; color: #cb4b16; cursor: pointer;&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198; cursor: pointer;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 78px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot; style=&quot;animation: auto; color: #cb4b16; cursor: pointer;&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2; cursor: pointer;&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto; color: #d33682; cursor: pointer;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;]&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198; cursor: pointer;&quot;&gt;&#39;C&#39;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; cursor: pointer; font-style: italic;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Can&amp;nbsp;use&amp;nbsp;any&amp;nbsp;compile-time&amp;nbsp;expression&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 96px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk10&quot; style=&quot;animation: auto; color: #cb4b16; cursor: pointer;&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;::cout&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198; cursor: pointer;&quot;&gt;&quot;This&amp;nbsp;is&amp;nbsp;a&amp;nbsp;CAT&amp;nbsp;-&amp;nbsp;has&amp;nbsp;4&amp;nbsp;legs,&amp;nbsp;meows&lt;/span&gt;&lt;span class=&quot;mtk10&quot; style=&quot;animation: auto; color: #cb4b16; cursor: pointer;&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198; cursor: pointer;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 114px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 132px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 150px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk10&quot; style=&quot;animation: auto; color: #cb4b16; cursor: pointer;&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;::cout&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198; cursor: pointer;&quot;&gt;&quot;This&amp;nbsp;is&amp;nbsp;a&amp;nbsp;BIRD&amp;nbsp;-&amp;nbsp;has&amp;nbsp;2&amp;nbsp;legs,&amp;nbsp;flies&lt;/span&gt;&lt;span class=&quot;mtk10&quot; style=&quot;animation: auto; color: #cb4b16; cursor: pointer;&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198; cursor: pointer;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 168px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: #657b83; border-color: rgb(101, 123, 131); box-sizing: border-box; color: #9a847c; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; cursor: pointer; height: 6px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 632px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; cursor: pointer; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 632px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; cursor: pointer; height: 192px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; cursor: pointer; height: 192px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; cursor: pointer; left: 0px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; height: 192px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; cursor: pointer; height: 192px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;460&quot; style=&quot;animation: auto !important; cursor: pointer !important; height: 192px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;460&quot; style=&quot;animation: auto !important; cursor: pointer !important; height: 192px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.2); cursor: pointer; height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## Quick Comparison&quot; data-section-index=&quot;17&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-17&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Quick&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;Comparison&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;div class=&quot;monaco-scrollable-element mac&quot; role=&quot;presentation&quot; style=&quot;background-color: #fdf6e3; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; margin: 1em 0px; orphans: 2; overflow: hidden; position: relative; scrollbar-width: none; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2; width: 646.009px;&quot;&gt;&lt;div style=&quot;overflow: hidden;&quot;&gt;&lt;table class=&quot;markdown-table&quot; style=&quot;border-collapse: collapse; font-size: inherit;&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; text-align: left; white-space: nowrap;&quot;&gt;Keyword&lt;/th&gt;&lt;th style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; text-align: left; white-space: nowrap;&quot;&gt;When&amp;nbsp;Evaluated&lt;/th&gt;&lt;th style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; text-align: left; white-space: nowrap;&quot;&gt;Use&amp;nbsp;Case&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; line-height: 1.4; word-break: break-all;&quot;&gt;constexpr&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;Compile time OR runtime&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;Functions/variables that&amp;nbsp;CAN be constant&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; line-height: 1.4; word-break: break-all;&quot;&gt;consteval&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;Compile time ONLY&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;Functions that MUST be constant&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; line-height: 1.4; word-break: break-all;&quot;&gt;constinit&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;Initialization&amp;nbsp;at compile time&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;Variables with&amp;nbsp;compile-time initialization&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; line-height: 1.4; word-break: break-all;&quot;&gt;if&amp;nbsp;constexpr&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;Compile time&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;Conditional compilation&amp;nbsp;branches&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal fade&quot; role=&quot;presentation&quot; style=&quot;bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; transition: opacity 0.8s linear; visibility: hidden; width: 411px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 283px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;height: 162px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 162px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 10px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
So the answer is: **three main keywords** (`constexpr`, `consteval`, `constinit`), plus `if constexpr` for compile-time conditionals! 🎯&quot; data-section-index=&quot;20&quot; id=&quot;markdown-section-4ef26597-536e-461b-b24e-5d294d9dedaa-20&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;So&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;the answer&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;is&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;three&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;main&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;keywords&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;constexpr&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;consteval&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;constinit&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;), plus&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;if constexpr&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;for&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;compile-time condit&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;ionals&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;🎯&lt;/span&gt;&lt;/section&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;ok, one thing to clear&amp;nbsp;&lt;/p&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## Both are equivalent:&quot; data-section-index=&quot;16&quot; id=&quot;markdown-section-1017acbf-d9a9-43e7-abc7-243a040b97de-16&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Both&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;are equivalent&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```cpp
// Option 1: Use constexpr function
if constexpr (isDogCompileTime(T::type))

// Option 2: Write expression directly (does the same thing)
if constexpr (T::type[0] == &#39;D&#39;)
```&quot; data-section-index=&quot;17&quot; id=&quot;markdown-section-1017acbf-d9a9-43e7-abc7-243a040b97de-17&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;b0eb2628-d125-4ea6-9453-c296e8a54e50&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 111.66px; width: 646.009px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.380392 0.380392 0.380392 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #fdf6e3; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;103&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto; height: 102px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs&quot; data-uri=&quot;composer-code-block-anysphere://yjyajjilhf&quot; role=&quot;code&quot; style=&quot;--vscode-editor-placeholder-foreground: rgba(0, 0, 0, 0.47); animation: auto; height: 102px; overflow-wrap: normal; overflow: visible; position: relative; width: 632px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 102px; overflow: hidden; position: relative; width: 632px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 102px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 102px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 102px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 102px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 632px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 102px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 632px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;//&amp;nbsp;Option&amp;nbsp;1:&amp;nbsp;Use&amp;nbsp;constexpr&amp;nbsp;function&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;isDogCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot; style=&quot;animation: auto; color: #cb4b16;&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;::type))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;//&amp;nbsp;Option&amp;nbsp;2:&amp;nbsp;Write&amp;nbsp;expression&amp;nbsp;directly&amp;nbsp;(does&amp;nbsp;the&amp;nbsp;s&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;ame&amp;nbsp;thing)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot; style=&quot;animation: auto; color: #cb4b16;&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto; color: #d33682;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;]&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198;&quot;&gt;&#39;D&#39;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: #657b83; border-color: rgb(101, 123, 131); box-sizing: border-box; color: #9a847c; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 6px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 632px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 632px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 102px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 102px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 102px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 102px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;244&quot; style=&quot;animation: auto !important; height: 102px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;244&quot; style=&quot;animation: auto !important; height: 102px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(253, 246, 227) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center&quot; style=&quot;align-items: center; animation: auto; border-style: none; color: #616161; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
The **only** requirement for `if constexpr` is that the condition must be a **compile-time constant expression** - it doesn&#39;t matter whether it comes from a function call or is written inline! 🎯&quot; data-section-index=&quot;19&quot; id=&quot;markdown-section-1017acbf-d9a9-43e7-abc7-243a040b97de-19&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;The&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;only&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;requirement&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;for&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;constexpr&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;is that the&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;condition&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;must be a&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;compile-time constant expression&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;- it&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;doesn&#39;t matter&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;whether&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;it comes&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;from a function call or&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;is&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;written&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;inline&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;!&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;🎯&lt;/span&gt;&lt;/section&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;What is meaning constexpr is flexible??&lt;/p&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## `constexpr` - Flexible (Can do both)&quot; data-section-index=&quot;1&quot; id=&quot;markdown-section-e3980c6a-c0f7-4cde-b105-fbe7b766b780-1&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;constexpr&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;- Flexible&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;(Can&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;do both)&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```15:18:/workspace/____ck_task_3233/study_c++/dispatcher_pattern/02_constexpr_functions.cpp
// Constexpr function - can run at compile time!
constexpr bool isDogCompileTime(const char* type) {
    return type[0] == &#39;D&#39;;
}
```&quot; data-section-index=&quot;2&quot; id=&quot;markdown-section-e3980c6a-c0f7-4cde-b105-fbe7b766b780-2&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;43145100-066d-4124-86e7-96794b734019&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 122.487px; width: 646.009px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.380392 0.380392 0.380392 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;composer-code-block-header&quot; style=&quot;align-items: center; animation: 0.25s fade-in; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; border-bottom-color: color(srgb 0.380392 0.380392 0.380392 / 0.12); border-bottom-style: solid; border-bottom-width: 0.833333px; cursor: pointer; display: flex; gap: 6px; height: 28px; justify-content: space-between; max-width: 100%; overflow: hidden; padding: 0px 8px 0px 6px; position: sticky; scrollbar-width: none; transition: background 0.1s ease-in-out; z-index: 2;&quot;&gt;&lt;div class=&quot;composer-code-block-file-info&quot; style=&quot;align-items: center; animation: 0.25s fade-in; box-sizing: border-box; display: flex; flex: 1 1 0%; gap: 6px; min-width: 0px; overflow: auto hidden; scrollbar-width: none;&quot;&gt;&lt;span class=&quot;composer-primary-toolcall-icon&quot; style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; height: 16px; justify-content: center; width: 16px;&quot;&gt;&lt;div class=&quot;show-file-icons&quot; style=&quot;animation: 0.25s fade-in; height: 18px;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; height: 17.9948px; justify-content: center; position: relative; width: 15.9961px;&quot;&gt;&lt;div class=&quot;monaco-icon-label file-icon cpp-lang-file-icon height-override-important file-icon-override&quot; style=&quot;animation: 0.25s fade-in; display: flex; height: 17.9948px; overflow: hidden; text-overflow: ellipsis;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;span class=&quot;composer-code-block-filename&quot; style=&quot;animation: 0.25s fade-in; direction: rtl; font-size: 12px; line-height: 14.4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in; direction: ltr; unicode-bidi: embed;&quot;&gt;02_constexpr_functions.cpp&lt;span style=&quot;animation: 0.25s fade-in; color: #717171; margin-left: 6px; opacity: 0.8;&quot;&gt;Lines 15-18&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #fdf6e3; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: calc(100% - 6px); pointer-events: none; position: absolute; right: 0px; top: 0px; width: 644.342px; z-index: 1;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-clickable=&quot;true&quot; data-keybinding-context=&quot;104&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto; cursor: pointer; height: 84px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs&quot; data-uri=&quot;composer-code-block-anysphere://wgwtclaqjl&quot; role=&quot;code&quot; style=&quot;--vscode-editor-placeholder-foreground: rgba(0, 0, 0, 0.47); animation: auto; cursor: pointer; height: 84px; overflow-wrap: normal; overflow: visible; position: relative; width: 632px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; overflow: hidden; position: relative; width: 632px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; cursor: pointer; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; height: 84px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 84px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; cursor: pointer; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 632px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 84px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 632px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; cursor: pointer; font-style: italic;&quot;&gt;//&amp;nbsp;Constexpr&amp;nbsp;function&amp;nbsp;-&amp;nbsp;can&amp;nbsp;run&amp;nbsp;at&amp;nbsp;compile&amp;nbsp;time!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2; cursor: pointer;&quot;&gt;isDogCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;char*&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;type)&amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2; cursor: pointer;&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto; color: #d33682; cursor: pointer;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;]&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198; cursor: pointer;&quot;&gt;&#39;D&#39;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: #657b83; border-color: rgb(101, 123, 131); box-sizing: border-box; color: #9a847c; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; cursor: pointer; height: 6px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 632px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; cursor: pointer; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 632px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; cursor: pointer; height: 84px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; cursor: pointer; height: 84px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; cursor: pointer; left: 0px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;201&quot; style=&quot;animation: auto !important; cursor: pointer !important; height: 84px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;201&quot; style=&quot;animation: auto !important; cursor: pointer !important; height: 84px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.2); cursor: pointer; height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
**This same function can be used in BOTH ways:**&quot; data-section-index=&quot;4&quot; id=&quot;markdown-section-e3980c6a-c0f7-4cde-b105-fbe7b766b780-4&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;This&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;same&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;function can be&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;use&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;d in&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;BOTH ways:&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

### ✅ Use 1: Compile-time evaluation
```cpp
// Used in &amp;quot;if constexpr&amp;quot; - evaluated at COMPILE TIME
if constexpr (isDogCompileTime(&amp;quot;Dog&amp;quot;)) {
    // Compiler evaluates this during compilation
}

// Or store in constexpr variable - evaluated at COMPILE TIME
constexpr bool result = isDogCompileTime(&amp;quot;Cat&amp;quot;);
```&quot; data-section-index=&quot;5&quot; id=&quot;markdown-section-e3980c6a-c0f7-4cde-b105-fbe7b766b780-5&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h3 style=&quot;animation: 0.25s fade-in; font-size: 1.15em; line-height: 1.25; margin-bottom: 8px; margin-top: 18px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;✅ Use&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;1: Compile-time evaluation&lt;/span&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;fd996fd6-0fd6-4b17-88aa-3cb268e1a162&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 147.656px; width: 646.009px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.380392 0.380392 0.380392 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #fdf6e3; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;105&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto; height: 138px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs&quot; data-uri=&quot;composer-code-block-anysphere://bymzwqrbcf&quot; role=&quot;code&quot; style=&quot;--vscode-editor-placeholder-foreground: rgba(0, 0, 0, 0.47); animation: auto; height: 138px; overflow-wrap: normal; overflow: visible; position: relative; width: 632px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 138px; overflow: hidden; position: relative; width: 632px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 138px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 138px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 138px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 138px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 632px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 138px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 632px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;//&amp;nbsp;Used&amp;nbsp;in&amp;nbsp;&quot;if&amp;nbsp;constexpr&quot;&amp;nbsp;-&amp;nbsp;evaluated&amp;nbsp;at&amp;nbsp;COMPILE&amp;nbsp;T&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;IME&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;isDogCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198;&quot;&gt;&quot;Dog&quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;))&amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Compiler&amp;nbsp;evaluates&amp;nbsp;this&amp;nbsp;during&amp;nbsp;compilation&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;//&amp;nbsp;Or&amp;nbsp;store&amp;nbsp;in&amp;nbsp;constexpr&amp;nbsp;variable&amp;nbsp;-&amp;nbsp;evaluated&amp;nbsp;at&amp;nbsp;C&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;OMPILE&amp;nbsp;TIME&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;result&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;isDogCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198;&quot;&gt;&quot;Cat&quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: #657b83; border-color: rgb(101, 123, 131); box-sizing: border-box; color: #9a847c; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 6px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 632px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 632px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 138px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 138px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 138px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 138px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;331&quot; style=&quot;animation: auto !important; height: 138px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;331&quot; style=&quot;animation: auto !important; height: 138px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(253, 246, 227) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center&quot; style=&quot;align-items: center; animation: auto; border-style: none; color: #616161; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h3&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

### ✅ Use 2: Runtime evaluation
```cpp
// Called with runtime variable - evaluated at RUNTIME
const char* runtimeString = getUserInput();  // Can&#39;t know at compile time
bool result = isDogCompileTime(runtimeString);  // Runs during program execution
```&quot; data-section-index=&quot;6&quot; id=&quot;markdown-section-e3980c6a-c0f7-4cde-b105-fbe7b766b780-6&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h3 style=&quot;animation: 0.25s fade-in; font-size: 1.15em; line-height: 1.25; margin-bottom: 8px; margin-top: 18px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;✅ Use 2: Runtime evaluation&lt;/span&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;6a20c640-5e73-4f24-ab56-21bdca013249&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 75.6575px; width: 646.009px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.380392 0.380392 0.380392 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #fdf6e3; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;106&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto; height: 66px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs&quot; data-uri=&quot;composer-code-block-anysphere://hdhvmmaeqa&quot; role=&quot;code&quot; style=&quot;--vscode-editor-placeholder-foreground: rgba(0, 0, 0, 0.47); animation: auto; height: 66px; overflow-wrap: normal; overflow: visible; position: relative; width: 632px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 66px; overflow: hidden; position: relative; width: 632px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 66px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 66px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 66px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 66px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 632px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 66px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 632px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;//&amp;nbsp;Called&amp;nbsp;with&amp;nbsp;runtime&amp;nbsp;variable&amp;nbsp;-&amp;nbsp;evaluated&amp;nbsp;at&amp;nbsp;RUN&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;TIME&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;runtimeString&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;getUserInput&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Can&#39;t&amp;nbsp;know&amp;nbsp;at&amp;nbsp;compile&amp;nbsp;time&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;result&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;isDogCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;(runtimeString);&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Runs&amp;nbsp;during&amp;nbsp;program&amp;nbsp;execution&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: #657b83; border-color: rgb(101, 123, 131); box-sizing: border-box; color: #9a847c; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 6px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 632px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 632px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 66px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 66px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 66px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 66px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;158&quot; style=&quot;animation: auto !important; height: 66px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;158&quot; style=&quot;animation: auto !important; height: 66px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(253, 246, 227) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center&quot; style=&quot;align-items: center; animation: auto; border-style: none; color: #616161; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h3&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## `consteval` - NOT Flexible (Compile time only)&quot; data-section-index=&quot;7&quot; id=&quot;markdown-section-e3980c6a-c0f7-4cde-b105-fbe7b766b780-7&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;consteval&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;- NOT&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;Flexible&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;(Compile&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;time&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;only)&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```20:23:/workspace/____ck_task_3233/study_c++/dispatcher_pattern/02_constexpr_functions.cpp
// Consteval (C++20) - MUST run at compile time
consteval bool isDogMustCompileTime(const char* type) {
    return type[0] == &#39;D&#39;;
}
```&quot; data-section-index=&quot;8&quot; id=&quot;markdown-section-e3980c6a-c0f7-4cde-b105-fbe7b766b780-8&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;5033340c-99cd-410a-ae54-36c38abc4365&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 122.487px; width: 646.009px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.380392 0.380392 0.380392 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;composer-code-block-header&quot; style=&quot;align-items: center; animation: 0.25s fade-in; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; border-bottom-color: color(srgb 0.380392 0.380392 0.380392 / 0.12); border-bottom-style: solid; border-bottom-width: 0.833333px; cursor: pointer; display: flex; gap: 6px; height: 28px; justify-content: space-between; max-width: 100%; overflow: hidden; padding: 0px 8px 0px 6px; position: sticky; scrollbar-width: none; transition: background 0.1s ease-in-out; z-index: 2;&quot;&gt;&lt;div class=&quot;composer-code-block-file-info&quot; style=&quot;align-items: center; animation: 0.25s fade-in; box-sizing: border-box; display: flex; flex: 1 1 0%; gap: 6px; min-width: 0px; overflow: auto hidden; scrollbar-width: none;&quot;&gt;&lt;span class=&quot;composer-primary-toolcall-icon&quot; style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; height: 16px; justify-content: center; width: 16px;&quot;&gt;&lt;div class=&quot;show-file-icons&quot; style=&quot;animation: 0.25s fade-in; height: 18px;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; height: 17.9948px; justify-content: center; position: relative; width: 15.9961px;&quot;&gt;&lt;div class=&quot;monaco-icon-label file-icon cpp-lang-file-icon height-override-important file-icon-override&quot; style=&quot;animation: 0.25s fade-in; display: flex; height: 17.9948px; overflow: hidden; text-overflow: ellipsis;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;span class=&quot;composer-code-block-filename&quot; style=&quot;animation: 0.25s fade-in; direction: rtl; font-size: 12px; line-height: 14.4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in; direction: ltr; unicode-bidi: embed;&quot;&gt;02_constexpr_functions.cpp&lt;span style=&quot;animation: 0.25s fade-in; color: #717171; margin-left: 6px; opacity: 0.8;&quot;&gt;Lines 20-23&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: 0.25s fade-in; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #fdf6e3; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: calc(100% - 6px); pointer-events: none; position: absolute; right: 0px; top: 0px; width: 644.342px; z-index: 1;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-clickable=&quot;true&quot; data-keybinding-context=&quot;107&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto; cursor: pointer; height: 84px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs&quot; data-uri=&quot;composer-code-block-anysphere://njvcpnbgdf&quot; role=&quot;code&quot; style=&quot;--vscode-editor-placeholder-foreground: rgba(0, 0, 0, 0.47); animation: auto; cursor: pointer; height: 84px; overflow-wrap: normal; overflow: visible; position: relative; width: 632px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; overflow: hidden; position: relative; width: 632px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; cursor: pointer; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; height: 84px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 84px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; cursor: pointer; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 632px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 84px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 632px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; cursor: pointer; font-style: italic;&quot;&gt;//&amp;nbsp;Consteval&amp;nbsp;(C++20)&amp;nbsp;-&amp;nbsp;MUST&amp;nbsp;run&amp;nbsp;at&amp;nbsp;compile&amp;nbsp;time&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;consteval&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2; cursor: pointer;&quot;&gt;isDogMustCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; cursor: pointer; font-weight: bold;&quot;&gt;char*&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;type)&amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2; cursor: pointer;&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto; color: #d33682; cursor: pointer;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;]&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900; cursor: pointer;&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198; cursor: pointer;&quot;&gt;&#39;D&#39;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; cursor: pointer; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: #657b83; border-color: rgb(101, 123, 131); box-sizing: border-box; color: #9a847c; cursor: pointer; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; cursor: pointer; height: 6px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 632px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; cursor: pointer; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 632px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; cursor: pointer; height: 84px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; cursor: pointer; height: 84px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; cursor: pointer; left: 0px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; cursor: pointer; height: 84px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;201&quot; style=&quot;animation: auto !important; cursor: pointer !important; height: 84px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;201&quot; style=&quot;animation: auto !important; cursor: pointer !important; height: 84px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; cursor: pointer; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.2); cursor: pointer; height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: pointer; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto; cursor: pointer;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
**This can ONLY be used at compile time:**&quot; data-section-index=&quot;10&quot; id=&quot;markdown-section-e3980c6a-c0f7-4cde-b105-fbe7b766b780-10&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;This can&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;ONLY be used at&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;compile time:&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```cpp
// ✅ OK - compile time
if constexpr (isDogMustCompileTime(&amp;quot;Dog&amp;quot;)) { }

// ❌ ERROR - can&#39;t use with runtime values
const char* runtimeString = getUserInput();
bool result = isDogMustCompileTime(runtimeString);  // COMPILE ERROR!
```&quot; data-section-index=&quot;11&quot; id=&quot;markdown-section-e3980c6a-c0f7-4cde-b105-fbe7b766b780-11&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;1b51c651-0ac8-4409-9257-79bc6f8ee8cb&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 129.661px; width: 646.009px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.380392 0.380392 0.380392 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #fdf6e3; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;108&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto; height: 120px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs&quot; data-uri=&quot;composer-code-block-anysphere://wdbyuzdxzz&quot; role=&quot;code&quot; style=&quot;--vscode-editor-placeholder-foreground: rgba(0, 0, 0, 0.47); animation: auto; height: 120px; overflow-wrap: normal; overflow: visible; position: relative; width: 632px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 120px; overflow: hidden; position: relative; width: 632px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 120px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 120px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 120px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 120px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 632px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 120px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 632px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;//&amp;nbsp;✅&amp;nbsp;OK&amp;nbsp;-&amp;nbsp;compile&amp;nbsp;time&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;isDogMustCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198;&quot;&gt;&quot;Dog&quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;))&amp;nbsp;{&amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;//&amp;nbsp;❌&amp;nbsp;ERROR&amp;nbsp;-&amp;nbsp;can&#39;t&amp;nbsp;use&amp;nbsp;with&amp;nbsp;runtime&amp;nbsp;values&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;runtimeString&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;getUserInput&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;result&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;isDogMustCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;(runtimeString);&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;COMPILE&amp;nbsp;ERROR!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: #657b83; border-color: rgb(101, 123, 131); box-sizing: border-box; color: #9a847c; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 6px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 632px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 632px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 120px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 120px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 120px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 120px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;288&quot; style=&quot;animation: auto !important; height: 120px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;288&quot; style=&quot;animation: auto !important; height: 120px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(253, 246, 227) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center&quot; style=&quot;align-items: center; animation: auto; border-style: none; color: #616161; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## Summary&quot; data-section-index=&quot;12&quot; id=&quot;markdown-section-e3980c6a-c0f7-4cde-b105-fbe7b766b780-12&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Summary&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;div class=&quot;monaco-scrollable-element mac&quot; role=&quot;presentation&quot; style=&quot;background-color: #fdf6e3; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; margin: 1em 0px; orphans: 2; overflow: hidden; position: relative; scrollbar-width: none; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2; width: 646.009px;&quot;&gt;&lt;div style=&quot;overflow: hidden;&quot;&gt;&lt;table class=&quot;markdown-table&quot; style=&quot;border-collapse: collapse; font-size: inherit;&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; text-align: left; white-space: nowrap;&quot;&gt;Feature&lt;/th&gt;&lt;th style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; text-align: left; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; line-height: 1.4; word-break: break-all;&quot;&gt;constexpr&lt;/span&gt;&amp;nbsp;(Flexible)&lt;/th&gt;&lt;th style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; text-align: left; white-space: nowrap;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; line-height: 1.4; word-break: break-all;&quot;&gt;consteval&lt;/span&gt;&amp;nbsp;(Strict)&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;Compile-time use&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;✅ Yes&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;✅ Yes&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;Runtime use&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;✅ Yes&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;❌ No&amp;nbsp;(compile&amp;nbsp;error)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;Flexibility&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;Can&amp;nbsp;adapt&amp;nbsp;to context&lt;/td&gt;&lt;td style=&quot;border: 0.833333px solid rgb(200, 200, 200); padding: 6px 13px; white-space: nowrap;&quot;&gt;Must be compile-time only&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;bottom: 0px; height: 10px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 646px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 10px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 646px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;height: 130px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 130px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 10px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
**&amp;quot;Flexible&amp;quot; = The compiler decides when to evaluate it based on context!** 🎯&quot; data-section-index=&quot;15&quot; id=&quot;markdown-section-e3980c6a-c0f7-4cde-b105-fbe7b766b780-15&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&quot;Flexible&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;= The&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;compiler&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;decides when to evaluate it base&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;d on context&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;!&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;🎯&lt;/span&gt;&lt;/section&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;One more thing to clear!! what happened in runtime exactly?&lt;/p&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
When you call a `constexpr` function with runtime values, it simply **executes as a regular function during program execution**.&quot; data-section-index=&quot;2&quot; id=&quot;markdown-section-4170ade8-35c8-46b0-bced-3c3fbe7112ab-2&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;When you call a&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;constexpr&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;function with runtime values, it simply&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;executes as&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;a regular function during&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;program&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;execution&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;.&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## Here&#39;s what happens:&quot; data-section-index=&quot;3&quot; id=&quot;markdown-section-4170ade8-35c8-46b0-bced-3c3fbe7112ab-3&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Here&#39;s what happens:&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```cpp
// Example with constexpr function
constexpr bool isDogCompileTime(const char* type) {
    return type[0] == &#39;D&#39;;  // Check first character
}

// Scenario 1: COMPILE TIME (value known at compile)
if constexpr (isDogCompileTime(&amp;quot;Dog&amp;quot;)) {  
    // ↑ Compiler evaluates: &amp;quot;Dog&amp;quot;[0] == &#39;D&#39; → true
    // Decision made BEFORE program runs
}

// Scenario 2: RUNTIME (value unknown until program runs)
const char* runtimeString = getUserInput();  // User types something
bool result = isDogCompileTime(runtimeString);  
    // ↑ Program executes this code WHILE running
    // Checks runtimeString[0] == &#39;D&#39; at runtime
    // Just like a normal function!
```&quot; data-section-index=&quot;4&quot; id=&quot;markdown-section-4170ade8-35c8-46b0-bced-3c3fbe7112ab-4&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;9446dc37-c985-4e79-899b-0ce41dd1041c&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 327.656px; width: 646.009px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.380392 0.380392 0.380392 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #fdf6e3; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;109&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto; height: 318px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs&quot; data-uri=&quot;composer-code-block-anysphere://vmuwcoijcg&quot; role=&quot;code&quot; style=&quot;--vscode-editor-placeholder-foreground: rgba(0, 0, 0, 0.47); animation: auto; height: 318px; overflow-wrap: normal; overflow: visible; position: relative; width: 632px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 318px; overflow: hidden; position: relative; width: 632px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 318px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 318px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 318px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 150px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 168px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 186px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 204px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 222px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 240px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 258px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 276px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 294px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 318px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 632px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 150px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 168px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 186px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 204px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 222px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 240px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 258px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 276px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 294px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 318px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 632px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;//&amp;nbsp;Example&amp;nbsp;with&amp;nbsp;constexpr&amp;nbsp;function&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;isDogCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;char*&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;type)&amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto; color: #d33682;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;]&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198;&quot;&gt;&#39;D&#39;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Check&amp;nbsp;first&amp;nbsp;character&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;//&amp;nbsp;Scenario&amp;nbsp;1:&amp;nbsp;COMPILE&amp;nbsp;TIME&amp;nbsp;(value&amp;nbsp;known&amp;nbsp;at&amp;nbsp;compil&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;e)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;isDogCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198;&quot;&gt;&quot;Dog&quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;))&amp;nbsp;{&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;↑&amp;nbsp;Compiler&amp;nbsp;evaluates:&amp;nbsp;&quot;Dog&quot;[0]&amp;nbsp;==&amp;nbsp;&#39;D&#39;&amp;nbsp;→&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 150px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Decision&amp;nbsp;made&amp;nbsp;BEFORE&amp;nbsp;program&amp;nbsp;runs&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 168px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 186px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 204px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;//&amp;nbsp;Scenario&amp;nbsp;2:&amp;nbsp;RUNTIME&amp;nbsp;(value&amp;nbsp;unknown&amp;nbsp;until&amp;nbsp;progra&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;m&amp;nbsp;runs)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 222px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;runtimeString&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;getUserInput&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;User&amp;nbsp;types&amp;nbsp;something&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 240px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;result&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;isDogCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;(runtimeString);&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 258px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;↑&amp;nbsp;Program&amp;nbsp;executes&amp;nbsp;this&amp;nbsp;code&amp;nbsp;WHILE&amp;nbsp;running&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 276px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Checks&amp;nbsp;runtimeString[0]&amp;nbsp;==&amp;nbsp;&#39;D&#39;&amp;nbsp;at&amp;nbsp;runtime&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 294px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Just&amp;nbsp;like&amp;nbsp;a&amp;nbsp;normal&amp;nbsp;function!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: #657b83; border-color: rgb(101, 123, 131); box-sizing: border-box; color: #9a847c; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 6px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 632px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 632px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 318px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 318px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 318px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 318px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;763&quot; style=&quot;animation: auto !important; height: 318px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;763&quot; style=&quot;animation: auto !important; height: 318px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(253, 246, 227) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center&quot; style=&quot;align-items: center; animation: auto; border-style: none; color: #616161; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## Think of `constexpr` like this:&quot; data-section-index=&quot;5&quot; id=&quot;markdown-section-4170ade8-35c8-46b0-bced-3c3fbe7112ab-5&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Think&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;of&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;constexpr&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;like&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;this&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

```cpp
constexpr bool isDogCompileTime(const char* type) {
    return type[0] == &#39;D&#39;;
}

// Is basically saying:
// &amp;quot;Hey compiler, I&#39;m a function that:
//  - If you CAN figure out my result during compilation → do it!
//  - If you CAN&#39;T (because input is runtime) → just run me normally!&amp;quot;
```&quot; data-section-index=&quot;6&quot; id=&quot;markdown-section-4170ade8-35c8-46b0-bced-3c3fbe7112ab-6&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;62ac5bf5-7cce-473b-bc43-e0aa123aad8f&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 165.658px; width: 646.009px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.380392 0.380392 0.380392 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #fdf6e3; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;110&quot; data-mode-id=&quot;worktree-cpp&quot; style=&quot;animation: auto; height: 156px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs&quot; data-uri=&quot;composer-code-block-anysphere://rcbdamuuwe&quot; role=&quot;code&quot; style=&quot;--vscode-editor-placeholder-foreground: rgba(0, 0, 0, 0.47); animation: auto; height: 156px; overflow-wrap: normal; overflow: visible; position: relative; width: 632px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 156px; overflow: hidden; position: relative; width: 632px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 156px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 156px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 156px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 156px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 632px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 156px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 632px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;constexpr&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;isDogCompileTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk9 mtkb&quot; style=&quot;animation: auto; color: #586e75; font-weight: bold;&quot;&gt;char*&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;type)&amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk7&quot; style=&quot;animation: auto; color: #268bd2;&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk6&quot; style=&quot;animation: auto; color: #d33682;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;]&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot; style=&quot;animation: auto; color: #859900;&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk4&quot; style=&quot;animation: auto; color: #2aa198;&quot;&gt;&#39;D&#39;&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 60px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span style=&quot;animation: auto;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 78px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;//&amp;nbsp;Is&amp;nbsp;basically&amp;nbsp;saying:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 96px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;//&amp;nbsp;&quot;Hey&amp;nbsp;compiler,&amp;nbsp;I&#39;m&amp;nbsp;a&amp;nbsp;function&amp;nbsp;that:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 114px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;//&amp;nbsp;&amp;nbsp;-&amp;nbsp;If&amp;nbsp;you&amp;nbsp;CAN&amp;nbsp;figure&amp;nbsp;out&amp;nbsp;my&amp;nbsp;result&amp;nbsp;during&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;compilation&amp;nbsp;→&amp;nbsp;do&amp;nbsp;it!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 132px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;//&amp;nbsp;&amp;nbsp;-&amp;nbsp;If&amp;nbsp;you&amp;nbsp;CAN&#39;T&amp;nbsp;(because&amp;nbsp;input&amp;nbsp;is&amp;nbsp;runtime)&amp;nbsp;→&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mtk3 mtki&quot; style=&quot;animation: auto; color: #93a1a1; font-style: italic;&quot;&gt;just&amp;nbsp;run&amp;nbsp;me&amp;nbsp;normally!&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: #657b83; border-color: rgb(101, 123, 131); box-sizing: border-box; color: #9a847c; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 6px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 632px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 632px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 156px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 156px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 156px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 156px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;374&quot; style=&quot;animation: auto !important; height: 156px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;374&quot; style=&quot;animation: auto !important; height: 156px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(253, 246, 227) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center&quot; style=&quot;align-items: center; animation: auto; border-style: none; color: #616161; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;

## Visual Timeline:&quot; data-section-index=&quot;7&quot; id=&quot;markdown-section-4170ade8-35c8-46b0-bced-3c3fbe7112ab-7&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;h2 style=&quot;animation: 0.25s fade-in; font-size: 1.3em; line-height: 1.25; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;Visual&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;Timeline&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;:&lt;/span&gt;&lt;/h2&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
**Compile Time** (if arguments are constants):&quot; data-section-index=&quot;9&quot; id=&quot;markdown-section-4170ade8-35c8-46b0-bced-3c3fbe7112ab-9&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;Compile Time&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;(if&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;arguments&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;are constants&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;):&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
```
Compiler: &amp;quot;isDogCompileTime(&amp;quot;Dog&amp;quot;)? Let me compute... type[0]=&#39;D&#39;==&#39;D&#39;? TRUE!&amp;quot;
          &amp;quot;I&#39;ll just replace this with &#39;true&#39; in the compiled code&amp;quot;
```&quot; data-section-index=&quot;10&quot; id=&quot;markdown-section-4170ade8-35c8-46b0-bced-3c3fbe7112ab-10&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;a7292def-c8b2-473a-8f1d-4b4c3fd42290&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 57.6562px; width: 646.009px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.380392 0.380392 0.380392 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #fdf6e3; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;111&quot; data-mode-id=&quot;plaintext&quot; style=&quot;animation: auto; height: 48px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs&quot; data-uri=&quot;composer-code-block-anysphere://iokvpoomsd&quot; role=&quot;code&quot; style=&quot;--vscode-editor-placeholder-foreground: rgba(0, 0, 0, 0.47); animation: auto; height: 48px; overflow-wrap: normal; overflow: visible; position: relative; width: 632px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 48px; overflow: hidden; position: relative; width: 632px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 48px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 48px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 48px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 48px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 632px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 48px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 632px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;Compiler:&amp;nbsp;&quot;isDogCompileTime(&quot;Dog&quot;)?&amp;nbsp;Let&amp;nbsp;me&amp;nbsp;compute&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;...&amp;nbsp;type[0]=&#39;D&#39;==&#39;D&#39;?&amp;nbsp;TRUE!&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;I&#39;ll&amp;nbsp;just&amp;nbsp;replace&amp;nbsp;this&amp;nbsp;with&amp;nbsp;&#39;true&#39;&amp;nbsp;in&amp;nbsp;t&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;he&amp;nbsp;compiled&amp;nbsp;code&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: #657b83; border-color: rgb(101, 123, 131); box-sizing: border-box; color: #9a847c; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 6px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 632px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 632px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 48px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 48px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 48px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 48px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;115&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;115&quot; style=&quot;animation: auto !important; height: 48px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(253, 246, 227) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center&quot; style=&quot;align-items: center; animation: auto; border-style: none; color: #616161; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
**Runtime** (if arguments are not constants):&quot; data-section-index=&quot;12&quot; id=&quot;markdown-section-4170ade8-35c8-46b0-bced-3c3fbe7112ab-12&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;Runtime&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;(if arguments are not&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;constants):&lt;/span&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
```
Program: &amp;quot;User entered &#39;Cat&#39;... let me call isDogCompileTime(&#39;Cat&#39;)...&amp;quot;
         &amp;quot;Checking: &#39;Cat&#39;[0] == &#39;D&#39;? That&#39;s &#39;C&#39; == &#39;D&#39;? FALSE!&amp;quot;
         &amp;quot;Return false&amp;quot;
```&quot; data-section-index=&quot;13&quot; id=&quot;markdown-section-4170ade8-35c8-46b0-bced-3c3fbe7112ab-13&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;div class=&quot;markdown-code-outer-container&quot; id=&quot;88d08566-1a09-4985-a33a-6653eccf752a&quot; style=&quot;align-items: center; animation: 0.25s fade-in; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; height: 75.6575px; width: 646.009px;&quot;&gt;&lt;div class=&quot;composer-code-block-container composer-message-codeblock&quot; style=&quot;animation: 0.25s fade-in; border-image: none; border-radius: 8px; border-style: solid; border-width: 0.833333px; border: 0.833333px solid color(srgb 0.380392 0.380392 0.380392 / 0.08) !important; contain: paint; display: flex; flex-direction: column; margin: 4px 0px; position: relative; transition: border-color 0.1s ease-in-out;&quot;&gt;&lt;div style=&quot;animation: 0.25s fade-in; position: relative;&quot;&gt;&lt;div class=&quot;composer-code-block-content&quot; style=&quot;--vscode-sidebar-background: #fdf6e3; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: none; background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; box-sizing: border-box; overflow: auto hidden; padding: 0px 6px; position: relative; scrollbar-width: none;&quot;&gt;&lt;div class=&quot;scrollable-div-container show-only-on-hover&quot; data-keybinding-context=&quot;112&quot; data-mode-id=&quot;plaintext&quot; style=&quot;animation: auto; height: 66px;&quot;&gt;&lt;div class=&quot;monaco-editor no-user-select mac showUnused showDeprecated vs&quot; data-uri=&quot;composer-code-block-anysphere://hqjzkzeplh&quot; role=&quot;code&quot; style=&quot;--vscode-editor-placeholder-foreground: rgba(0, 0, 0, 0.47); animation: auto; height: 66px; overflow-wrap: normal; overflow: visible; position: relative; width: 632px;&quot;&gt;&lt;div class=&quot;overflow-guard&quot; data-mprt=&quot;3&quot; style=&quot;animation: auto; height: 66px; overflow: hidden; position: relative; width: 632px;&quot;&gt;&lt;textarea aria-autocomplete=&quot;none&quot; aria-label=&quot;The editor is not accessible at this time. To enable screen reader optimized mode, use Shift+Option+F1&quot; aria-multiline=&quot;true&quot; aria-required=&quot;false&quot; aria-roledescription=&quot;editor&quot; autocapitalize=&quot;off&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; class=&quot;inputarea monaco-mouse-cursor-text&quot; data-mprt=&quot;7&quot; role=&quot;textbox&quot; spellcheck=&quot;false&quot; style=&quot;animation: auto; border-style: none; border-width: medium; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; font-weight: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; margin: 0px; min-height: 0px; min-width: 0px; outline: currentcolor; overflow: hidden; padding: 0px; position: absolute; resize: none; tab-size: 28.8906px; top: 6px; width: 1px; z-index: -10;&quot; tabindex=&quot;0&quot;&gt;&lt;/textarea&gt;&lt;div class=&quot;monaco-editor-background textAreaCover&quot; style=&quot;animation: auto; height: 0px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin&quot; role=&quot;presentation&quot; style=&quot;animation: auto; contain: strict; height: 66px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;div class=&quot;glyph-margin&quot; style=&quot;animation: auto; height: 66px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;margin-view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 66px; letter-spacing: 0px; line-height: 18px; position: absolute; width: 0px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 0px;&quot;&gt;&lt;div class=&quot;current-line&quot; style=&quot;animation: auto; box-sizing: border-box; height: 17.9948px; left: 0px; position: absolute; top: 0px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;glyph-margin-widgets&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;monaco-scrollable-element editor-scrollable vs mac&quot; data-mprt=&quot;6&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 66px; left: 0px; overflow: hidden; position: absolute; scrollbar-width: none; width: 632px;&quot;&gt;&lt;div class=&quot;lines-content monaco-editor-background&quot; style=&quot;animation: auto; contain: strict; height: 16777200px; left: 0px; overflow: hidden; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 16777200px;&quot;&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-overlays&quot; role=&quot;presentation&quot; style=&quot;animation: auto; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 0px; letter-spacing: 0px; line-height: 18px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-rulers&quot; role=&quot;presentation&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-zones&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;view-lines monaco-mouse-cursor-text&quot; data-mprt=&quot;8&quot; role=&quot;presentation&quot; style=&quot;animation: auto; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 66px; letter-spacing: 0px; line-height: 18px; position: absolute; white-space: nowrap; width: 632px;&quot;&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 6px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;Program:&amp;nbsp;&quot;User&amp;nbsp;entered&amp;nbsp;&#39;Cat&#39;...&amp;nbsp;let&amp;nbsp;me&amp;nbsp;call&amp;nbsp;isDogC&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;ompileTime(&#39;Cat&#39;)...&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 24px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;Checking:&amp;nbsp;&#39;Cat&#39;[0]&amp;nbsp;==&amp;nbsp;&#39;D&#39;?&amp;nbsp;That&#39;s&amp;nbsp;&#39;C&#39;&amp;nbsp;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&#39;D&#39;?&amp;nbsp;FALSE!&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;view-line&quot; style=&quot;animation: auto; height: 18px; position: absolute; top: 42px; width: 631.999px;&quot;&gt;&lt;span style=&quot;animation: auto; bottom: 0px; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;span class=&quot;mtk1&quot; style=&quot;animation: auto;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;Return&amp;nbsp;false&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;contentWidgets&quot; data-mprt=&quot;1&quot; style=&quot;animation: auto; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;cursors-layer cursor-line-thin-style cursor-solid&quot; role=&quot;presentation&quot; style=&quot;animation: auto; position: absolute; top: 0px; z-index: 4;&quot;&gt;&lt;div class=&quot;cursor monaco-mouse-cursor-text&quot; style=&quot;animation: auto; background-color: #657b83; border-color: rgb(101, 123, 131); box-sizing: border-box; color: #9a847c; cursor: text; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-feature-settings: &amp;quot;liga&amp;quot; 0, &amp;quot;calt&amp;quot; 0; font-size: 12px; font-variation-settings: normal; height: 18px; left: 0px; letter-spacing: 0px; line-height: 18px; overflow: hidden; padding-left: 0px; position: absolute; top: 6px; visibility: hidden; width: 0.833333px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar horizontal&quot; role=&quot;presentation&quot; style=&quot;animation: auto; bottom: 0px; height: 6px; left: 0px; opacity: 0; pointer-events: none; position: absolute; visibility: hidden; width: 632px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 6px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 632px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;invisible scrollbar vertical&quot; role=&quot;presentation&quot; style=&quot;animation: auto; box-shadow: none; height: 66px; opacity: 0; pointer-events: none; position: absolute; right: 0px; top: 0px; visibility: hidden; width: 0px;&quot;&gt;&lt;div class=&quot;slider&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.4); contain: strict; height: 66px; left: 0px; position: absolute; top: 0px; transform: translate3d(0px, 0px, 0px); width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; role=&quot;presentation&quot; style=&quot;animation: auto; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overlayWidgets&quot; data-mprt=&quot;4&quot; style=&quot;animation: auto; left: 0px; position: absolute; top: 0px; width: 632px;&quot;&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;minimap slider-mouseover&quot; data-mprt=&quot;9&quot; role=&quot;presentation&quot; style=&quot;animation: auto; height: 66px; left: 0px; position: absolute; width: 0px; z-index: 11;&quot;&gt;&lt;div class=&quot;minimap-shadow-hidden&quot; style=&quot;animation: auto; height: 66px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;canvas height=&quot;158&quot; style=&quot;animation: auto !important; height: 66px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;canvas class=&quot;minimap-decorations-layer&quot; height=&quot;158&quot; style=&quot;animation: auto !important; height: 66px; left: 0px; position: absolute; width: 0px;&quot; width=&quot;0&quot;&gt;&lt;/canvas&gt;&lt;div class=&quot;minimap-slider&quot; style=&quot;animation: auto; contain: strict; opacity: 0; position: absolute; transform: translate3d(0px, 0px, 0px); transition: opacity 0.1s linear; width: 0px;&quot;&gt;&lt;div class=&quot;minimap-slider-horizontal&quot; style=&quot;animation: auto; background: 0% 0% repeat rgba(100, 100, 100, 0.2); height: 0px; position: absolute; width: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div aria-hidden=&quot;true&quot; class=&quot;blockDecorations-container&quot; role=&quot;presentation&quot; style=&quot;animation: auto; pointer-events: none; position: absolute; top: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;overflowingContentWidgets&quot; data-mprt=&quot;2&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;overflowingOverlayWidgets&quot; data-mprt=&quot;5&quot; style=&quot;animation: auto;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;composer-codeblock-copy-overlay&quot; style=&quot;align-items: center; animation: auto; background-attachment: scroll; background-clip: border-box; background-image: linear-gradient(to left, rgb(253, 246, 227) 80%, rgba(0, 0, 0, 0) 100%); background-origin: padding-box; background-position: 0% 0%; background-repeat: repeat; background-size: auto; display: flex; position: absolute; right: 6px; top: 6px; z-index: 2;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; justify-content: flex-end; overflow: hidden; position: relative;&quot;&gt;&lt;div style=&quot;align-items: center; animation: auto; display: flex; flex-shrink: 0; justify-content: flex-end; justify-self: flex-end; position: relative;&quot;&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 20px; margin-left: 4px; opacity: 1; pointer-events: auto; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;div class=&quot;anysphere-icon-button bg-[transparent] border-none text-[var(--cursor-text-primary)] flex w-4 items-center justify-center&quot; style=&quot;align-items: center; animation: auto; border-style: none; color: #616161; cursor: pointer; display: flex; height: 20px; justify-content: center; opacity: 0.5; outline: currentcolor; width: 20px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;animation: auto; flex-shrink: 0; height: 0px; opacity: 0; pointer-events: none; transition: opacity 0.1s ease-in-out;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;markdown-section chat-fade-in&quot; data-markdown-raw=&quot;
So yes, **`constexpr` with runtime values = normal function execution!** 🎯&quot; data-section-index=&quot;15&quot; id=&quot;markdown-section-4170ade8-35c8-46b0-bced-3c3fbe7112ab-15&quot; style=&quot;background-color: #fdf6e3; border-radius: 4px; color: #657b83; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; font-variant-ligatures: normal; line-height: 19.5px; margin: 6px 0px; orphans: 2; position: relative; scroll-margin-bottom: 40px; scroll-margin-top: 40px; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; widows: 2;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;So&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;yes&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;markdown-bold-text&quot; style=&quot;animation: 0.25s fade-in; font-weight: 600;&quot;&gt;&lt;span class=&quot;markdown-inline-code leading-[1.4]&quot; style=&quot;animation: 0.25s fade-in; background-color: color(srgb 0.709865 0.735345 0.743452 / 0.454118); border-radius: 4px; cursor: default; font-family: Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace, Menlo, Monaco, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.9em; line-height: 1.4; padding: 1.5px 3px; transition: 0.1s; word-break: break-all;&quot;&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;constexpr&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;with&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;runtime values&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;= normal&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;function execution&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;!&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;animation: 0.25s fade-in;&quot;&gt;🎯&lt;/span&gt;&lt;/section&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;That&#39;s it.&lt;/p&gt;&lt;p&gt;Thank you!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Study.marearts.com!!!&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://study.marearts.com/feeds/2455174639429686304/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://study.marearts.com/2025/12/c-constexpr-02constexprfunctionscpp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/2455174639429686304'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8995455167205656082/posts/default/2455174639429686304'/><link rel='alternate' type='text/html' href='http://study.marearts.com/2025/12/c-constexpr-02constexprfunctionscpp.html' title='c++ constexpr #02_constexpr_functions.cpp'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>