Files
geant4/source/analysis/include/tools/rcmp
T
2016-06-09 16:46:55 +02:00

31 lines
618 B
Plaintext

// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.
#ifndef tools_rcmp
#define tools_rcmp
// used in safe cast.
#include <string>
namespace tools {
inline bool rcmp(const std::string& a_1,const std::string& a_2) {
std::string::size_type l1 = a_1.size();
std::string::size_type l2 = a_2.size();
if(l1!=l2) return false;
if(!l1) return true;
const char* p1 = a_1.c_str()+l1-1;
const char* p2 = a_2.c_str()+l2-1;
//ab
//012
for(std::string::size_type index=0;index<l1;index++,p1--,p2--) {
if(*p1!=*p2) return false;
}
return true;
}
}
#endif