Skip to content

feelpp/napp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAPP : Named Arguments in C++

What is NAPP?

  • arg given by value

  • arg given by ref (lvalue or rvalue)

  • static arg

  • default value

  • template and non template function

Examples

basic examples :

#include <napp/na.hpp>
#include <iostream>

constexpr auto& _elt1 = NA::identifier<struct elt1_tag>;
constexpr auto& _elt2 = NA::identifier<struct elt2_tag>;
constexpr auto& _elt3 = NA::identifier<struct elt3_tag>;

template <typename ... Ts>
void func( Ts && ... v )
{
    auto args = NA::make_arguments( std::forward<Ts>(v)... );

    std::cout << "elt1 : " << args.get(_elt1) << "\n"
              << "elt2 : " << args.get_else(_elt2, "a default value" ) << "\n"
              << "elt3 : " << args.get_else_invocable(_elt3, []() { return 3.1415; } )
              << std::endl;
}

int main()
{
    func( _elt2=36,_elt1="toto",_elt3=std::string("string as rvalue") );

    func( _elt1=36 );

    return 0;
}

advanced examples :

TODO

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 83.8%
  • Emacs Lisp 9.1%
  • CMake 7.1%