*** empty log message ***

[SVN r27671]
This commit is contained in:
Thorsten Jørgen Ottosen
2005-03-15 16:00:19 +00:00
parent bf5ca9612c
commit 4524abb615
3 changed files with 71 additions and 24 deletions

View File

@ -15,38 +15,47 @@
# pragma once
#endif
#include <mfc/include/afxtempl.h> // for CArray
#include <afxtempl.h> // for CArray
#include <boost/range/config.hpp>
#include <boost/range/metafunctions.hpp>
namespace boost
{
template< class T, class U >
struct iterator_of< CArray<T,U> >
struct range_iterator< CArray<T,U> >
{
typedef T* type;
};
//
// Why is this needed?!?
//
template< class T, class U >
struct range_iterator< const CArray<T,U> >
{
typedef T* type;
};
template< class T, class U >
struct const_iterator_of< CArray<T,U> >
struct range_const_iterator< CArray<T,U> >
{
typedef const T* type;
};
template< class T, class U >
struct difference_type_of< CArray<T,U> >
struct range_difference< CArray<T,U> >
{
typedef std::ptrdiff_t type;
};
template< class T, class U >
struct size_type_of< CArray<T,U> >
struct range_size< CArray<T,U> >
{
typedef int type;
};
template< class T, class U >
struct value_type_of< CArray<T,U> >
struct range_value< CArray<T,U> >
{
typedef T type;
};

View File

@ -17,43 +17,57 @@
#include <afx.h> // for CString
#include <boost/range/config.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/range/metafunctions.hpp>
namespace boost
{
struct iterator_of< CString >
template<>
struct range_iterator< CString >
{
typedef TCHAR* type;
};
struct const_iterator_of< CString >
//
// Why is this needed?!?
//
template<>
struct range_iterator< const CString >
{
typedef TCHAR* type;
};
template<>
struct range_const_iterator< CString >
{
typedef const TCHAR* type;
};
struct difference_type_of< CString >
template<>
struct range_difference< CString >
{
typedef std::ptrdiff_t type;
};
struct size_type_of< CString >
template<>
struct range_size< CString >
{
typedef int type;
};
struct value_type_of< CString >
template<>
struct range_value< CString >
{
typedef TCHAR type;
};
TCHAR* begin( CString& r )
{
return &r[0];
return r.GetBuffer(0);
}
const TCHAR* begin( const CString& r )
{
return &r[0];
return (LPCTSTR)r;
}
int size( const CString& r )
@ -61,12 +75,12 @@ namespace boost
return r.GetLength();
}
T* end( CString& r )
TCHAR* end( CString& r )
{
return begin( r ) + size( r );
}
const T* end( const CString& r )
const TCHAR* end( const CString& r )
{
return begin( r ) + size( r );
}

View File

@ -18,6 +18,18 @@
#endif
#define BOOST_RANGE_ENABLE_MFC
#define BOOST_RANGE_ENABLE_MCF_CARRAY
/*
#define WIN32
#define _WINDOWS
#define _MBCS
#define _AFXDLL
#define _ATL_DLL
*/
///Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_MBCS" /D "_AFXDLL" /D "_ATL_DLL" /Gm /EHsc /RTC1
// /MDd /Zc:wchar_t /Yu"stdafx.h" /Fp"Debug/Foo.pch" /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /nologo /c /Wp64 /ZI /TP
#include <boost/range.hpp>
#include <boost/range/detail/mfc/carray.hpp>
@ -25,9 +37,6 @@
#include <boost/test/test_tools.hpp>
#include <boost/config.hpp>
#include <vector>
#include <fstream>
#include <algorithm>
void check_mfc()
@ -36,7 +45,22 @@ void check_mfc()
BOOST_CHECK( boost::begin( s ) + boost::size( s ) == boost::end( s ) );
BOOST_CHECK( boost::size( s ) == boost::size( "hello world" ) );
BOOST_CHECK( !boost::empty( s ) );
const CString cs( s );
BOOST_CHECK( boost::begin( cs ) + boost::size( cs ) == boost::end( cs ) );
BOOST_CHECK( boost::size( cs ) == boost::size( "hello world" ) );
BOOST_CHECK( !boost::empty( cs ) );
CArray<int,int> a;
BOOST_CHECK( boost::empty( a ) );
a.Add( 5 );
a.Add( 10 );
BOOST_CHECK( boost::begin( a ) + boost::size( a ) == boost::end( a ) );
BOOST_CHECK( boost::size( a ) == 2 );
BOOST_CHECK( !boost::empty( a ) );
const CArray<int,int>& ca = a;
BOOST_CHECK( boost::begin( ca ) + boost::size( ca ) == boost::end( ca ) );
BOOST_CHECK( boost::size( ca ) == 2 );
BOOST_CHECK( !boost::empty( ca ) );
}