Difference between revisions of "Cpp"

From Chessprogramming wiki
Jump to: navigation, search
(2020 ...)
(13 intermediate revisions by one other user not shown)
Line 119: Line 119:
 
* [https://en.wikipedia.org/wiki/Intel_C%2B%2B_Compiler Intel C++ Compiler from Wikipeadia]
 
* [https://en.wikipedia.org/wiki/Intel_C%2B%2B_Compiler Intel C++ Compiler from Wikipeadia]
 
* [https://en.wikipedia.org/wiki/Visual_C%2B%2B Visual C++ from Wikipeadia]
 
* [https://en.wikipedia.org/wiki/Visual_C%2B%2B Visual C++ from Wikipeadia]
 +
* [https://godbolt.org/ Compiler Explorer] by [https://github.com/mattgodbolt Matt Godbolt]
 
<span id="Libraries"></span>
 
<span id="Libraries"></span>
 
=Libraries=
 
=Libraries=
Line 174: Line 175:
 
* [https://pdos.csail.mit.edu/~xi/ Xi Wang], [https://pdos.csail.mit.edu/~hchen/ Haogang Chen], [https://homes.cs.washington.edu/~akcheung/ Alvin Cheung], [http://zhihaojia.com/ Zhihao Jia], [http://people.csail.mit.edu/nickolai/ Nickolai Zeldovich], [https://pdos.csail.mit.edu/~kaashoek/ M. Frans Kaashoek] ('''2012'''). ''Undefined Behavior: What Happened to My Code''? [https://pdos.csail.mit.edu/papers/ub:apsys12.pdf pdf] <ref>[http://www.talkchess.com/forum/viewtopic.php?t=50186&start=80 Re: A note for C programmers] by [[Rein Halbersma]], [[CCC]], November 28, 2013</ref>
 
* [https://pdos.csail.mit.edu/~xi/ Xi Wang], [https://pdos.csail.mit.edu/~hchen/ Haogang Chen], [https://homes.cs.washington.edu/~akcheung/ Alvin Cheung], [http://zhihaojia.com/ Zhihao Jia], [http://people.csail.mit.edu/nickolai/ Nickolai Zeldovich], [https://pdos.csail.mit.edu/~kaashoek/ M. Frans Kaashoek] ('''2012'''). ''Undefined Behavior: What Happened to My Code''? [https://pdos.csail.mit.edu/papers/ub:apsys12.pdf pdf] <ref>[http://www.talkchess.com/forum/viewtopic.php?t=50186&start=80 Re: A note for C programmers] by [[Rein Halbersma]], [[CCC]], November 28, 2013</ref>
 
* [https://wdtz.org/ Will Dietz], [https://lipeng28.github.io/ Peng Li], [http://www.cs.utah.edu/~regehr/ John Regehr], [https://en.wikipedia.org/wiki/Vikram_Adve Vikram Adve] ('''2012'''). ''Understanding Integer Overflow in C/C++''. [http://www.cs.utah.edu/~regehr/papers/overflow12.pdf pdf]
 
* [https://wdtz.org/ Will Dietz], [https://lipeng28.github.io/ Peng Li], [http://www.cs.utah.edu/~regehr/ John Regehr], [https://en.wikipedia.org/wiki/Vikram_Adve Vikram Adve] ('''2012'''). ''Understanding Integer Overflow in C/C++''. [http://www.cs.utah.edu/~regehr/papers/overflow12.pdf pdf]
 
=Andrew Koenig at Dr Dobbs=
 
{{Andrew Koenig at Dr Dobbs}}
 
  
 
=Forum Posts=
 
=Forum Posts=
Line 194: Line 192:
 
==2010 ...==
 
==2010 ...==
 
* [http://talkchess.com/forum/viewtopic.php?t=39683 c or c++ ?] by ethan ara, [[CCC]], July 10, 2011
 
* [http://talkchess.com/forum/viewtopic.php?t=39683 c or c++ ?] by ethan ara, [[CCC]], July 10, 2011
'''2012'''
 
 
* [http://www.talkchess.com/forum/viewtopic.php?t=42046 C++ templates question] by [[José C. Martínez Galán]], [[CCC]], January 18, 2012
 
* [http://www.talkchess.com/forum/viewtopic.php?t=42046 C++ templates question] by [[José C. Martínez Galán]], [[CCC]], January 18, 2012
 
* [http://www.talkchess.com/forum/viewtopic.php?t=44999 C++11 for chess engines] by [[Marco Costalba]], [[CCC]], September 03, 2012
 
* [http://www.talkchess.com/forum/viewtopic.php?t=44999 C++11 for chess engines] by [[Marco Costalba]], [[CCC]], September 03, 2012
 
* [http://www.talkchess.com/forum/viewtopic.php?t=45482 Has GCC caught up with Intel with respect to performance?] by [[Don Dailey]], [[CCC]], October 07, 2012
 
* [http://www.talkchess.com/forum/viewtopic.php?t=45482 Has GCC caught up with Intel with respect to performance?] by [[Don Dailey]], [[CCC]], October 07, 2012
'''2013'''
 
 
* [http://www.talkchess.com/forum/viewtopic.php?t=47841 Need Help Getting GCC Working?!?] by [[Steve Maughan]], [[CCC]], April 23, 2013
 
* [http://www.talkchess.com/forum/viewtopic.php?t=47841 Need Help Getting GCC Working?!?] by [[Steve Maughan]], [[CCC]], April 23, 2013
 
* [http://www.open-std.org/pipermail/ub/2013-May/000005.html [ub] Objectives and tasks for SG12] by [http://www.cse.tamu.edu/people/faculty/gdr Gabriel Dos Reis], [http://www.open-std.org/ Open Standards], [http://www.open-std.org/pipermail/ub/ The ub Archives], May 29, 2013
 
* [http://www.open-std.org/pipermail/ub/2013-May/000005.html [ub] Objectives and tasks for SG12] by [http://www.cse.tamu.edu/people/faculty/gdr Gabriel Dos Reis], [http://www.open-std.org/ Open Standards], [http://www.open-std.org/pipermail/ub/ The ub Archives], May 29, 2013
 
* [http://www.talkchess.com/forum/viewtopic.php?t=48795 C++ Question] by Ted Wong, [[CCC]], July 30, 2013 » [[Thread]]
 
* [http://www.talkchess.com/forum/viewtopic.php?t=48795 C++ Question] by Ted Wong, [[CCC]], July 30, 2013 » [[Thread]]
'''2014'''
 
 
* [http://www.open-chess.org/viewtopic.php?f=5&t=2618 C++11 threads seem to get shafted for cycles] by [[Dann Corbit|User923005]], [[Computer Chess Forums|OpenChess Forum]], March 18, 2014 » [[Parallel Search]], [[Senpai]], [[Thread]]
 
* [http://www.open-chess.org/viewtopic.php?f=5&t=2618 C++11 threads seem to get shafted for cycles] by [[Dann Corbit|User923005]], [[Computer Chess Forums|OpenChess Forum]], March 18, 2014 » [[Parallel Search]], [[Senpai]], [[Thread]]
 
* [http://www.talkchess.com/forum/viewtopic.php?t=51824 c++11 std::atomic and memory_order_relaxed] by Kevin Hearn, [[CCC]], April 01, 2014 » [[Memory]]
 
* [http://www.talkchess.com/forum/viewtopic.php?t=51824 c++11 std::atomic and memory_order_relaxed] by Kevin Hearn, [[CCC]], April 01, 2014 » [[Memory]]
Line 211: Line 206:
 
* [http://www.talkchess.com/forum/viewtopic.php?t=63978 BMI2 intrinsics in gcc] by [[Álvaro Begué]], [[CCC]], May 14, 2017 » [[BMI2]]
 
* [http://www.talkchess.com/forum/viewtopic.php?t=63978 BMI2 intrinsics in gcc] by [[Álvaro Begué]], [[CCC]], May 14, 2017 » [[BMI2]]
 
* [http://www.talkchess.com/forum/viewtopic.php?t=65523 Advantages of C++11 for Chess?] by [[Steve Maughan]], [[CCC]], October 23, 2017
 
* [http://www.talkchess.com/forum/viewtopic.php?t=65523 Advantages of C++11 for Chess?] by [[Steve Maughan]], [[CCC]], October 23, 2017
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=70584 Wouldn't it be nice if C++ GPU] by [[Chris Whittington]], [[CCC]], April 25, 2019 » [[GPU]]
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=72461&start=3 Re: Pawn move generation in bitboards] by [[Álvaro Begué]], [[CCC]], December 05, 2019 » [[Bitboards]]
 +
==2020 ...==
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=75818 C++20 standard bit operations] by [[Jon Dart]], [[CCC]], November 15, 2020 » [[General Setwise Operations]], [[Population Count]], [[BitScan]]
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=76592 C++ type system AKA what is exactly int ?] by [[Toni Helminen|JohnWoe]], [[CCC]], February 14, 2021
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=76817 C++ code for <nowiki>board[8][8]</nowiki> representation] by [[Yves De Billoëz]], [[CCC]], March 08, 2021 » [[8x8 Board]]
 +
: [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=76817&start=4 Re: C++ code for <nowiki>board[8][8]</nowiki> representation] by [[Rein Halbersma]], [[CCC]], March 08, 2021 <ref>[https://en.wikipedia.org/wiki/Anonymous_function#C++_(since_C++11) lambda expressions (C++ 11) from Wikipedia]</ref>
 +
* [http://www.talkchess.com/forum3/viewtopic.php?t=78070 Why C++ instead of C#?] by [[Henk]], [[CCC]], August 31, 2021
  
 
=External Links=  
 
=External Links=  
Line 218: Line 221:
 
* <span id="14"></span>[https://en.wikipedia.org/wiki/C%2B%2B14 C++14 from Wikipedia]
 
* <span id="14"></span>[https://en.wikipedia.org/wiki/C%2B%2B14 C++14 from Wikipedia]
 
* <span id="17"></span>[https://en.wikipedia.org/wiki/C%2B%2B17 C++17 from Wikipedia]
 
* <span id="17"></span>[https://en.wikipedia.org/wiki/C%2B%2B17 C++17 from Wikipedia]
* [https://en.wikipedia.org/wiki/C%2B%2B20 C++20 from Wikipedia]
+
* <span id="20"></span>[https://en.wikipedia.org/wiki/C%2B%2B20 C++20 from Wikipedia]
 
* [https://en.wikibooks.org/wiki/C%2B%2B_Programming C++ Programming from Wikibooks]
 
* [https://en.wikibooks.org/wiki/C%2B%2B_Programming C++ Programming from Wikibooks]
 
* [https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms More C++ Idioms - Wikibooks]
 
* [https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms More C++ Idioms - Wikibooks]
 
* [https://en.wikiversity.org/wiki/C%2B%2B C++ - Wikiversity]
 
* [https://en.wikiversity.org/wiki/C%2B%2B C++ - Wikiversity]
 +
* [https://en.cppreference.com/w/cpp C++ reference - cppreference.com]
 
* [http://www.cplusplus.com/ cplusplus.com - The C++ Resources Network]
 
* [http://www.cplusplus.com/ cplusplus.com - The C++ Resources Network]
 
* [http://www.fredosaurus.com/notes-cpp/index.html C++ Notes] by [[Fred Swartz]]
 
* [http://www.fredosaurus.com/notes-cpp/index.html C++ Notes] by [[Fred Swartz]]
Line 229: Line 233:
 
* [http://www.tantalon.com/pete/cppopt/main.htm C++ Optimization Strategies and Techniques] by [http://www.tantalon.com/pete.htm Pete Isensee]
 
* [http://www.tantalon.com/pete/cppopt/main.htm C++ Optimization Strategies and Techniques] by [http://www.tantalon.com/pete.htm Pete Isensee]
 
* [http://yosefk.com/c++fqa/index.html C++ Frequently Questioned Answers] by [http://yosefk.com/about.html Yossi Kreinin]
 
* [http://yosefk.com/c++fqa/index.html C++ Frequently Questioned Answers] by [http://yosefk.com/about.html Yossi Kreinin]
* [https://groups.google.com/forum/#!forum/comp.lang.c++ comp.lang.c++] The object-oriented C++ language.
+
* [https://groups.google.com/forum/#!forum/comp.lang.c++ comp.lang.c++] The object-oriented C++ language  
 
* [[Mathematician#Stroustrup|Bjarne Stroustrup]] - The Essence of C++, [https://en.wikipedia.org/wiki/YouTube YouTube] Video  
 
* [[Mathematician#Stroustrup|Bjarne Stroustrup]] - The Essence of C++, [https://en.wikipedia.org/wiki/YouTube YouTube] Video  
 
: {{#evu:https://www.youtube.com/watch?v=86xWVb4XIyE|alignment=left|valignment=top}}
 
: {{#evu:https://www.youtube.com/watch?v=86xWVb4XIyE|alignment=left|valignment=top}}
Line 236: Line 240:
 
<references />
 
<references />
 
'''[[Languages|Up one Level]]'''
 
'''[[Languages|Up one Level]]'''
[[Category:Videos]]
+
[[Category:Videos|C++]]

Revision as of 11:00, 16 September 2021

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.

C Extensions

References

Exception Handling

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

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

Function Overloading

Operator Overloading

Late Binding

Abstract Classes

Pure Abstract Classes

Multiple Inheritance

Templates

Anonymous Functions

Smart Pointer

Class Design of a Chess Engine

main article Class Design of a Chess Engine

C++ Compiler

Libraries

NIH Class Library — Software Preservation Group, The Computer History Museum [1]

See also

C++ Publications

1985 ...

1990 ...

1995 ...

2000 ...

2005 ...

2010 ...

Forum Posts

1997 ...

Re: Search Degredation w/ C++ by Amir Ban, rgcc, June 17, 1997
Re: object oriented chess programming by Dave Fotland, rgcc, January 06, 1998

2000 ...

2005 ...

2010 ...

2015 ...

2020 ...

Re: C++ code for board[8][8] representation by Rein Halbersma, CCC, March 08, 2021 [6]

External Links

Calling conventions for different C++ compilers and operating systems (pdf) by Agner Fog

References

Up one Level