forked from pEp.foundation/CXX-project-template

3 changed files with 72 additions and 0 deletions
@ -0,0 +1,29 @@ |
|||||
|
// This file is under GNU General Public License 3.0
|
||||
|
// see LICENSE.txt
|
||||
|
|
||||
|
#include "hello_world.hh" |
||||
|
|
||||
|
namespace pEp { |
||||
|
namespace HelloWorld { |
||||
|
//non-template func and template-specializations here
|
||||
|
std::string hello_world() |
||||
|
{ |
||||
|
return "hello world"; |
||||
|
} |
||||
|
|
||||
|
// specialization for int
|
||||
|
template<> |
||||
|
int hello_world(int param1) |
||||
|
{ |
||||
|
return param1 * 2; |
||||
|
} |
||||
|
|
||||
|
// specialization for float
|
||||
|
template<> |
||||
|
double hello_world(double param1) |
||||
|
{ |
||||
|
return param1 * 2; |
||||
|
} |
||||
|
|
||||
|
} // namespace HelloWorld
|
||||
|
} // namespace pEp
|
@ -0,0 +1,24 @@ |
|||||
|
// This file is under GNU General Public License 3.0
|
||||
|
// see LICENSE.txt
|
||||
|
|
||||
|
#ifndef LIBPEPHELLOWORLD_HELLO_WORLD_HH |
||||
|
#define LIBPEPHELLOWORLD_HELLO_WORLD_HH |
||||
|
|
||||
|
#include <string> |
||||
|
|
||||
|
namespace pEp { |
||||
|
namespace HelloWorld { |
||||
|
// non-template functions and classes
|
||||
|
// impl in .cc
|
||||
|
std::string hello_world(); |
||||
|
|
||||
|
// template functions and classes
|
||||
|
// impl in .hxx
|
||||
|
template<typename T> |
||||
|
T hello_world(T param1); |
||||
|
} // namespace HelloWorld
|
||||
|
} // namespace pEp
|
||||
|
|
||||
|
#include "hello_world.hxx" |
||||
|
|
||||
|
#endif // LIBPEPHELLOWORLD_HELLO_WORLD_HH
|
@ -0,0 +1,19 @@ |
|||||
|
// This file is under GNU General Public License 3.0
|
||||
|
// see LICENSE.txt
|
||||
|
|
||||
|
#ifndef LIBPEPHELLOWORLD_HELLO_WORLD_HXX |
||||
|
#define LIBPEPHELLOWORLD_HELLO_WORLD_HXX |
||||
|
|
||||
|
#include <sstream> |
||||
|
|
||||
|
namespace pEp { |
||||
|
namespace HelloWorld { |
||||
|
template<typename T> |
||||
|
T hello_world(T param1) |
||||
|
{ |
||||
|
return param1; |
||||
|
} |
||||
|
} // namespace HelloWorld
|
||||
|
} // namespace pEp
|
||||
|
|
||||
|
#endif //LIBPEPHELLOWORLD_HELLO_WORLD_HXX
|
Loading…
Reference in new issue