8000 GitHub - dechimal/desalt: A metaprgramming utilities for C++1z.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

dechimal/desalt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Desalt - Funny C++ Utility Libraries

Desalt ease using some metaprogramming idiom on later C++1z.

Library includes following features:

- AutoFun : Deduce return type of a function by the expression of return statement.
- Require : Conditional overloaded function selection using SFINAE.
- ParameterPack : Assist metaprogramming with parameter pack.
- Newtype : Make a different type with existing type easily (inspired by Haskell's newtype),
- StaticControl : SFINAE-based compile-time branch and loop (static if, static for, etc...).
- Format : Extensible printf.
- QuectoTest: Micro testing framework

The samples are under test/ directory.


AutoFun

  Header
  desalt/auto_fun.hpp

  Synopsis
  #define DESALT_AUTO_FUN(name_sig, expr) /* unspecified */
  #define DESALT_AUTO_FUN_NOEXCEPT(name_sig, expr) /* unspecified */

  DESALT_AUTO_FUN define a function what has a name and a signature by name_sig.
  The return type is decltype(expr).

  Parameters
  name_sig | A name and signature of function.
           | grammer is:
           |   name_sig:
           |     declarator-id ( parameter-declaration-clause )
           |       cv-qualifier_opt ref-qualifier_opt exception-specification_opt
  expr     | A expression to be body of the function and to determine the return type.
           | expr can include some number comma.
 
  Semantics
  A declaration
    DESALT_AUTO_FUN( name_sig , expr ) ;
  generates following function definition:
    auto name_sig -> decltype( expr )
      { return expr ; }
  cv-qualifier, ref-qualifier, and exception-specification are optional.

  DESALT_AUTO_FUN_NOEXCEPT(name_sig, expr) is same DESALT_AUTO_FUN(name_sig, expr) except exception-specification is determined by noexcept(expression).

  Example
  See test/auto_fun.cpp

Require

  Header
  desalt/require.hpp

  Synopsis
  #define DESALT_REQUIRE(mpl_cond) /* unspecified */
  #define DESALT_REQUIRE_NOT(mpl_cond) /* unspecified */
  #define DESALT_REQUIRE_C(cond) /* unspecified */
  #define DESALT_REQUIRE_EXPR(expr) /* unspecified */

  Parameters
  mpl_cond | A model of Boost.MPL Integral Constant.
  cond     | A integral-constant-expression.

  Semantics


ParameterPack

  Header
  desalt/parameter_pack.hpp

Newtype

  Header
  desalt/newtype.hpp

StaticControl

  Headers
  desalt/static_control.hpp
  desalt/static_control/static_control.hpp
  desalt/static_control/static_if.hpp
  desalt/static_control/static_match.hpp
  desalt/static_control/static_while.hpp
  desalt/static_control/static_for.hpp
  desalt/static_control/with_unpacked.hpp
  desalt/static_control/with_index_sequence.hpp
  desalt/static_control/wrap.hpp
  desalt/static_control/clause.hpp

Format

  Header
  desalt/format.hpp

QuectoTest

  Header
  desalt/quectotest.hpp

  Synopsis
  #define TEST(test_case_name, setup_classes...)
  #define ASSERT(expr)
  #define ASSERT_EQ(expr1, expr2, extra_msg_args...)
  #define ASSERT_NE(expr1, expr2, extra_msg_args...)

  Examples
  #include <desalt/quectotest.hpp>

  struct setup1 {
    int x = 10;
    int y = 20;
  };

  TEST("test1") {
    ASSERT(true);
  }

  TEST("test1", setup1) {
    ASSERT_EQ(x + 10, y);
  }

  Remarks
  desalt/quectotest.hpp includes main function, do not define yourself it.
  The built program may take testcase filter patterns (regular expression).

About

A metaprgramming utilities for C++1z.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0