8000 adl/oct, adl: Correct function implementations (e.g. adl_IMPL, inline, etc) · Issue #41 · flisboac/adl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adl/oct, adl: Correct function implementations (e.g. adl_IMPL, inline, etc) #41

Open
flisboac opened this issue Aug 7, 2017 · 0 comments

Comments

@flisboac
Copy link
Owner
flisboac commented Aug 7, 2017

Guidelines for implementations:

  • Is it a template class/struct specialization? Use adl_*CLASS
  • Is it a non-template class/struct? Use adl_*CLASS
  • Is it a non-constexpr non-type-member (global or namespace) function declaration? Use adl_*API
  • Is the full path to a non-constexpr function definition non-templated or specialized? Use adl_IMPL
  • Does the full path to a non-constexpr function definition contain any non-specialized template parameter? Use inline.

Examples for template types:

// Declaration
template<typename T> struct my_type;

// Definition
template<typename T> struct my_type {
    void function();
    template <typename F> void tpl_function(F);
    void inline_function() {}
};

// Member function definition
template <typename T>
inline void my_type<T>::function() {}

// Template member function definition
template <typename T>
template <typename F>
inline void my_type<T>::tpl_function(F) {}

// Specialization declaration (if any)
template<> struct adl_CLASS my_type<int> {
    void function();
    template <typename F> void tpl_function(F);
    void inline_function() {}
};

// Specialization: Member function definition
template <>
adl_IMPL void my_type<int>::function() {}

// Specialization: Template member function definition
template <>
template <typename F>
inline void my_type<int>::tpl_function(F) {}

// Specialization: Template member function specialized definition
template <>
template <>
adl_IMPL void my_type<int>::tpl_function<int>(F) {}

Examples for non-template types:

// Declaration
struct my_type;

// Definition
struct my_type {
    void function();
    template <typename F> void tpl_function(F);
    void inline_function() {}
};

// Specialization: Member function definition
adl_IMPL void my_type::function() {}

// Specialization: Template member function definition
inline void my_type::tpl_function(F) {}

Examples for functions:

// Declaration
adl_API void function();

template <typename F> void tpl_function(F);
template <> adl_API void tpl_function<int>(F);

adl_API void inline_function() {}


// Definition
adl_IMPL void function() {}

template <typename F> 
inline void tpl_function(F) {}

template <> adl_IMPL void tpl_function<int>(F) {}

The rest follows standard convention (constexpr at declaration and definition, etc).

@flisboac flisboac added this to the Sprint 001 - ADL v0.1.0 milestone Aug 7, 2017
@flisboac flisboac self-assigned this Aug 7, 2017
@flisboac flisboac modified the milestones: Sprint 005 - ADL v0.5.0, Sprint 001 - ADL v0.1.0 Aug 7, 2017
@flisboac flisboac changed the title Correct function implementations (e.g. adl_IMPL, inline, etc) adl/oct, adl: Correct function implementations (e.g. adl_IMPL, inline, etc) Aug 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0