c++ - Using Namespace and Headers -
i'm working on project i've written test code in header files. i've done because i'm doing test driven development , results in large amount of complementary classes each class add: interface, test, mock etc. think i'd go crazy if had deal cpp versions of these files...
i don't add "using namespace std" start of headers because i've learned no, no. anyway, lets initialise blob object @ start of test, follows:
blob v = boost::assign::list_of(std::pair<std::string, container >("scotland",container(boost::assign::list_of(1)(2)(3).convert_to_container<std::vector<int> >()))) (std::pair<std::string, container >("sweden",container()));
where blob typedef
ed somewhere std::vector<std::pair<std::string, container > >
.
how can make prettier? reason i'm using list_of make things more readable in case think makes lot more difficult read. lot better:
blob v = list_of(pair<string, container >("scotland",container(list_of(1)(2)(3).convert_to_container<vector<int> >()))) (pair<string, container >("sweden",container()));
but can't in header...
what might solve problem? i'm working c++98.
update:
just idea. if renamed test headers cpp files instead?
tdd requires short edit->compilation->run cycle times. therefore should write code possible in cpp files reduce compilation time. nevertheless, solve problem using init function:
inline blob initblob() { using namespace boost; using namespace std; return assign::list_of(/*...*/); } blob v = initblob();