{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,8,24]],"date-time":"2026-08-24T17:25:52Z","timestamp":1787592352501,"version":"build-2736575974"},"reference-count":73,"publisher":"Association for Computing Machinery (ACM)","issue":"OOPSLA1","license":[{"start":{"date-parts":[[2025,4,9]],"date-time":"2025-04-09T00:00:00Z","timestamp":1744156800000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/legalcode"}],"funder":[{"DOI":"10.13039\/100000001","name":"National Science Foundation","doi-asserted-by":"publisher","award":["2237440, 2114627"],"award-info":[{"award-number":["2237440, 2114627"]}],"id":[{"id":"10.13039\/100000001","id-type":"DOI","asserted-by":"publisher"}]},{"DOI":"10.13039\/100000185","name":"Defense Advanced Research Projects Agency","doi-asserted-by":"publisher","award":["N66001-21-C-4024"],"award-info":[{"award-number":["N66001-21-C-4024"]}],"id":[{"id":"10.13039\/100000185","id-type":"DOI","asserted-by":"publisher"}]}],"content-domain":{"domain":["dl.acm.org"],"crossmark-restriction":true},"short-container-title":["Proc. ACM Program. Lang."],"published-print":{"date-parts":[[2025,4,9]]},"abstract":"<jats:p>\n                    C++ templates are a powerful feature for generic programming and compile-time computations, but C++compilers often emit overly verbose template error messages. Even short error messages often involve unnecessary and confusing implementation details, which are difficult for developers to read and understand. To address this problem, C++20 introduced\n                    <jats:italic toggle=\"yes\">constraints and concepts<\/jats:italic>\n                    , which impose requirements on template parameters. The new features can define clearer interfaces for templates and can improve compiler diagnostics. However, manually specifying template constraints can still be non-trivial, which becomes even more challenging when working with legacy C++ projects or with frequent code changes.\n                  <\/jats:p>\n                  <jats:p>\n                    This paper bridges the gap and proposes an automatic approach to synthesizing constraints for C++ function templates. We utilize a lightweight static analysis to analyze the usage patterns within the template body and summarize them into constraints for each type parameter of the template. The analysis is inter-procedural and uses disjunctions of constraints to model function overloading. We have implemented our approach based on the Clang frontend and evaluated it on two C++ libraries chosen separately from two popular library sets:\n                    <jats:monospace>algorithm<\/jats:monospace>\n                    from the Standard Template Library (STL) and\n                    <jats:monospace>special_functions<\/jats:monospace>\n                    from the Boost library, both of which extensively use templates. Our tool can process over 110k lines of C++ code in less than 1.5 seconds and synthesize non-trivial constraints for 30%\u201340% of the function templates. The constraints synthesized for\n                    <jats:monospace>algorithm<\/jats:monospace>\n                    align well with the standard documentation and on average, the synthesized constraints can reduce error message lengths by 56.6% for\n                    <jats:monospace>algorithm<\/jats:monospace>\n                    and 63.8% for\n                    <jats:monospace>special_functions<\/jats:monospace>\n                    .\n                  <\/jats:p>","DOI":"10.1145\/3720422","type":"journal-article","created":{"date-parts":[[2025,4,9]],"date-time":"2025-04-09T13:48:26Z","timestamp":1744206506000},"page":"225-252","update-policy":"https:\/\/doi.org\/10.1145\/crossmark-policy","source":"Crossref","is-referenced-by-count":0,"title":["Fast Constraint Synthesis for C++ Function Templates"],"prefix":"10.1145","volume":"9","author":[{"ORCID":"https:\/\/orcid.org\/0000-0003-0843-0729","authenticated-orcid":false,"given":"Shuo","family":"Ding","sequence":"first","affiliation":[{"name":"Georgia Institute of Technology, Atlanta, USA"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0001-5367-9377","authenticated-orcid":false,"given":"Qirun","family":"Zhang","sequence":"additional","affiliation":[{"name":"Georgia Institute of Technology, Atlanta, USA"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"320","published-online":{"date-parts":[[2025,4,9]]},"reference":[{"key":"e_1_3_1_2_2","doi-asserted-by":"publisher","DOI":"10.1145\/1993498.1993569"},{"key":"e_1_3_1_3_2","doi-asserted-by":"publisher","unstructured":"John Altidor Yannis Smaragdakis. 2014. Refactoring Java generics in practice. Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA 2014) 271\u2013290. https:\/\/doi.org\/10.1145\/2660193.2660203 10.1145\/2660193.2660203.","DOI":"10.1145\/2660193.2660203"},{"key":"e_1_3_1_4_2","doi-asserted-by":"publisher","DOI":"10.1007\/11531142_19"},{"key":"e_1_3_1_5_2","doi-asserted-by":"crossref","unstructured":"Wisnu Anggoro John Torjo. 2015. Boost.Asio C++ Network Programming.","DOI":"10.1016\/S1353-4858(15)30108-2"},{"key":"e_1_3_1_6_2","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-642-39799-8_60"},{"key":"e_1_3_1_7_2","doi-asserted-by":"publisher","unstructured":"Jean-Philippe Bernardy Patrik Jansson Marcin Zalewski Sibylle Schupp Andreas P. Priesnitz. 2008. A comparison of C++ concepts and Haskell type classes. Proceedings of the ACM SIGPLAN Workshop on Generic Programming (WGP 2008) 37\u201348. https:\/\/doi.org\/10.1145\/1411318.1411324 10.1145\/1411318.1411324.","DOI":"10.1145\/1411318.1411324"},{"key":"e_1_3_1_8_2","doi-asserted-by":"publisher","DOI":"10.1145\/3314221.3314648"},{"key":"e_1_3_1_9_2","unstructured":"Cppreference. 2024. Class template argument deduction."},{"key":"e_1_3_1_10_2","unstructured":"Cppreference. 2024. CPP named requirements: LegacyInputIterator. https:\/\/en.cppreference.com\/w\/cpp\/named_req\/InputIterator. Accessed in April 2024."},{"key":"e_1_3_1_11_2","unstructured":"Cppreference. 2024. CPP named requirements."},{"key":"e_1_3_1_12_2","unstructured":"Cppreference. 2024. SFINAE."},{"key":"e_1_3_1_13_2","unstructured":"Cppreference. 2024. Template argument deduction."},{"key":"e_1_3_1_14_2","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-030-81685-8_4"},{"key":"e_1_3_1_15_2","doi-asserted-by":"publisher","DOI":"10.1145\/3540203.3540985"},{"key":"e_1_3_1_16_2","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-031-44425-2_12"},{"key":"e_1_3_1_17_2","doi-asserted-by":"publisher","unstructured":"Shuo Ding Qiren Zhang. 2025. Fast Constraint Synthesis for C++ Function Templates (Artifact). Artifact. doi:10.5281\/zenodo.14945421","DOI":"10.5281\/zenodo.14945421"},{"key":"e_1_3_1_18_2","unstructured":"Lee Zhi Eng. 2016. Qt5 C++ GUI Programming Cookbook. Packt Publishing Ltd.."},{"key":"e_1_3_1_19_2","doi-asserted-by":"publisher","DOI":"10.1145\/3009837.3009951"},{"key":"e_1_3_1_20_2","doi-asserted-by":"publisher","DOI":"10.1145\/1612607.1612613"},{"key":"e_1_3_1_21_2","doi-asserted-by":"publisher","DOI":"10.1016\/S0049-237X(98)80049-9"},{"key":"e_1_3_1_22_2","doi-asserted-by":"publisher","DOI":"10.1561\/2500000010"},{"key":"e_1_3_1_23_2","unstructured":"ISO. 2025. A Tour of C++: Containers and Algorithms. https:\/\/isocpp.org\/files\/4-Tour-Algorithm.pdf. Accessed in January 2025 117 pages."},{"key":"e_1_3_1_24_2","unstructured":"ISO. 2024. The Standard Definition of C++. https:\/\/www.iso.org\/standard\/79358.html. Accessed in October 2024."},{"key":"e_1_3_1_25_2","doi-asserted-by":"publisher","DOI":"10.1145\/3498720"},{"key":"e_1_3_1_26_2","unstructured":"Nicolai M. Josuttis. 2012. The C++ Standard Library: A Tutorial and Reference. Addison-Wesley."},{"key":"e_1_3_1_27_2","doi-asserted-by":"publisher","DOI":"10.1145\/3158105"},{"key":"e_1_3_1_28_2","doi-asserted-by":"publisher","unstructured":"Chris Lattner Vikram Adve. 2004. LLVM: A compilation framework for lifelong program analysis & transformation. International Symposium on Code Generation and Optimization (CGO 2004) 75\u201386. doi:10.1109\/CGO.2004.1281665","DOI":"10.1109\/CGO.2004.1281665"},{"key":"e_1_3_1_29_2","doi-asserted-by":"publisher","unstructured":"Benjamin S. Lerner Matthew Flower Dan Grossman Craig Chambers. 2007. Searching for type-error messages. Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2007) 425\u2013434. doi:10.1145\/1250734.1250783","DOI":"10.1145\/1250734.1250783"},{"key":"e_1_3_1_30_2","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-642-22110-1_49"},{"key":"e_1_3_1_31_2","unstructured":"Guodong Li Indradeep Ghosh Sreeranga P. Rajan. 2012. KIL: An Abstract Intermediate Language for Symbolic Execution and Test Generation of C++ Programs. CiteSeer."},{"key":"e_1_3_1_32_2","doi-asserted-by":"publisher","DOI":"10.1145\/3295739"},{"key":"e_1_3_1_33_2","doi-asserted-by":"publisher","DOI":"10.1145\/2644805"},{"key":"e_1_3_1_34_2","doi-asserted-by":"publisher","unstructured":"V. Benjamin Livshits Aditya V. Nori Sriram K. Rajamani Anindya Banerjee. 2009. Merlin: specification inference for explicit information flow problems. Proceedings of PLDI 2009 75\u201384. doi:10.1145\/1542476.1542485","DOI":"10.1145\/1542476.1542485"},{"key":"e_1_3_1_35_2","unstructured":"LLVM. 2024. LLVM Language Reference Manual. Accessed in April 2024."},{"key":"e_1_3_1_36_2","doi-asserted-by":"publisher","DOI":"10.1002\/j.1538-7305.1956.tb03835.x"},{"key":"e_1_3_1_37_2","doi-asserted-by":"publisher","DOI":"10.1002\/STVR.1793"},{"key":"e_1_3_1_38_2","doi-asserted-by":"publisher","DOI":"10.1145\/2806886"},{"key":"e_1_3_1_39_2","doi-asserted-by":"publisher","DOI":"10.3102\/1076998619872761"},{"key":"e_1_3_1_40_2","doi-asserted-by":"publisher","unstructured":"Yun Peng Cuiyun Gao Zongjie Li Bowen Gao David Lo Qirun Zhang Michael R. Lyu. 2022. Static Inference Meets Deep Learning. Proceedings of ESEC\/FSE 2022 2019\u20132030. doi:10.1145\/3510003.3510038","DOI":"10.1145\/3510003.3510038"},{"key":"e_1_3_1_41_2","doi-asserted-by":"publisher","DOI":"10.2307\/2308219"},{"key":"e_1_3_1_42_2","doi-asserted-by":"publisher","DOI":"10.1080\/00029890.1955.11988710"},{"key":"e_1_3_1_43_2","doi-asserted-by":"publisher","unstructured":"Muralik Krishnan Ananth Grama Suresh Jagannathan. 2007. Static specification inference using predicate mining. Proceedings of PLDI 2007 123\u2013134. doi:10.1145\/1250734.1250749","DOI":"10.1145\/1250734.1250749"},{"key":"e_1_3_1_44_2","doi-asserted-by":"publisher","unstructured":"Gabriel Dos Reis Bjarne Stroustrup. 2006. Specifying C++ concepts. Proceedings of POPL 2006 295\u2013308. doi:10.1145\/1111037.1111064","DOI":"10.1145\/1111037.1111064"},{"key":"e_1_3_1_45_2","doi-asserted-by":"publisher","DOI":"10.1145\/2644805"},{"key":"e_1_3_1_46_2","doi-asserted-by":"publisher","unstructured":"V. Benjamin Livshits Aditya V. Nori Sriram K. Rajamani Anindya Banerjee. 2009. Merlin: specification inference for explicit information flow problems. Proceedings of PLDI 2009 75\u201384. doi:10.1145\/1542476.1542485","DOI":"10.1145\/1542476.1542485"},{"key":"e_1_3_1_47_2","unstructured":"LLVM. 2024. LLVM Language Reference Manual. Accessed in April 2024."},{"key":"e_1_3_1_48_2","doi-asserted-by":"publisher","DOI":"10.1002\/j.1538-7305.1956.tb03835.x"},{"key":"e_1_3_1_49_2","doi-asserted-by":"publisher","DOI":"10.1002\/STVR.1793"},{"key":"e_1_3_1_50_2","doi-asserted-by":"publisher","DOI":"10.1145\/2806886"},{"key":"e_1_3_1_51_2","doi-asserted-by":"publisher","DOI":"10.3102\/1076998619872761"},{"key":"e_1_3_1_52_2","doi-asserted-by":"publisher","unstructured":"Yun Peng Cuiyun Gao Zongjie Li Bowen Gao David Lo Qirun Zhang Michael R. Lyu. 2022. Static Inference Meets Deep Learning. Proceedings of ESEC\/FSE 2022 2019\u20132030. doi:10.1145\/3510003.3510038","DOI":"10.1145\/3510003.3510038"},{"key":"e_1_3_1_53_2","doi-asserted-by":"publisher","DOI":"10.2307\/2308219"},{"key":"e_1_3_1_54_2","doi-asserted-by":"publisher","DOI":"10.1080\/00029890.1955.11988710"},{"key":"e_1_3_1_55_2","doi-asserted-by":"publisher","unstructured":"Muralik Krishnan Ananth Grama Suresh Jagannathan. 2007. Static specification inference using predicate mining. Proceedings of PLDI 2007 123\u2013134. doi:10.1145\/1250734.1250749","DOI":"10.1145\/1250734.1250749"},{"key":"e_1_3_1_56_2","doi-asserted-by":"publisher","unstructured":"Gabriel Dos Reis Bjarne Stroustrup. 2006. Specifying C++ concepts. Proceedings of POPL 2006 295\u2013308. doi:10.1145\/1111037.1111064","DOI":"10.1145\/1111037.1111064"},{"key":"e_1_3_1_57_2","doi-asserted-by":"publisher","DOI":"10.1145\/345099.345137"},{"key":"e_1_3_1_58_2","doi-asserted-by":"publisher","DOI":"10.1109\/TSE.2012.63"},{"key":"e_1_3_1_59_2","doi-asserted-by":"publisher","DOI":"10.1007\/11785477_19"},{"key":"e_1_3_1_60_2","doi-asserted-by":"publisher","unstructured":"Saurabh Srivastava Sumit Gulwani Jeffrey S. Foster. 2010. From program verification to program synthesis. Proceedings of POPL 2010 313\u2013326. doi:10.1145\/1706299.1706337","DOI":"10.1145\/1706299.1706337"},{"key":"e_1_3_1_61_2","unstructured":"Stackexchange. 2024. Generate the longest error message in CPP. Accessed in April 2024."},{"key":"e_1_3_1_62_2","unstructured":"StackOverflow. 2024. Compilation error for a binary search on the attributes. Accessed in April 2024."},{"key":"e_1_3_1_63_2","unstructured":"StackOverflow. 2024. Deciphering CPP template error messages. Accessed in April 2024."},{"key":"e_1_3_1_64_2","unstructured":"StackOverflow. 2024. How to improve compiler error messages when using CPP std::visit?. Accessed in April 2024."},{"key":"e_1_3_1_65_2","unstructured":"StackOverflow. 2024. Using std::sort in CPP with iterators and templates. Accessed in October 2024."},{"key":"e_1_3_1_66_2","unstructured":"Bjarne Stroustrup. 2022. A Tour of C++. Addison-Wesley Professional."},{"key":"e_1_3_1_67_2","doi-asserted-by":"publisher","DOI":"10.1145\/3485524"},{"key":"e_1_3_1_68_2","unstructured":"Tumblr. 2024. The Grand CPP Error Explosion Competition. Accessed in April 2024."},{"key":"e_1_3_1_69_2","doi-asserted-by":"publisher","DOI":"10.1109\/TCAD.2005.855944"},{"key":"e_1_3_1_70_2","unstructured":"Todd L. Veldhuizen. 2003. C++ templates are Turing complete. Technical Report Indiana University."},{"key":"e_1_3_1_71_2","doi-asserted-by":"publisher","DOI":"10.1145\/3527312"},{"key":"e_1_3_1_72_2","doi-asserted-by":"publisher","unstructured":"Shengzhe Xu Ziqi Dong Nan Meng. 2019. Monitor: inference and application of API migration edits. Proceedings of the 27th International Conference on Program Comprehension (ICPC 2019) 336\u2013346. doi:10.1109\/ICPC.2019.00052","DOI":"10.1109\/ICPC.2019.00052"},{"key":"e_1_3_1_73_2","doi-asserted-by":"publisher","unstructured":"Zhaoqiu Xu Xiangyu Zhang Lin Chen Kexin Pei Baowen Xu. 2016. Python probabilistic type inference with natural language support. Proceedings of the 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering (FSE 2016) 607\u2013618. doi:10.1145\/2950290.2950343","DOI":"10.1145\/2950290.2950343"},{"key":"e_1_3_1_74_2","doi-asserted-by":"publisher","unstructured":"Qirun Zhang Anders M\u00f8ller. 2017. Context-sensitive data-dependence analysis via linear conjunctive language reachability. Proceedings of the ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017) 344\u2013358. doi:10.1145\/3009837.3009848","DOI":"10.1145\/3009837.3009848"}],"container-title":["Proceedings of the ACM on Programming Languages"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3720422","content-type":"unspecified","content-version":"vor","intended-application":"text-mining"},{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/3720422","content-type":"application\/pdf","content-version":"vor","intended-application":"syndication"},{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/3720422","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2026,8,24]],"date-time":"2026-08-24T16:31:31Z","timestamp":1787589091000},"score":1,"resource":{"primary":{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3720422"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2025,4,9]]},"references-count":73,"journal-issue":{"issue":"OOPSLA1","published-print":{"date-parts":[[2025,4,9]]}},"alternative-id":["10.1145\/3720422"],"URL":"https:\/\/doi.org\/10.1145\/3720422","relation":{},"ISSN":["2475-1421"],"issn-type":[{"value":"2475-1421","type":"electronic"}],"subject":[],"published":{"date-parts":[[2025,4,9]]},"assertion":[{"value":"2024-10-08","order":0,"name":"received","label":"Received","group":{"name":"publication_history","label":"Publication History"}},{"value":"2025-02-18","order":2,"name":"accepted","label":"Accepted","group":{"name":"publication_history","label":"Publication History"}},{"value":"2025-04-09","order":3,"name":"published","label":"Published","group":{"name":"publication_history","label":"Publication History"}}]}}