3 * Copyright (c) 1998-2000
6 * Permission to use, copy, modify, distribute and sell this software
7 * and its documentation for any purpose is hereby granted without fee,
8 * provided that the above copyright notice appear in all copies and
9 * that both that copyright notice and this permission notice appear
10 * in supporting documentation. Dr John Maddock makes no representations
11 * about the suitability of this software for any purpose.
12 * It is provided "as is" without express or implied warranty.
17 * LOCATION: see http://www.boost.org for most recent version.
18 * FILE regex_config.hpp
20 * DESCRIPTION: auto-configure options for regular expression code.
23 #ifndef BOOST_REGEX_CONFIG_HPP
24 #define BOOST_REGEX_CONFIG_HPP
26 /************************************************************************
28 The purpose of this header is to provide compiler and STL configuration
29 options. Options fall into three categaries (namespaces, compiler and STL),
30 throughout, the defaults assume that the compiler and STL are fully C++ standard
31 compliant, features that are not supported on your system may be selectively
32 turned off by defining the appropriate macros. Borland C++, Borland C++ Builder,
33 and Microsoft Visual C++ should be auto-recognised and configured. The HP aCC and
34 SunPro C++ compiler should also be supported - but run configure for best results.
35 The SGI, HP, Microsoft and Rogue Wave STL's should be auto-recognised and configured.
36 Do not change this file unless you really really have to, add options to
37 <boost/re_detail/_opt.h> instead. See <jm_opt.h> for a full list of macros and their usage.
39 ************************************************************************/
42 #include <boost/config.h>
44 #include <boost/re_detail/regex_options.hpp>
54 #include <boost/smart_ptr.hpp>
58 // don't include <boost/config.hpp> because that may
59 // do C++ specific things in future...
63 #define BOOST_MSVC _MSC_VER
67 /* this will increase in future versions: */
68 #define BOOST_RE_VERSION 300
71 #if defined(_UNICODE) && !defined(UNICODE)
75 #ifndef BOOST_RE_AUTO_CONFIGURE
76 #if (defined(__WIN32__) || defined(_WIN32) || defined(WIN32)) && !defined(__GNUC__)
77 #define BOOST_RE_PLATFORM_W32
81 // no std::maessages facet
82 #define BOOST_RE_NO_MESSAGES
87 #if __BORLANDC__ < 0x500
88 #define BOOST_RE_NO_NAMESPACES
89 #define BOOST_RE_NO_BOOL
90 #define BOOST_RE_NO_MUTABLE
93 #if __BORLANDC__ < 0x520
94 #define BOOST_RE_NO_WCSTRING
95 #define BOOST_RE_NO_INT64
96 // Early versions of Borlands namespace code can't cope with iterators
97 // that are in different namespaces from STL code.
99 #define BOOST_RE_NO_NOT_EQUAL
102 #if __BORLANDC__ < 0x530
103 #define BOOST_RE_NO_WCTYPE_H
104 #define BOOST_RE_NO_WCHAR_H
105 #define BOOST_RE_OLD_IOSTREAM
106 #define BOOST_RE_NO_TRICKY_DEFAULT_PARAM
107 #define BOOST_RE_NO_EXCEPTION_H
109 #define BOOST_RE_NO_WCSTRING
111 #define BOOST_RE_NO_LOCALE_H
112 #define BOOST_RE_NO_TEMPLATE_RETURNS
114 // this is a hack to get around buggy namespace support in the
115 // 0x520 compiler version
116 #define BOOST_RE_NO_USING
117 #define BOOST_RE_USING_HACK
118 #define BOOST_RE_OLD_IOSTREAM
121 #if __BORLANDC__ < 0x540
122 #define BOOST_RE_NO_MEMBER_TEMPLATES
123 // inline contructors exhibit strange behaviour
124 // under Builder 3 and C++ 5.x when throwing exceptions
125 #define INLINE_EXCEPTION_BUG
126 #define BOOST_RE_NESTED_TEMPLATE_DECL
127 #define BOOST_RE_NO_PARTIAL_FUNC_SPEC
128 #define BOOST_RE_NO_STRING_DEF_ARGS
129 #define BOOST_RE_NO_TYPEINFO // bad_cast etc not in namespace std.
132 // Builder 4 seems to have broken template friend support:
133 #define BOOST_RE_NO_TEMPLATE_FRIEND
135 #if (__BORLANDC__ == 0x550) || (__BORLANDC__ == 0x551)
136 // problems with std::basic_string and dll RTL:
137 #if defined(_RTLDLL) && defined(_RWSTD_COMPILE_INSTANTIATE)
138 #ifdef BOOST_RE_BUILD_DLL
139 #error _RWSTD_COMPILE_INSTANTIATE must not be defined when building regex++ as a DLL
141 #pragma warn defining _RWSTD_COMPILE_INSTANTIATE when linking to the DLL version of the RTL may produce memory corruption problems in std::basic_string, as a result of separate versions of basic_string's static data in the RTL and you're exe/dll: be warned!!
145 // this is harmless for a staic link:
146 #define _RWSTD_COMPILE_INSTANTIATE
151 #error exception handling support required
155 #define BOOST_RE_PLATFORM_WINDOWS
157 #define BOOST_RE_PLATFORM_DOS
161 #define BOOST_RE_CALL
162 #define BOOST_RE_CCALL
164 #define BOOST_RE_CALL __fastcall
165 #define BOOST_RE_CCALL __stdcall
168 #define BOOST_RE_INT64t __int64
169 #define BOOST_RE_IMM64(val) val##i64
170 #define BOOST_RE_NO_CAT
171 // broken wide character support:
172 #define BOOST_RE_NO_SWPRINTF
175 #define BOOST_RE_THREADS
180 // if we're building a console app then there can't be any VCL (can there?)
181 #if !defined(__CONSOLE__) && !defined(_NO_VCL)
182 #define BOOST_RE_USE_VCL
185 // import export options:
187 #ifdef BOOST_RE_BUILD_DLL
188 #define BOOST_RE_IX_DECL __declspec( dllexport )
189 #elif !defined(BOOST_REGEX_LIBRARY_INCLUDE_HPP) && !defined(BOOST_RE_NO_LIB)
190 #define BOOST_RE_IX_DECL __declspec( dllimport )
193 #include <boost/re_detail/regex_library_include.hpp>
201 // only want "real" Visual C++ here:
202 #if defined(BOOST_MSVC) && !defined(__WATCOMC__) && !defined(__BORLANDC__) && !defined(__GNUC__) && !defined(__MWERKS__) && !defined (__ICL)
203 #define BOOST_RE_CALL __fastcall
204 #define BOOST_RE_CCALL __stdcall
206 #if BOOST_MSVC < 1100
207 #define BOOST_RE_NO_NAMESPACES
208 #define BOOST_RE_NO_DEFAULT_PARAM
209 #define BOOST_RE_NO_BOOL
210 #define BOOST_RE_NO_MUTABLE
211 #define BOOST_RE_NO_WCSTRING
212 #define BOOST_RE_NO_LOCALE_H
213 #define BOOST_RE_NO_TEMPLATE_RETURNS
214 #define BOOST_RE_NO_INT64
217 #if BOOST_MSVC < 1200
218 #define BOOST_RE_NESTED_TEMPLATE_DECL
219 #define BOOST_RE_NO_STRING_DEF_ARGS
222 #if !defined(_CPPUNWIND) && defined(__cplusplus)
223 #error exception handling support required
226 #define BOOST_RE_PLATFORM_WINDOWS
228 // no support for nested template classes yet....
229 // although this part of VC6 is badly documented
230 #define BOOST_RE_NO_MEMBER_TEMPLATES
231 #define BOOST_RE_INT64t __int64
232 #define BOOST_RE_IMM64(val) val##i64
233 #define BOOST_RE_NO_CAT
234 #define BOOST_RE_NO_PARTIAL_FUNC_SPEC
235 #define BOOST_RE_NO_TEMPLATE_FRIEND
236 #define BOOST_RE_NO_SWPRINTF
239 #define BOOST_RE_THREADS
246 #pragma warning(disable: 4786)
247 #pragma warning(disable: 4800)
248 #pragma warning(disable: 4200)
249 #pragma warning(disable: 4097)
250 #pragma warning(disable: 4127)
253 // import export options:
255 #ifdef BOOST_RE_BUILD_DLL
256 #define BOOST_RE_IX_DECL __declspec( dllexport )
257 #elif !defined(BOOST_REGEX_LIBRARY_INCLUDE_HPP) && !defined(BOOST_RE_NO_LIB)
258 #define BOOST_RE_IX_DECL __declspec( dllimport )
261 #include <boost/re_detail/regex_library_include.hpp>
266 #if (__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ < 91))
267 #define BOOST_RE_NO_NAMESPACES
268 #define BOOST_RE_NO_MUTABLE
269 #define BOOST_RE_NO_MEMBER_TEMPLATES
270 #define BOOST_RE_NO_PARTIAL_FUNC_SPEC
271 #define BOOST_RE_NO_TEMPLATE_FRIEND
273 #ifndef __STL_USE_NAMESPACES
274 //#define BOOST_RE_NO_EXCEPTION_H
276 #define BOOST_RE_INT64t long long
277 #define BOOST_RE_IMM64(val) val##LL
280 /* there seems to be a problem with <windows.h> in gcc */
281 #define BOOST_RE_LOCALE_C
282 #define BOOST_RE_NO_W32
283 #define BOOST_RE_NO_WCTYPE_H
284 #define BOOST_RE_NO_TEMPLATE_SWITCH_MERGE
286 #define BOOST_RE_NO_CAT
287 #define BOOST_RE_NESTED_TEMPLATE_DECL
288 #define BOOST_RE_NO_SWPRINTF
291 #define BOOST_RE_NO_WCSTRING
294 // for now we'll always define these
295 // unless we know that the platform can cope
296 // with woide character strings:
298 #define BOOST_RE_NO_WCTYPE_H
299 #define BOOST_RE_NO_WCSTRING
305 #define BOOST_RE_NO_CAT
309 #if (__SUNPRO_CC < 0x500)
310 #define BOOST_RE_NO_NAMESPACES
311 #define BOOST_RE_NO_MUTABLE
312 #define BOOST_RE_NO_MEMBER_TEMPLATES
313 #define BOOST_RE_OLD_IOSTREAM
315 #ifndef __STL_USE_NAMESPACES
316 #define BOOST_RE_NO_EXCEPTION_H
318 #define BOOST_RE_INT64t long long
319 #define BOOST_RE_IMM64(val) val##LL
320 #define BOOST_RE_NESTED_TEMPLATE_DECL
321 #define BOOST_RE_NO_SWPRINTF
322 #define BOOST_RE_NO_TEMPLATE_FRIEND
326 // putative HP aCC support, run configure for
327 // support tailored to your system....
328 #define BOOST_RE_NO_NAMESPACES
329 #define BOOST_RE_NO_MUTABLE
330 #define BOOST_RE_NO_MEMBER_TEMPLATES
331 #define BOOST_RE_OLD_IOSTREAM
332 #ifndef __STL_USE_NAMESPACES
333 #define BOOST_RE_NO_EXCEPTION_H
335 #define BOOST_RE_INT64t long long
336 #define BOOST_RE_IMM64(val) val##LL
337 #define BOOST_RE_NESTED_TEMPLATE_DECL
338 #define BOOST_RE_NO_TEMPLATE_FRIEND
339 #define BOOST_RE_NO_SWPRINTF
342 #ifdef __sgi // SGI IRIX C++
343 #define BOOST_RE_NO_SWPRINTF
344 #if defined(__SGI_STL_PORT)
345 // STLPort on IRIX is misconfigured: <cwctype> does not compile
346 // as a temporary fix include <wctype.h> instead and prevent inclusion
347 // of STLPort version of <cwctype>
349 #define __STLPORT_CWCTYPE
350 #define BOOST_RE_NO_WCTYPE_H
355 // Kai 3.4 appears to have no wide character string support:
356 # if __KCC_VERSION <= 3499
357 # define BOOST_RE_NO_WCSTRING
361 #endif // BOOST_RE_AUTO_CONFIGURE
364 #ifndef BOOST_RE_NO_WCSTRING
365 #ifndef BOOST_RE_NO_WCTYPE_H
368 #ifndef BOOST_RE_NO_WCHAR_H
374 #ifdef BOOST_RE_NO_NAMESPACES
375 #define BOOST_RE_MAYBE_ACCESS_SPEC ::
377 #define BOOST_RE_MAYBE_ACCESS_SPEC
380 #if !defined(BOOST_RE_INT64t) || !defined(BOOST_RE_IMM64)
381 #define BOOST_RE_NO_INT64
384 #ifndef BOOST_RE_INT32_LONG
385 typedef unsigned int jm_uintfast32_t;
387 typedef unsigned long jm_uintfast32_t;
390 #ifndef BOOST_RE_NESTED_TEMPLATE_DECL
391 #define BOOST_RE_NESTED_TEMPLATE_DECL template
394 #ifndef BOOST_RE_IX_DECL
395 #define BOOST_RE_IX_DECL
400 // better make a conservative guess!
401 #define MB_CUR_MAX 10
405 /* everything else is C++: */
409 /* define macro's to make default parameter declaration easier: */
411 #ifdef BOOST_RE_NO_DEFAULT_PARAM
412 #define BOOST_RE_DEFAULT_PARAM(x)
413 #define BOOST_RE_TRICKY_DEFAULT_PARAM(x)
414 #elif defined(BOOST_RE_NO_TRICKY_DEFAULT_PARAM)
415 #define BOOST_RE_DEFAULT_PARAM(x) = x
416 #define BOOST_RE_TRICKY_DEFAULT_PARAM(x)
418 #define BOOST_RE_DEFAULT_PARAM(x) = x
419 #define BOOST_RE_TRICKY_DEFAULT_PARAM(x) = x
422 /* STL configuration goes here: */
424 #ifndef BOOST_RE_AUTO_CONFIGURE
425 #ifdef BOOST_RE_NO_STL
426 #define BOOST_RE_NO_EXCEPTION_H
427 #define BOOST_RE_NO_ITERATOR_H
428 #define BOOST_RE_NO_MEMORY_H
429 #define BOOST_RE_NO_LOCALE_H
430 #define BOOST_RE_NO_STRING_H
433 #ifndef BOOST_RE_NO_EXCEPTION_H
437 #ifndef BOOST_RE_NO_ITERATOR_H
440 #if defined(__SGI_STL_INTERNAL_ITERATOR_H) || defined(__SGI_STL_ITERATOR_H)
442 /* we are using SGI's STL
446 # if !defined (__SGI_STL_OWN_IOSTREAMS) || defined (__STL_HAS_NO_NEW_IOSTREAMS) || defined (__STL_USE_NO_IOSTREAMS) || defined(__STL_NO_MBSTATE_T)
448 #define BOOST_RE_NO_LOCALE_H
449 #define BOOST_RE_OLD_IOSTREAM
451 #ifdef __STL_NO_EXPLICIT_FUNCTION_TMPL_ARGS
452 #define BOOST_RE_USE_FACET(l, m) (*std::_Use_facet<m >(l))
456 #define BOOST_RE_NO_WCSTRING
458 #if !defined(__STL_MEMBER_TEMPLATE_CLASSES) || !defined(__STL_MEMBER_TEMPLATES)
459 #define BOOST_RE_NO_MEMBER_TEMPLATES
461 #define BOOST_RE_NO_TYPEINFO
464 #define BOOST_RE_NO_BOOL
466 #ifdef __STL_LIMITED_DEFAULT_TEMPLATES
467 #define BOOST_RE_NO_TRICKY_DEFAULT_PARAM
468 #define BOOST_RE_NO_STRING_DEF_ARGS
470 #ifndef __STL_USE_EXCEPTIONS
471 #error exception handling support required
477 #define BOOST_RE_ALGO_INCLUDED
479 #define BOOST_RE_DISTANCE(i, j, n) do { n = 0; std::distance(i, j, n); } while(false)
480 #define BOOST_RE_OUTPUT_ITERATOR(T, D) std::output_iterator
481 #define BOOST_RE_INPUT_ITERATOR(T, D) std::input_iterator<T, D>
482 #define BOOST_RE_FWD_ITERATOR(T, D) std::forward_iterator<T, D>
483 #define BOOST_RE_BIDI_ITERATOR(T, D) std::bidirectional_iterator<T, D>
484 #define BOOST_RE_RA_ITERATOR(T, D) std::random_access_iterator<T, D>
486 #if defined(__STL_USE_STD_ALLOCATORS) || (defined(__SGI_STL_PORT ) && !defined(__STL_MEMBER_TEMPLATE_CLASSES) && !defined(__STL_MEMBER_TEMPLATES))
488 /* new style allocator's with nested template classes */
489 #undef BOOST_RE_NO_MEMBER_TEMPLATES
490 #define REBIND_INSTANCE(x, y, inst) y::BOOST_RE_NESTED_TEMPLATE_DECL rebind<x>::other(inst)
491 #define REBIND_TYPE(x, y) y::BOOST_RE_NESTED_TEMPLATE_DECL rebind<x>::other
492 #define BOOST_RE_DEF_ALLOC_PARAM(x) BOOST_RE_TRICKY_DEFAULT_PARAM( std::allocator<x> )
493 #define BOOST_RE_DEF_ALLOC(x) std::allocator<x>
495 #else /* __STL_USE_STD_ALLOCATORS */
496 #define BOOST_RE_OLD_ALLOCATORS
497 #define REBIND_INSTANCE(x, y, inst) BOOST_RE_MAYBE_ACCESS_SPEC boost::re_detail::re_alloc_binder<x, y>(inst)
498 #define REBIND_TYPE(x, y) BOOST_RE_MAYBE_ACCESS_SPEC re_alloc_binder<x, y>
499 #define BOOST_RE_DEF_ALLOC_PARAM(x) BOOST_RE_TRICKY_DEFAULT_PARAM( jm_def_alloc )
500 #define BOOST_RE_DEF_ALLOC(x) jm_def_alloc
501 #define BOOST_RE_NEED_BINDER
502 #define BOOST_RE_NEED_ALLOC
503 #endif /* __STL_USE_STD_ALLOCATORS */
505 #define BOOST_RE_STL_DONE
506 #ifndef __SGI_STL_PORT
507 //#define BOOST_RE_NO_NOT_EQUAL
510 #elif defined(__STD_ITERATOR__)
514 #if defined(RWSTD_NO_MEMBER_TEMPLATES) || defined(RWSTD_NO_MEM_CLASS_TEMPLATES)
515 #define BOOST_RE_NO_MEMBER_TEMPLATES
517 #ifdef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
518 #define BOOST_RE_NO_TEMPLATE_RETURNS
521 #ifdef RWSTD_NO_EXCEPTIONS
522 #error exception handling support required
525 #ifdef RWSTD_NO_MUTABLE
526 #define BOOST_RE_NO_MUTABLE
529 #ifdef RWSTD_NO_DEFAULT_TEMPLATES
530 #define BOOST_RE_NO_DEFAULT_PARAM
531 #define BOOST_RE_NO_TRICKY_DEFAULT_PARAM
532 #define BOOST_RE_NO_STRING_DEF_ARGS
535 #ifdef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
536 #define BOOST_RE_NO_TRICKY_DEFAULT_PARAM
537 #define BOOST_RE_NO_STRING_DEF_ARGS
541 #define BOOST_RE_NO_BOOL
544 #if _RWSTD_VER > 0x020000
545 #ifdef _RWSTD_NO_CLASS_PARTIAL_SPEC
546 #define BOOST_RE_DISTANCE(i, j, n) do { n = 0; std::distance(i, j, n); } while(false)
548 #define BOOST_RE_DISTANCE(i, j, n) (n = std::distance(i, j))
550 #define BOOST_RE_OUTPUT_ITERATOR(T, D) std::iterator<std::output_iterator_tag, T, D, T*, T&>
551 #define BOOST_RE_INPUT_ITERATOR(T, D) std::iterator<std::input_iterator_tag, T, D, T*, T&>
552 #define BOOST_RE_FWD_ITERATOR(T, D) std::iterator<std::forward_iterator_tag, T, D, T*, T&>
553 #define BOOST_RE_BIDI_ITERATOR(T, D) std::iterator<std::bidirectional_iterator_tag, T, D, T*, T&>
554 #define BOOST_RE_RA_ITERATOR(T, D) std::iterator<std::random_access_iterator_tag, T, D, T*, T&>
556 #define BOOST_RE_DISTANCE(i, j, n) std::distance(i, j, n)do { n = 0; std::distance(i, j, n); } while(false)
557 #define BOOST_RE_OUTPUT_ITERATOR(T, D) std::output_iterator
558 #if _RWSTD_VER >= 0x0200
559 #define BOOST_RE_INPUT_ITERATOR(T, D) std::input_iterator<T>
561 #define BOOST_RE_INPUT_ITERATOR(T, D) std::input_iterator<T, D>
563 #define BOOST_RE_FWD_ITERATOR(T, D) std::forward_iterator<T, D>
564 #define BOOST_RE_BIDI_ITERATOR(T, D) std::bidirectional_iterator<T, D>
565 #define BOOST_RE_RA_ITERATOR(T, D) std::random_access_iterator<T, D>
570 #ifdef _RWSTD_ALLOCATOR
572 /* new style allocator */
574 #define REBIND_INSTANCE(x, y, inst) y::BOOST_RE_NESTED_TEMPLATE_DECL rebind<x>::other(inst)
575 #define REBIND_TYPE(x, y) y::BOOST_RE_NESTED_TEMPLATE_DECL rebind<x>::other
576 #define BOOST_RE_DEF_ALLOC_PARAM(x) BOOST_RE_TRICKY_DEFAULT_PARAM( std::allocator<x> )
577 #define BOOST_RE_DEF_ALLOC(x) std::allocator<x>
581 // old style allocator
582 // this varies a great deal between versions, and there is no way
583 // that I can tell of differentiating between them, so use our
584 // own default allocator...
586 #define BOOST_RE_OLD_ALLOCATORS
587 #define REBIND_INSTANCE(x, y, inst) BOOST_RE_MAYBE_ACCESS_SPEC boost::re_detail::re_alloc_binder<x, y>(inst)
588 #define REBIND_TYPE(x, y) BOOST_RE_MAYBE_ACCESS_SPEC re_alloc_binder<x, y>
589 #define BOOST_RE_DEF_ALLOC_PARAM(x) BOOST_RE_TRICKY_DEFAULT_PARAM( jm_def_alloc )
590 #define BOOST_RE_DEF_ALLOC(x) jm_def_alloc
592 #define BOOST_RE_NEED_BINDER
593 #define BOOST_RE_NEED_ALLOC
597 #define BOOST_RE_STL_DONE
598 #if _RWSTD_VER < 0x020100
599 #define BOOST_RE_NO_OI_ASSIGN
602 #elif defined (ITERATOR_H)
606 #define BOOST_RE_NO_LOCALE_H
609 #define BOOST_RE_ALGO_INCLUDED
611 #define BOOST_RE_DISTANCE(i, j, n) std::distance(i, j, n)do { n = 0; std::distance(i, j, n); } while(false)
612 #define BOOST_RE_OUTPUT_ITERATOR(T, D) std::output_iterator
613 #define BOOST_RE_INPUT_ITERATOR(T, D) std::input_iterator<T, D>
614 #define BOOST_RE_FWD_ITERATOR(T, D) std::forward_iterator<T, D>
615 #define BOOST_RE_BIDI_ITERATOR(T, D) std::bidirectional_iterator<T, D>
616 #define BOOST_RE_RA_ITERATOR(T, D) std::random_access_iterator<T, D>
618 /* old style allocator */
619 #define BOOST_RE_OLD_ALLOCATORS
620 #define REBIND_INSTANCE(x, y, inst) BOOST_RE_MAYBE_ACCESS_SPEC boost::re_detail::re_alloc_binder<x, y>(inst)
621 #define REBIND_TYPE(x, y) BOOST_RE_MAYBE_ACCESS_SPEC re_alloc_binder<x, y>
622 #define BOOST_RE_DEF_ALLOC_PARAM(x) BOOST_RE_TRICKY_DEFAULT_PARAM( jm_def_alloc )
623 #define BOOST_RE_DEF_ALLOC(x) jm_def_alloc
625 #define BOOST_RE_NEED_BINDER
626 #define BOOST_RE_NEED_ALLOC
627 #define BOOST_RE_NO_NOT_EQUAL
629 #define BOOST_RE_STL_DONE
631 #elif defined (BOOST_MSVC)
633 /* assume we're using MS's own STL (VC++ 5/6) */
634 #define BOOST_RE_NO_OI_ASSIGN
636 #define BOOST_RE_DISTANCE(i, j, n) n = std::distance(i, j)
637 #define BOOST_RE_OUTPUT_ITERATOR(T, D) std::iterator<std::output_iterator_tag, T, D>
638 #define BOOST_RE_INPUT_ITERATOR(T, D) std::iterator<std::input_iterator_tag, T, D>
639 #define BOOST_RE_FWD_ITERATOR(T, D) std::iterator<std::forward_iterator_tag, T, D>
640 #define BOOST_RE_BIDI_ITERATOR(T, D) std::iterator<std::bidirectional_iterator_tag, T, D>
641 #define BOOST_RE_RA_ITERATOR(T, D) std::iterator<std::random_access_iterator_tag, T, D>
643 /* MS's allocators are rather ambiguous about their properties
644 at least as far as MSDN is concerned, so play safe: */
645 #define BOOST_RE_OLD_ALLOCATORS
646 #define REBIND_INSTANCE(x, y, inst) BOOST_RE_MAYBE_ACCESS_SPEC boost::re_detail::re_alloc_binder<x, y>(inst)
647 #define REBIND_TYPE(x, y) BOOST_RE_MAYBE_ACCESS_SPEC re_alloc_binder<x, y>
648 #define BOOST_RE_DEF_ALLOC_PARAM(x) BOOST_RE_TRICKY_DEFAULT_PARAM( jm_def_alloc )
649 #define BOOST_RE_DEF_ALLOC(x) jm_def_alloc
651 #define BOOST_RE_NEED_BINDER
652 #define BOOST_RE_NEED_ALLOC
654 #define BOOST_RE_STL_DONE
656 #define BOOST_RE_USE_FACET(l, type) std::use_facet(l, (type*)0, true)
657 #define BOOST_RE_HAS_FACET(l, type) std::has_facet(l, (type*)0)
659 #define BOOST_RE_USE_FACET(l, type) std::use_facet(l, (type*)0)
660 #define BOOST_RE_HAS_FACET(l, type) std::has_facet(l, (type*)0)
666 /* unknown STL version
669 // dwa 10/05/00 Why were we assuming a broken distance in this case?
670 #define BOOST_RE_DISTANCE(i, j, n) (n = std::distance(i, j))
671 /* these may be suspect for older libraries */
672 #define BOOST_RE_OUTPUT_ITERATOR(T, D) std::iterator<std::output_iterator_tag, T, D, T*, T&>
673 #define BOOST_RE_INPUT_ITERATOR(T, D) std::iterator<std::input_iterator_tag, T, D, T*, T&>
674 #define BOOST_RE_FWD_ITERATOR(T, D) std::iterator<std::forward_iterator_tag, T, D, T*, T&>
675 #define BOOST_RE_BIDI_ITERATOR(T, D) std::iterator<std::bidirectional_iterator_tag, T, D, T*, T&>
676 #define BOOST_RE_RA_ITERATOR(T, D) std::iterator<std::random_access_iterator_tag, T, D, T*, T&>
678 #endif /* <iterator> config */
680 #else /* no <iterator> at all */
682 #define BOOST_RE_DISTANCE(i, j, n) (n = j - i)
683 #define BOOST_RE_OUTPUT_ITERATOR(T, D) boost::re_detail::dummy_iterator_base<T>
684 #define BOOST_RE_INPUT_ITERATOR(T, D) boost::re_detail::dummy_iterator_base<T>
685 #define BOOST_RE_FWD_ITERATOR(T, D) boost::re_detail::dummy_iterator_base<T>
686 #define BOOST_RE_BIDI_ITERATOR(T, D) boost::re_detail::dummy_iterator_base<T>
687 #define BOOST_RE_RA_ITERATOR(T, D) boost::re_detail::dummy_iterator_base<T>
692 /* now do allocator if not already done */
694 #ifndef BOOST_RE_STL_DONE
696 #ifdef BOOST_RE_NO_MEMORY_H
698 /* old style allocator */
700 #define BOOST_RE_OLD_ALLOCATORS
702 #define REBIND_INSTANCE(x, y, inst) BOOST_RE_MAYBE_ACCESS_SPEC boost::re_detail::re_alloc_binder<x, y>(inst)
703 #define REBIND_TYPE(x, y) BOOST_RE_MAYBE_ACCESS_SPEC re_alloc_binder<x, y>
704 #define BOOST_RE_DEF_ALLOC_PARAM(x) BOOST_RE_TRICKY_DEFAULT_PARAM( jm_def_alloc )
705 #define BOOST_RE_DEF_ALLOC(x) jm_def_alloc
707 #define BOOST_RE_NEED_BINDER
708 #define BOOST_RE_NEED_ALLOC
712 /* new style allocator's with nested template classes */
714 #define REBIND_INSTANCE(x, y, inst) y::BOOST_RE_NESTED_TEMPLATE_DECL rebind<x>::other(inst)
715 #define REBIND_TYPE(x, y) y::BOOST_RE_NESTED_TEMPLATE_DECL rebind<x>::other
716 #define BOOST_RE_DEF_ALLOC_PARAM(x) BOOST_RE_TRICKY_DEFAULT_PARAM( std::allocator<x> )
717 #define BOOST_RE_DEF_ALLOC(x) std::allocator<x>
722 #endif // BOOST_RE_AUTO_CONFIGURE
726 /* namespace configuration goes here: */
727 #define BOOST_RE_USING(x) using namespace x;
730 /* locale configuration goes here */
731 #if !defined(BOOST_RE_NO_LOCALE_H)
733 #define LOCALE_INSTANCE(i) std::locale i;
734 #define MAYBE_PASS_LOCALE(i) , i
735 #ifndef BOOST_RE_NO_TEMPLATE_RETURNS
736 #ifndef BOOST_RE_USE_FACET
737 #define BOOST_RE_USE_FACET(l, type) std::use_facet< type >(l)
739 #ifndef BOOST_RE_HAS_FACET
740 #define BOOST_RE_HAS_FACET(l, type) std::has_facet< type >(l)
743 #ifndef BOOST_RE_USE_FACET
744 #define BOOST_RE_USE_FACET(l, type) std::use_facet(l, (type*)0)
746 #ifndef BOOST_RE_HAS_FACET
747 #define BOOST_RE_HAS_FACET(l, type) std::has_facet(l, (type*)0)
751 #define LOCALE_INSTANCE(i)
752 #define MAYBE_PASS_LOCALE(i)
755 /* compiler configuration goes here: */
757 #ifdef BOOST_RE_NO_MUTABLE
758 #define BOOST_RE_MUTABLE
760 #define BOOST_RE_MUTABLE mutable
763 #if defined( BOOST_RE_NO_BOOL) && !defined(bool)
769 #ifndef BOOST_RE_CALL
770 #define BOOST_RE_CALL
773 #ifndef BOOST_RE_CCALL
774 #define BOOST_RE_CCALL
777 #ifndef BOOST_RE_DECL
778 #define BOOST_RE_DECL
781 #if defined(BOOST_RE_NO_DEFAULT_PARAM) || defined(BOOST_RE_NO_TRICKY_DEFAULT_PARAM)
782 #define BOOST_RE_NO_STRING_DEF_ARGS
787 /* add our class def's if they are needed: */
793 #if __BORLANDC__ == 0x530
794 #pragma option push -a4 -b
795 #elif __BORLANDC__ > 0x530
796 #pragma option push -a8 -b
800 // add our destroy functions:
803 inline void BOOST_RE_CALL jm_destroy(T* t)
806 (void)t; // suppress incorrect MSVC compiler warning
809 inline void BOOST_RE_CALL jm_destroy(char* t){}
810 inline void BOOST_RE_CALL jm_destroy(short* t){}
811 inline void BOOST_RE_CALL jm_destroy(unsigned short* t){}
812 inline void BOOST_RE_CALL jm_destroy(int* t){}
813 inline void BOOST_RE_CALL jm_destroy(unsigned int* t){}
814 inline void BOOST_RE_CALL jm_destroy(long* t){}
815 inline void BOOST_RE_CALL jm_destroy(unsigned long* t){}
819 inline void BOOST_RE_CALL jm_construct(void* p, const T& t)
825 template<class T, class Allocator>
826 class re_alloc_binder : public Allocator
829 typedef T value_type;
831 typedef const T* const_pointer;
832 typedef T& reference;
833 typedef const T& const_reference;
834 typedef std::size_t size_type;
835 typedef std::ptrdiff_t difference_type;
837 re_alloc_binder(const Allocator& i);
838 re_alloc_binder(const re_alloc_binder& o) : Allocator(o) {}
840 T* BOOST_RE_CALL allocate(std::size_t n, std::size_t /* hint */ = 0)
841 { return 0 == n ? 0 : (T*) this->Allocator::allocate(n * sizeof(T)); }
842 void BOOST_RE_CALL deallocate(T *p, std::size_t n)
843 { if (0 != n) this->Allocator::deallocate((char*)p, n * sizeof (T)); }
845 pointer BOOST_RE_CALL address(reference x) const { return &x; }
846 const_pointer BOOST_RE_CALL address(const_reference x) const { return &x; }
847 static size_type BOOST_RE_CALL max_size() { return (size_type)-1; }
848 static void BOOST_RE_CALL construct(pointer p, const T& val) { jm_construct(p, val); }
849 void BOOST_RE_CALL destroy(pointer p) { jm_destroy(p); }
851 const Allocator& BOOST_RE_CALL instance()const { return *this; }
853 #ifndef BOOST_RE_NO_MEMBER_TEMPLATES
858 typedef re_alloc_binder<U, Allocator> other;
862 BOOST_RE_CALL re_alloc_binder(const re_alloc_binder<U, Allocator>& o) throw()
863 : Allocator(o.instance())
869 template<class T, class Allocator>
870 inline re_alloc_binder<T, Allocator>::re_alloc_binder(const Allocator &i)
876 // class jm_def_alloc
877 // basically a standard allocator that only allocates bytes...
878 // think of it as allocator<char>, with a non-standard
879 // rebind::other typedef.
884 typedef char value_type;
885 typedef char* pointer;
886 typedef const char* const_pointer;
887 typedef char& reference;
888 typedef const char& const_reference;
889 typedef std::size_t size_type;
890 typedef std::ptrdiff_t difference_type;
892 pointer BOOST_RE_CALL address(reference x) const { return &x; }
893 const_pointer BOOST_RE_CALL address(const_reference x) const { return &x; }
894 static size_type BOOST_RE_CALL max_size() { return (size_type)-1; }
895 static void BOOST_RE_CALL construct(pointer , const char& ) { }
896 void BOOST_RE_CALL destroy(pointer ) { }
897 static void * BOOST_RE_CALL allocate(std::size_t n, std::size_t /* hint */ = 0)
899 return ::operator new(n);
901 static void BOOST_RE_CALL deallocate(void *p, std::size_t /*n*/ )
903 ::operator delete(p);
906 #ifndef BOOST_RE_NO_MEMBER_TEMPLATES
910 typedef re_alloc_binder<U, jm_def_alloc> other;
914 BOOST_RE_CALL jm_def_alloc(const re_alloc_binder<U, jm_def_alloc>& ) throw() { }
916 jm_def_alloc(const jm_def_alloc&) {}
921 struct dummy_iterator_base
923 typedef T value_type;
924 typedef std::ptrdiff_t difference_type;
926 typedef T& reference;
927 //typedef Category iterator_category;
930 // we need to absolutely sure that int values are correctly
931 // translated to bool (true or false) values...
932 // note that the original HP STL redefines the bool type regardless
933 // of whether the compiler supports it.... yuk
935 #if defined(BOOST_RE_NO_BOOL) || defined(ITERATOR_H) || defined(bool)
936 #define BOOST_RE_MAKE_BOOL(x) boost::re_detail::boolify(x)
939 inline bool BOOST_RE_CALL boolify(I val)
941 return val ? true : false;
945 #define BOOST_RE_MAKE_BOOL(x) x
949 #if __BORLANDC__ > 0x520
954 } // namespace re_detail
955 #ifdef BOOST_RE_NEED_BINDER
956 using re_detail::re_alloc_binder;
958 #ifdef BOOST_RE_NEED_ALLOC
959 using re_detail::jm_def_alloc;
964 #define INLINE_EXCEPTION_BUG
967 #if !defined(INLINE_EXCEPTION_BUG) || defined(BOOST_RE_NO_TEMPLATE_MERGE)
968 #define CONSTRUCTOR_INLINE inline
970 #define CONSTRUCTOR_INLINE
973 #if defined(BOOST_RE_PLATFORM_W32) && !defined(BOOST_RE_LOCALE_W32) && !defined(BOOST_RE_LOCALE_C) && !defined(BOOST_RE_LOCALE_CPP) && !defined(BOOST_RE_NO_W32)
974 #define BOOST_RE_LOCALE_W32
977 #if !defined(BOOST_RE_LOCALE_W32) && !defined(BOOST_RE_LOCALE_C) && !defined(BOOST_RE_LOCALE_CPP)
978 #define BOOST_RE_LOCALE_C
981 #if defined(BOOST_RE_OLD_ALLOCATORS)
982 #define BOOST_RE_MAYBE_TYPENAME
984 #define BOOST_RE_MAYBE_TYPENAME typename
987 #if defined(_WIN32) && !defined(BOOST_RE_NO_W32)
992 /* now do debugging stuff: */
994 #ifdef BOOST_RE_DEBUG
996 #ifdef BOOST_RE_OLD_IOSTREAM
997 #include <iostream.h>
1009 #define jm_assert(x) if((x) == 0){ cerr << "Assertion failed: " << #x << " in file " << __FILE__ << "and line " << __LINE__ << endl; exit(-1); }
1012 #define jm_trace(x) cerr << x << endl;
1014 #ifndef jm_instrument
1015 #define jm_instrument jm_trace(__FILE__<<"#"<<__LINE__)
1019 namespace re_detail{
1029 debug_guard(const char* f, int l, const char* p1 = 0, char* p2 = 0);
1033 #define BOOST_RE_GUARD_STACK boost::re_detail::debug_guard sg(__FILE__, __LINE__);
1034 #define BOOST_RE_GUARD_GLOBAL(x) const char g1##x[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, }; char g2##x[32]; boost::debug_guard g3##x(__FILE__, __LINE__, g1##x, g2##x);
1036 } // namespace re_detail
1037 } // namespace boost
1040 #pragma message "macro allocator: " BOOST_RE_DEF_ALLOC_PARAM(wchar_t)
1041 #pragma message "macro jm_input_iterator: " BOOST_RE_INPUT_ITERATOR(char, std::ptrdiff_t)
1042 #pragma message "macro jm_output_iterator: " BOOST_RE_OUTPUT_ITERATOR(char, std::ptrdiff_t)
1043 #pragma message "macro jm_fwd_iterator: " BOOST_RE_FWD_ITERATOR(char, std::ptrdiff_t)
1044 #pragma message "macro jm_bidi_iterator: " BOOST_RE_BIDI_ITERATOR(char, std::ptrdiff_t)
1045 #pragma message "macro jm_ra_iterator: " BOOST_RE_RA_ITERATOR(char, std::ptrdiff_t)
1046 #ifdef BOOST_RE_LOCALE_CPP
1047 #pragma message "locale support enabled"
1053 #define jm_assert(x)
1055 #define BOOST_RE_GUARD_STACK
1056 #define BOOST_RE_GUARD_GLOBAL(x)
1057 #ifndef jm_instrument
1058 #define jm_instrument
1067 // fix for namespace problems:
1069 // the following are defined as macros which are
1070 // incompatable with std::something syntax, no
1071 // choice but to undef them?
1167 #if defined(BOOST_NO_STDC_NAMESPACE) || (defined(std) && defined(__SGI_STL_PORT))
1170 // note that we almost always do this for STLPort, as it doesn't always
1171 // catch all the wide character functions:
1196 #ifndef BOOST_RE_NO_WCSTRING
1197 #ifndef BOOST_RE_NO_SWPRINTF
1215 #if !defined(BOOST_RE_NO_LOCALE_H) && !defined (__STL_NO_NATIVE_MBSTATE_T)
1224 #endif // BOOST_RE_NO_WCSTRING
1229 #if defined(__SGI_STL_PORT) && defined(BOOST_MSVC) && !defined(_MT) && (__SGI_STL_PORT >= 0x400)
1230 #error STLPort libraries require multithread support to be turned on.
1234 #endif /* __cplusplus */
1236 #ifndef BOOST_RE_CALL
1237 #define BOOST_RE_CALL
1240 #ifndef BOOST_RE_CCALL
1241 #define BOOST_RE_CCALL
1244 #ifndef BOOST_RE_DECL
1245 #define BOOST_RE_DECL
1249 #endif // BOOST_REGEX_CONFIG_HPP