Skip to content

robcholz/default

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libdefault

a header only c++ library for setting default values in a rust manner.

Install

  • add include directory to your include path.

Usage

#include <default/default.hpp>

struct your_custom_type{
};

namespace rb{
template<typename T>
struct default_value<T, std::enable_if_t<std::is_same_v<T, your_custom_type>>> {
  using type = T;
  static constexpr type value() {
	return your_custom_type{};
  }
};
}

int main() {
  your_custom_type a = rb::default_value<your_custom_type>::value();
  return 0;
}

About

a header only c++ library for setting default values in a rust manner.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published