Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

The Windows Access Control Model: Part 2

, 27 Jun 2005 CPOL
This second part of the Access Control series will program with the basic Access Control structures.
boost.zip
boost
config
compiler
platform
stdlib
detail
mpl
aux_
config
preprocessed
bcc
bcc551
gcc
msvc60
msvc70
mwcw
no_ctps
no_ttp
plain
preprocessor
range_c
preprocessor
arithmetic
detail
array
comparison
config
control
detail
edg
msvc
detail
facilities
iteration
detail
bounds
iter
list
detail
edg
logical
punctuation
repetition
detail
edg
msvc
selection
seq
detail
slot
detail
tuple
regex
v3
test
detail
included
type_traits
detail
utility
userfun.zip
ATL
release
UserFun.exe
LowLevel
release
LowLevel.exe
2000
release
2000.exe
whoami.zip
Whoami
release
Whoami.exe
//-----------------------------------------------------------------------------
// boost mpl/aux_/template_arity.hpp header file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// Permission to use, copy, modify, distribute and sell this software
// and its documentation for any purpose is hereby granted without fee, 
// provided that the above copyright notice appears in all copies and 
// that both the copyright notice and this permission notice appear in 
// supporting documentation. No representations are made about the 
// suitability of this software for any purpose. It is provided "as is" 
// without express or implied warranty.

#if !defined(BOOST_PP_IS_ITERATING)

///// header body

#ifndef BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED
#define BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED

#include "boost/mpl/aux_/config/ttp.hpp"
#include "boost/mpl/aux_/config/lambda.hpp"

#if !defined(BOOST_MPL_PREPROCESSING_MODE)
#   include "boost/mpl/aux_/template_arity_fwd.hpp"
#   if !defined(BOOST_MPL_NO_FULL_LAMBDA_SUPPORT)
#   if defined(BOOST_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
#       include "boost/mpl/aux_/type_wrapper.hpp"
#   endif
#   else
#       include "boost/mpl/aux_/has_rebind.hpp"
#   endif
#endif

#include "boost/mpl/aux_/config/use_preprocessed.hpp"

#if !defined(BOOST_MPL_NO_PREPROCESSED_HEADERS) \
 && !defined(BOOST_MPL_PREPROCESSING_MODE)

#   define BOOST_MPL_PREPROCESSED_HEADER template_arity.hpp
#   include "boost/mpl/aux_/include_preprocessed.hpp"

#else

#   if !defined(BOOST_MPL_NO_FULL_LAMBDA_SUPPORT)
#   if defined(BOOST_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)

#   include "boost/mpl/limits/arity.hpp"
#   include "boost/mpl/aux_/config/nttp.hpp"
#   include "boost/mpl/aux_/preprocessor/range.hpp"
#   include "boost/mpl/aux_/preprocessor/repeat.hpp"
#   include "boost/mpl/aux_/preprocessor/params.hpp"

#   include "boost/preprocessor/seq/fold_left.hpp"
#   include "boost/preprocessor/comma_if.hpp"
#   include "boost/preprocessor/iterate.hpp"
#   include "boost/preprocessor/inc.hpp"
#   include "boost/preprocessor/cat.hpp"

namespace boost { namespace mpl { namespace aux {

template< BOOST_MPL_AUX_NTTP_DECL(int, N) > struct arity_tag
{
    typedef char (&type)[N + 1];
};

#define AUX_MAX_ARITY_OP(unused, state, i) \
    ( BOOST_PP_CAT(C,i) > 0 ? BOOST_PP_CAT(C,i) : state ) \
/**/

template<
      BOOST_MPL_PP_PARAMS(
          BOOST_MPL_METAFUNCTION_MAX_ARITY
        , BOOST_MPL_AUX_NTTP_DECL(int, C)
        )
    >
struct max_arity
{
    BOOST_STATIC_CONSTANT(int, value = 
          BOOST_PP_SEQ_FOLD_LEFT(
              AUX_MAX_ARITY_OP
            , -1
            , BOOST_MPL_PP_RANGE(1, BOOST_MPL_METAFUNCTION_MAX_ARITY)
            )
        );
};

#undef AUX_MAX_ARITY_OP

arity_tag<0> arity_helper(...);

#define BOOST_PP_ITERATION_LIMITS (1, BOOST_MPL_METAFUNCTION_MAX_ARITY)
#define BOOST_PP_FILENAME_1 "boost/mpl/aux_/template_arity.hpp"
#include BOOST_PP_ITERATE()

template< typename F, BOOST_MPL_AUX_NTTP_DECL(int, N) >
struct template_arity_impl
{
    BOOST_STATIC_CONSTANT(int, value = 
          sizeof(arity_helper(type_wrapper<F>(),arity_tag<N>())) - 1
        );
};

#define AUX_TEMPLATE_ARITY_IMPL_INVOCATION(unused, i, F) \
    BOOST_PP_COMMA_IF(i) template_arity_impl<F,BOOST_PP_INC(i)>::value \
/**/

template< typename F >
struct template_arity
{
    BOOST_STATIC_CONSTANT(int, value = (
          max_arity< BOOST_MPL_PP_REPEAT(
              BOOST_MPL_METAFUNCTION_MAX_ARITY
            , AUX_TEMPLATE_ARITY_IMPL_INVOCATION
            , F
            ) >::value
        ));
};

#undef AUX_TEMPLATE_ARITY_IMPL_INVOCATION

}}} // namespace boost::mpl::aux

#   endif // BOOST_EXTENDED_TEMPLATE_PARAMETERS_MATCHING
#   else // BOOST_MPL_NO_FULL_LAMBDA_SUPPORT

#   include "boost/mpl/aux_/config/eti.hpp"
#   include "boost/mpl/aux_/config/static_constant.hpp"
#   include "boost/mpl/aux_/config/workaround.hpp"

namespace boost { namespace mpl { namespace aux {

template< bool >
struct template_arity_impl
{
    template< typename F > struct result_
    {
        BOOST_STATIC_CONSTANT(int, value = -1);
    };
};

template<>
struct template_arity_impl<true>
{
    template< typename F > struct result_
    {
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x561 && !defined(BOOST_STRICT_CONFIG))
        enum { value = F::arity };
#else
        BOOST_STATIC_CONSTANT(int, value = F::arity);
#endif
    };
};

template< typename F >
struct template_arity
    : template_arity_impl< ::boost::mpl::aux::has_rebind<F>::value >
        ::template result_<F>
{
};

#if defined(BOOST_MPL_MSVC_ETI_BUG)
template<>
struct template_arity<int>
{
    BOOST_STATIC_CONSTANT(int, value = -1);
};
#endif

}}} // namespace boost::mpl::aux

#   endif // BOOST_MPL_NO_FULL_LAMBDA_SUPPORT

#endif // BOOST_MPL_USE_PREPROCESSED_HEADERS
#endif // BOOST_MPL_AUX_TEMPLATE_ARITY_HPP_INCLUDED

///// iteration

#else
#define i BOOST_PP_FRAME_ITERATION(1)

template<
      template< BOOST_MPL_PP_PARAMS(i, typename P) > class F
    , BOOST_MPL_PP_PARAMS(i, typename T)
    >
typename arity_tag<i>::type
arity_helper(type_wrapper< F<BOOST_MPL_PP_PARAMS(i, T)> >, arity_tag<i>);

#undef i
#endif // BOOST_PP_IS_ITERATING

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

oshah
Web Developer
United States United States
Mr. Shah is a reclusive C++/C# developer lurking somewhere in the depths of the city of London. He learnt physics at Kings' College London and obtained a Master in Science there. Having earned an MCAD, he teeters on the brink of transitioning from C++ to C#, unsure of which language to jump to. Fortunately, he also knows how to use .NET interop to merge code between the two languages (which means he won't have to make the choice anytime soon).
 
His interests (apart from programming) are walking, football (the real one!), philosophy, history, retro-gaming, strategy gaming, and any good game in general.
 
He maintains a website / blog / FAQ / junk at shexec32.serveftp.net, where he places the best answers he's written to the questions you've asked. If you can find him, maybe you can hire Mr. Shah to help you with anything C++[/CLI]/C#/.NET related Smile | :) .

| Advertise | Privacy | Mobile
Web03 | 2.8.141022.2 | Last Updated 27 Jun 2005
Article Copyright 2005 by oshah
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid