Browse Source

Add example library code

master
heck 3 years ago
parent
commit
5c0fe934b6
  1. 29
      src/hello_world.cc
  2. 24
      src/hello_world.hh
  3. 19
      src/hello_world.hxx

29
src/hello_world.cc

@ -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

24
src/hello_world.hh

@ -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

19
src/hello_world.hxx

@ -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…
Cancel
Save