Skip to content

Commit

Permalink
migrate from boost::shared_ptr to std::shared_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewprock committed Jun 23, 2024
1 parent 9d0e5cd commit 02e8087
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/lib/pokerstove/penum/ShowdownEnumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ShowdownEnumerator::ShowdownEnumerator() {}

vector<EquityResult> ShowdownEnumerator::calculateEquity(const vector<CardDistribution>& dists,
const CardSet& board,
boost::shared_ptr<PokerHandEvaluator> peval) const
std::shared_ptr<PokerHandEvaluator> peval) const
{
if (peval.get() == NULL)
throw runtime_error("ShowdownEnumerator, null evaluator");
Expand Down
4 changes: 2 additions & 2 deletions src/lib/pokerstove/penum/ShowdownEnumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#define PENUM_SHOWDOWNENUMERATOR_H_

#include "CardDistribution.h"
#include <boost/shared_ptr.hpp>
#include <pokerstove/peval/PokerHandEvaluator.h>
#include <memory>
#include <vector>

namespace pokerstove
Expand All @@ -22,7 +22,7 @@ class ShowdownEnumerator
std::vector<EquityResult>
calculateEquity(const std::vector<CardDistribution>& dists,
const CardSet& board,
boost::shared_ptr<PokerHandEvaluator> peval) const;
std::shared_ptr<PokerHandEvaluator> peval) const;
};
} // namespace pokerstove

Expand Down
4 changes: 2 additions & 2 deletions src/lib/pokerstove/peval/PokerHandEvaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "CardSet.h"
#include "PokerHandEvaluation.h"
#include <boost/lexical_cast.hpp>
#include <boost/shared_ptr.hpp>
#include <memory>
#include <string>
#include <vector>

Expand Down Expand Up @@ -98,7 +98,7 @@ class PokerHandEvaluator
* - 'e' stud/8
* - 'b' badugi
*/
typedef boost::shared_ptr<PokerHandEvaluator> eval_ptr;
typedef std::shared_ptr<PokerHandEvaluator> eval_ptr;
static eval_ptr alloc(const std::string& strid);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pokerstove/peval/PokerHandEvaluator.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ TEST(PokerHandEvaluator, OmahaHigh)
{
using namespace pokerstove;

boost::shared_ptr<PokerHandEvaluator> evaluator = PokerHandEvaluator::alloc("O");
std::shared_ptr<PokerHandEvaluator> evaluator = PokerHandEvaluator::alloc("O");
EXPECT_EQ(true, evaluator->usesSuits());
EXPECT_EQ(5, evaluator->boardSize());
}
6 changes: 3 additions & 3 deletions src/lib/pokerstove/peval/PokerHandEvaluator_Alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ using namespace std;
using namespace boost;
using namespace pokerstove;

boost::shared_ptr<PokerHandEvaluator> PokerHandEvaluator::alloc (const string & input)
std::shared_ptr<PokerHandEvaluator> PokerHandEvaluator::alloc (const string & input)
{
string strid = input;
boost::algorithm::to_lower(strid); // modifies str
boost::shared_ptr<PokerHandEvaluator> ret;
std::shared_ptr<PokerHandEvaluator> ret;
switch (strid[0])
{
case 'h': // hold'em
Expand All @@ -46,7 +46,7 @@ boost::shared_ptr<PokerHandEvaluator> PokerHandEvaluator::alloc (const string &
ret.reset (new UniversalHandEvaluator (1,3,0,0,0,&CardSet::evaluate3CP, NULL));
break;

case 'o': // omaha
case 'o': // omaha
{
auto ohigh = new UniversalHandEvaluator (4,4,3,5,2,&CardSet::evaluateHigh, NULL);
auto ohighlow8 = new UniversalHandEvaluator (4,4,3,5,2,&CardSet::evaluateHigh, NULL);
Expand Down
4 changes: 1 addition & 3 deletions src/lib/python/pokerstove.i
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@
%}

// take care of some shared pointer issues
// TODO: migrate to std::shared_ptr
%include <boost_shared_ptr.i>
%include <std_shared_ptr.i>
%shared_ptr(pokerstove::PokerHandEvaluator)


%include "pokerstove/peval/Rank.h"
%include "pokerstove/peval/Suit.h"
%include "pokerstove/peval/Card.h"
Expand Down
1 change: 0 additions & 1 deletion src/programs/ps-colex/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <boost/format.hpp>
#include <boost/program_options.hpp>
#include <boost/shared_ptr.hpp>
#include <iostream>
#include <pokerstove/peval/Card.h>
#include <pokerstove/peval/CardSet.h>
Expand Down
3 changes: 1 addition & 2 deletions src/programs/ps-eval/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ int main(int argc, char** argv)
bool quiet = vm.count("quiet") > 0;

// allocate evaluator and create card distributions
boost::shared_ptr<PokerHandEvaluator> evaluator =
PokerHandEvaluator::alloc(game);
std::shared_ptr<PokerHandEvaluator> evaluator = PokerHandEvaluator::alloc(game);
vector<CardDistribution> handDists;
for (const string& hand : hands)
{
Expand Down
1 change: 0 additions & 1 deletion src/programs/ps-lut/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <boost/format.hpp>
#include <boost/program_options.hpp>
#include <boost/shared_ptr.hpp>
#include <iostream>
#include <pokerstove/peval/Card.h>
#include <pokerstove/peval/CardSet.h>
Expand Down

0 comments on commit 02e8087

Please sign in to comment.