Giter Site home page Giter Site logo

articleenumclass-v2's People

Contributors

dalzhim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

articleenumclass-v2's Issues

enum bitmasks in template

I really like the elegant simplicity achieved by your enum classes!

However, I got stuck on a problem using them in templates. The following code inspired by ATL CWinTraits fails. Any idea of a solution?

enum class ServiceHandler : uint16_t 
{
    accept_none                     = 0u,
    accept_stop                     = SERVICE_ACCEPT_STOP,
    accept_pausecontinue            = SERVICE_ACCEPT_PAUSE_CONTINUE,
    accept_shutdown                 = SERVICE_ACCEPT_SHUTDOWN,
    accept_paramchange              = SERVICE_ACCEPT_PARAMCHANGE,
    accept_netbindchange            = SERVICE_ACCEPT_NETBINDCHANGE,
    accept_hardwareprofilechange    = SERVICE_ACCEPT_HARDWAREPROFILECHANGE,
    accept_powerevent               = SERVICE_ACCEPT_POWEREVENT,
    accept_sessionchange            = SERVICE_ACCEPT_SESSIONCHANGE,
    accept_preshutdown              = SERVICE_ACCEPT_PRESHUTDOWN,
    accept_timechange               = SERVICE_ACCEPT_TIMECHANGE,
    accept_triggerevent             = SERVICE_ACCEPT_TRIGGEREVENT,
    accept_userlogoff               = SERVICE_ACCEPT_USER_LOGOFF,
    accept_lowresources             = SERVICE_ACCEPT_LOWRESOURCES,
    accept_systemlowresources       = SERVICE_ACCEPT_SYSTEMLOWRESOURCES
};
enableEnumClassBitmask(ServiceHandler);

template <ServiceHandler Taccepttraits = ServiceHandler::accept_none>
class ServiceAcceptTraits
{
public:
    ServiceHandler GetAcceptTraits(void) const noexcept  { return Taccepttraits; }
};
using StandardAcceptTraits = ServiceAcceptTraits<
      ServiceHandler::accept_stop
    | ServiceHandler::accept_pausecontinue
    | ServiceHandler::accept_shutdown>;

This is intended to be used like so:

template <
	class TderivedClass, 
	const wchar_t* Tservicename, 
	class TServiceAcceptTraits = StandardAcceptTraits>
class NO_VTABLE ServiceBase
{
};

compilation gives

error C2440: 'specialization': cannot convert from 'bitmask<ServiceHandler>' to 'ServiceHandler'

Problems using macro enableEnumClassBitmask within namespace

Hi,

I have a problem when declaring enableEnumClassBitmask within some namespace.

namespace sth
{
enum class masks
{
	MASK_1 = 0x01,
	...
};
enableEnumClassBitmask(masks);
}

Compilers (gcc/clang) complain about specializing struct enable_enum_class_bitmask in some other namespace than it was previously declared (global namespace, when #included).
Macro enableEnumClassBitmask should declare this specialization in the global namespace, but trying to use struct ::enable_enum_class_bitmask<T> also gives an error.
Any ideas how to solve that issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.