Added default implementation to string2type::convert function.
This commit is contained in:
@@ -2,17 +2,6 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
|
||||||
|
|
||||||
namespace string2type {
|
|
||||||
|
|
||||||
template<>
|
|
||||||
int convert<int>(const std::string &value) {
|
|
||||||
return boost::lexical_cast<int>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
struct foo : attributes {
|
struct foo : attributes {
|
||||||
foo() {
|
foo() {
|
||||||
REGISTER_ATTRIBUTE(int, x);
|
REGISTER_ATTRIBUTE(int, x);
|
||||||
|
|||||||
@@ -16,10 +16,14 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
namespace string2type {
|
namespace string2type {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T convert(const std::string &value);
|
T convert(const std::string &value) {
|
||||||
|
return boost::lexical_cast<T>(value);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,16 +6,6 @@
|
|||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/lexical_cast.hpp>
|
|
||||||
|
|
||||||
namespace string2type {
|
|
||||||
|
|
||||||
template<>
|
|
||||||
int convert<int>(const std::string &value) {
|
|
||||||
return boost::lexical_cast<int>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
struct test : attributes {
|
struct test : attributes {
|
||||||
test() : x(0) {
|
test() : x(0) {
|
||||||
|
|||||||
@@ -5,23 +5,6 @@
|
|||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <boost/lexical_cast.hpp>
|
|
||||||
|
|
||||||
namespace string2type {
|
|
||||||
|
|
||||||
template<>
|
|
||||||
int convert<int>(const std::string &value) {
|
|
||||||
return boost::lexical_cast<int>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
double convert<double>(const std::string &value) {
|
|
||||||
return boost::lexical_cast<double>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(string2type_test)
|
BOOST_AUTO_TEST_SUITE(string2type_test)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( test1 )
|
BOOST_AUTO_TEST_CASE( test1 )
|
||||||
|
|||||||
Reference in New Issue
Block a user