Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O OpenFOAM-plus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 339
    • Issues 339
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • OpenFOAM-plus
  • Issues
  • #769
Closed
Open
Issue created Mar 14, 2018 by Mark OLESEN@markMaintainer

change contiguous to a class

Currently implemented as a number of global functions, but a templated class function would be more flexible. Eg,

//- Default definition: (integral | floating-point) are contiguous
template<class T>
struct contiguous
:
    std::integral_constant
    <
        bool,
        std::is_integral<T>::value || std::is_floating_point<T>::value
    >
{};


//- FixedList of (integral | floating-point) is contiguous
template<class T, unsigned N>
struct contiguous<FixedList<T, N>>
:
    std::integral_constant
    <
        bool,
        std::is_integral<T>::value || std::is_floating_point<T>::value
    >
{};

These definitions work for any size FixedList and thus eliminate most of contiguous.H. Template specializations for the function definition aren't really possible.

Pros:

  • usable in constexpr, at compile-time and static_assert

Cons:

  • user code that is currently overloading contiguous needs to specify it different.

      template<> inline bool contiguous<someType>() { return true; }
      template<> struct contiguous<someType> : std::true_type {};
Edited Mar 14, 2018 by Mark OLESEN
Assignee
Assign to
Time tracking