Skip to content

Commit

Permalink
Avoid global visibility of std:: in units
Browse files Browse the repository at this point in the history
Solaris defines SEC in the global namespace

Fixes: sass#1308
  • Loading branch information
saper committed Jul 13, 2015
1 parent d94ca1f commit 703117a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace Sass {
}
};

SassUnit string_to_unit(const string& s)
SassUnit string_to_unit(const std::string& s)
{
// size units
if (s == "px") return PX;
Expand Down Expand Up @@ -120,7 +120,7 @@ namespace Sass {
}

// throws incompatibleUnits exceptions
double conversion_factor(const string& s1, const string& s2)
double conversion_factor(const std::string& s1, const std::string& s2)
{
// assert for same units
if (s1 == s2) return 1;
Expand Down
11 changes: 5 additions & 6 deletions units.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
#include <sstream>

namespace Sass {
using namespace std;

const double PI = acos(-1);
const double PI = std::acos(-1);

enum SassUnitType {
SIZE = 0x000,
Expand Down Expand Up @@ -59,20 +58,20 @@ namespace Sass {
extern const double frequency_conversion_factors[2][2];
extern const double resolution_conversion_factors[3][3];

SassUnit string_to_unit(const string&);
SassUnit string_to_unit(const std::string&);
const char* unit_to_string(SassUnit unit);
SassUnitType get_unit_type(SassUnit unit);
// throws incompatibleUnits exceptions
double conversion_factor(const string&, const string&);
double conversion_factor(const std::string&, const std::string&);

class incompatibleUnits: public exception
class incompatibleUnits: public std::exception
{
public:
const char* msg;
incompatibleUnits(SassUnit a, SassUnit b)
: exception()
{
stringstream ss;
std::stringstream ss;
ss << "Incompatible units: ";
ss << "'" << unit_to_string(a) << "' and ";
ss << "'" << unit_to_string(b) << "'";
Expand Down

0 comments on commit 703117a

Please sign in to comment.