Cpp
Home * Programming * Languages * C++
C++,
a pragmatical, object oriented, general-purpose programming language,
initially an extension of C and designed and implemented in 1979 by Bjarne Stroustrup from Bell Laboratories.
C++ is pragmatical because one may write in "usual" C-style, using the C standard library (printf, strcpy, ...), except perhaps using C++ comments and references up and then (instead of pointer). On the other hand C++ allows to design classes and interfaces (pure virtual classes) in a more object oriented manner. There are lots of free and commercial class libraries for arithmetics, database related stuff, portable and proprietary window management and whatever else.
Many chess engines are written in C++, varying from using pure C-style, up to extensive use of object oriented stuff and templates as well as C++11 or C++17 features.
Contents
C Extensions
References
Exception Handling
- C++ Programming/Exception Handling from Wikibooks
- Exceptions - C++ Reference
- exception - C++ Reference
Classes
Classes as declaration for objects are more or less C-Structures. None static functions may be declared inside the scope of a class. Those functions, called member functions, have an implicit parameter called "this", a pointer to this structure, allocated either inside the data segment or bss as static or global, via "new" (malloc) on the heap or as automatic object (variable) on the stack.
Data Definition
Member Functions
Modifiers
- Access modifiers from Wikipedia
- Static (keyword) from Wikipedia
- Class variable from Wikipedia
- Static methods from Wikipedia
Pointer to Member Functions
For instance an array of member function pointers of a class CNode, which is indexed by arbitrary pieces code - as switch-case replacement via indirect call/jump. The special atomic C++ operator '->*' is used to call the indexed member-functions:
class CNode { U64 AssertAttack (EnumSquare sq) const; U64 wPawnAttacks (EnumSquare sq) const; U64 bPawnAttacks (EnumSquare sq) const; U64 knightAttacks(EnumSquare sq) const; U64 kingAttacks (EnumSquare sq) const; U64 bishopAttacks(EnumSquare sq) const; U64 rookAttacks (EnumSquare sq) const; U64 queenAttacks (EnumSquare sq) const; ... typedef U64 (CNode::*AttackPtrType)(EnumSquare sq) const; static AttackPtrType m_scPieceAtta[14]; ... U64 getAttack(EnumSquare sq, EnumPiece piece) const {return (this->*m_scPieceAtta[piece])(sq);} }; CNode::AttackPtrType CNode::m_scPieceAtta[14] = { AssertAttack, AssertAttack, wPawnAttacks, bPawnAttacks , bishopAttacks, bishopAttacks, knightAttacks, knightAttacks, rookAttacks, rookAttacks, kingAttacks, kingAttacks, queenAttacks, queenAttacks };
Inheritance
- Inheritance (object-oriented programming) from Wikipedia
- Inheritance from Wikibooks
- C++/Classes and Inheritance - Wikiversity
Function Overloading
Operator Overloading
Late Binding
Abstract Classes
Pure Abstract Classes
Multiple Inheritance
Templates
- Template (programming) from Wikipedia
- List of C++ template libraries from Wikipeadia
- Standard Template Library from Wikipedia
- Loki (C++) from Wikipedia by Andrei Alexandrescu as part of his book Modern C++ Design.
- Boost (C++ libraries) from Wikipedia
- Templates - C++ Documentation
- Metaprogramming in C++
- C++ Programming/Templates from Wikibooks
- Template Meta-Programming from Wikibooks
- Barton–Nackman trick from Wikipedia
- Curiously recurring template pattern from Wikipedia
- Variadic template from Wikipedia
Anonymous Functions
Smart Pointer
- Smart pointer from Wikipedia
- auto_ptr from Wikipedia (C++11 deprecated)
- unique_ptr from Wikipedia
- shared_ptr from Wikipedia
Class Design of a Chess Engine
main article Class Design of a Chess Engine
C++ Compiler
- List of C/C++ compilers from Wikipeadia
- GCC
- Intel C++ Compiler from Wikipeadia
- Visual C++ from Wikipeadia
Libraries
- Standard Template Library from Wikipeadia
- STL Containers - C++ Reference
- C++ Libraries — Software Preservation Group, The Computer History Museum
- Qt (software) from Wikipedia
- Loki (C++) from Wikipedia by Andrei Alexandrescu as part of his book Modern C++ Design.
- BITSCAN, a C++ library for bitstrings by Pablo San Segundo
- Boost (C++ libraries) from Wikipedia
- The Better String Library by Paul Hsieh
- log4cplus / Wiki / Home
- Senjo C++ UCI Adapter by Shawn Chidester » Clubfoot, UCI
See also
C++ Publications
1985 ...
- Bjarne Stroustrup (1985, 1991, 1997, 2000). The C++ Programming Language. Addison-Wesley
- Keith E. Gorlen (1987). An Object-Oriented Class Library for C++ Programs. C++ Workshop 1987
- Bjarne Stroustrup, Andrew Koenig (1989). C++: as close as possible to C -- but no closer. C++ Report, Vol. 1, no. 7
1990 ...
- Andrew Koenig, Bjarne Stroustrup (1990). Exception Handling for C++. Proc USENIX C++ Conference 1990, Also, Journal of Object Oriented Programming, Vol. 3, No. 2
- Keith E. Gorlen, et al. (1990). Data abstraction and object-oriented programming in C++. Wiley [2]
- Andrew Koenig, Thomas A. Cargill, Keith E. Gorlen, Robert B. Murray, Michael Vilot (1991). How Useful is Multiple Inheritance in C++? C++ Conference 1991
- Andrew Koenig (1992). Space-Efficient Trees in C++. C++ Conference 1992
- Scott Meyers (1992,2005). Effective C++: 50 Specific Ways to Improve Your Programs and Designs. Addison-Wesley
- Andrew Koenig (1994). Templates and Generic Algorithms. Journal of Object-Oriented Programming, Vol. 7 No. 3
- Andrew Koenig (1994). Generic Iterators. Journal of Object-Oriented Programming, Vol. 7, No. 5
- Bjarne Stroustrup, Andrew Koenig, Barbara Moo (1994). The C++ Programming Language. Encyclopedia of Software Engineering, Wiley
1995 ...
- Andrew Koenig, Bjarne Stroustrup (1995). Foundations for Native C++ Styles. Software Practice and Experience, Vol 25, special issue S4
- Patrick Winston (1995). On To C++. Addison Wesley
- Greg Wilson, Paul Lu (eds.) (1996). Parallel Programming Using C++. MIT Press
- Leen Ammeraal (1996). Algorithms and Data Structures in C++. John Wiley
- Andrew Koenig, Barbara Moo (1997). Ruminations on C++. Addison-Wesley
- Leen Ammeraal (1997). STL for C++ Programmers. ISBN 0-471-97181-2, Chichester: John Wiley
2000 ...
- Andrew Koenig, Barbara Moo (2000). Accelerated C++. Addison-Wesley
- Leen Ammeraal (2000). C++ for Programmers. ISBN 0-471-60697-9, Chichester: John Wiley
- Bjarne Stroustrup, Andrew Koenig, Barbara Moo (2001). The C++ Programming Language. Encyclopedia of Software Engineering. Wiley
- Andrei Alexandrescu (2001). Modern C++ Design: Generic Programming and Design Patterns Applied.
- Robert L. Akers, Ira Baxter, Michael Mehlich (2004). Invited application paper: re-engineering C++ components via automatic program transformation. PEPM 2004, pdf
2005 ...
- Robert L. Akers, Ira Baxter, Michael Mehlich, Brian J. Ellis, Kenn R. Luecke (2005). Reengineering C++ Component Models via Automatic Program Transformation. WCRE 2005
- Robert L. Akers, Ira Baxter, Michael Mehlich, Brian J. Ellis, Kenn R. Luecke (2007). Case study: Re-engineering C++ component models via automatic program transformation. Information & Software Technology, Vol. 49, No. 3
- Bjarne Stroustrup (2008, 2014). Programming -- Principles and Practice Using C++. Addison-Wesley
2010 ...
- Robert C. Seacord (2010). Dangerous Optimizations and the Loss of Causality. CS 15-392, Carnegie Mellon University, slides as pdf
- Anthony Williams (2012). C++ Concurrency in Action: Practical Multithreading. [3]
- Xi Wang, Haogang Chen, Alvin Cheung, Zhihao Jia, Nickolai Zeldovich, M. Frans Kaashoek (2012). Undefined Behavior: What Happened to My Code? pdf [4]
- Will Dietz, Peng Li, John Regehr, Vikram Adve (2012). Understanding Integer Overflow in C/C++. pdf
Andrew Koenig at Dr Dobbs
- Introducing C++ Order Relations, January 18, 2013
- If C++ Objects Are Unrelated, Are They Equal?, January 24, 2013
- A Strategy for Defining Order Relations, February 01, 2013
- How Dictionaries Work, February 06, 2013
- Concrete Examples of Orderings, February 15, 2013
- Comparison and Inheritance, February 22, 2013
- It's Hard To Compare Floating-Point Numbers, March 01, 2013
- Comparing an Integer With a Floating-Point Number, Part 1: Strategy, March 08, 2013
- Comparing an Integer with a Floating-Point Number, Part 2: Tactics, March 15, 2013
- If Order Relations are Such a Pain, Why Bother?, March 22, 2013
- Is Optimization Immoral?, March 28, 2013
- Optimization Versus Flexibility — An Example, April 04, 2013
- Optimizing a Program Means Making It Run Faster, Right?, April 10, 2013
- Sometimes Optimizations Cancel Each Other, April 17, 2013
- Some Optimizations Are No-Brainers, April 26, 2013
- Sometimes, Making a Program Clearer Makes It Faster, May 02, 2013
- Some Subtleties of Aliasing, May 09, 2013
- Aliasing Is Particularly Troublesome With Vector Elements, May 17, 2013
- The Hazards of Remembering Positions in Vectors, May 24, 2013
- Copying Container Elements From The C++ Library: It's Trickier Than It Looks, May 30, 2013
- Moving Is Not Copying, June 06, 2013
- When Is It Safe to Move an Object Instead of Copying It?, June 12, 2013
- More Thoughts About Moving Objects Safely, June 21, 2013
- Moving and Rvalue References, June 27, 2013
- Moving an Object Does Not Destroy The Original, July 04, 2013
- How the C++ Compiler Decides to Move Objects, July 10, 2013
- Sometimes You Must Violate an Abstraction to Maintain It, July 17, 2013
- Is Moving Objects Worth the Hassle?, July 26, 2013
- Why Would You Ever Pass a Container By Value?, July 31, 2013
- Some Optimizations Are More Important Than Others, August 08, 2013
- An Important Move Optimization Is Nearly Invisible, August 15, 2013
- Moving Data and Address Arithmetic, August 21, 2013
- Addresses and Nodes: Two Ways To Get Around, August 29, 2013
- Theory Versus Practice: The Great Divide in Programming Languages, September 06, 2013
- Programming Without Variables, September 12, 2013
- Containers That Never Change, September 19, 2013
- What Does It Mean To Change An Object?, September 26, 2013
- A Simple, Immutable, Node-Based Data Structure, October 02, 2013
- Introduction to Programming with Lists, October 09, 2013
- Reversing an Immutable List, October 17, 2013
- How Do You Decide On Intermediate States?, October 23, 2013
- Sorting An Immutable List, October 31, 2013
- Practical Advantages of Immutable Values, November 07, 2013
- When Is An Optimization More Than Just An Optimization?, November 14, 2013
- Abstraction and Performance Bugs, November 21, 2013
- Performance Bugs Can Be Hard to Detect, November 27, 2013
- Performance Bugs: Not Just Hard To Detect, But Hard To Define, December 05, 2013
- How Can One Test a Program's Average Performance? December 12, 2013
- Testing Behavior, Not Just Results, December 19, 2013
- Not All Bugs Are Random, December 27, 2013
- Testing Is Not Verification and Vice Versa, January 02, 2014
- Social Processes and the Design of Programming Languages, January 08, 2014
- Why Language Designers Tolerate Undefined Behavior, January 16, 2014
- Even Simple Floating-Point Output Is Complicated, January 23, 2014
- Why Is Exact Floating-Point Output So Hard? January 30, 2014
- Floating-Point Input and Output Are Not Symmetric, February 06, 2014
Forum Posts
1997 ...
- Search Degredation w/ C++ by Chris Jason Richards, rgcc, June 12, 1997
- Re: Search Degredation w/ C++ by Amir Ban, rgcc, June 17, 1997
- Question to Amir Ban by Bas Hamstra, CCC, November 05, 1997 [6]
- object oriented chess programming by James Long, rgcc, December 31, 1997
- Re: object oriented chess programming by Dave Fotland, rgcc, January 06, 1998
- C or C++ for chess programming: speed by Marc-Philippe Huget, CCC, October 20, 1999
2000 ...
- C++ Programming Q: are const and define efficiency the same by Federico Corigliano, CCC, January 16, 2004
- Kiwi for Win98 and input-reading stuff by Alessandro Scotti, CCC, September 29, 2004 » Kiwi, Windows, Thread
2005 ...
- Find The Bug - C / C++ by David Rasmussen, bytes.com, July 22, 2005 » Chezzz
- forcing compilers to inline (or to not inline) by Wylie Garvin, CCC, May 04, 2008
2010 ...
- c or c++ ? by ethan ara, CCC, July 10, 2011
2012
- C++ templates question by José C. Martínez Galán, CCC, January 18, 2012
- C++11 for chess engines by Marco Costalba, CCC, September 03, 2012
- Has GCC caught up with Intel with respect to performance? by Don Dailey, CCC, October 07, 2012
2013
- Need Help Getting GCC Working?!? by Steve Maughan, CCC, April 23, 2013
- [ub Objectives and tasks for SG12] by Gabriel Dos Reis, Open Standards, The ub Archives, May 29, 2013
- C++ Question by Ted Wong, CCC, July 30, 2013 » Thread
2014
- C++11 threads seem to get shafted for cycles by User923005, OpenChess Forum, March 18, 2014 » Parallel Search, Senpai, Thread
- c++11 std::atomic and memory_order_relaxed by Kevin Hearn, CCC, April 01, 2014 » Memory
- C++ puzzle by Marco Costalba, CCC, April 12, 2014
- std::vector<> considered harmful by Folkert van Heusden, CCC, September 25, 2014 » Move List, Array
2015 ...
- Polling standard input from C++ by Steven Edwards, CCC, May 10, 2015
- BMI2 intrinsics in gcc by Álvaro Begué, CCC, May 14, 2017 » BMI2
- Advantages of C++11 for Chess? by Steve Maughan, CCC, October 23, 2017
External Links
- C++ from Wikipedia
- C++03 from Wikipedia
- C++11 from Wikipedia
- C++14 from Wikipedia
- C++17 from Wikipedia
- C++20 from Wikipedia
- C++ Programming from Wikibooks
- More C++ Idioms - Wikibooks
- C++ - Wikiversity
- cplusplus.com - The C++ Resources Network
- C++ Notes by Fred Swartz
- C++ Historical Sources Archive — Software Preservation Group, The Computer History Museum
- Agner Fog's manuals
- C++ Optimization Strategies and Techniques by Pete Isensee
- C++ Frequently Questioned Answers by Yossi Kreinin
- comp.lang.c++ The object-oriented C++ language.
References
- ↑ Keith E. Gorlen, et al. (1990). Data abstraction and object-oriented programming in C++. Wiley
- ↑ NIH Class Library — Software Preservation Group, The Computer History Museum
- ↑ Information on the C++11 Memory Model by Scott Meyers, April 24, 2012
- ↑ Re: A note for C programmers by Rein Halbersma, CCC, November 28, 2013
- ↑ Andrew Koenig's Bio | Dr Dobb's
- ↑ Search Degredation w/ C++ by Chris Jason Richards, rgcc, June 12, 1997, post 4 and 6 by Amir Ban