Re: Get first and last iterator of a sequence where some condition is
true
On Feb 24, 10:03 am, Michael DOUBEZ <michael.dou...@free.fr> wrote:
Well, it cannot convert from const to non-const at least. Now I suppose
Resolution inherits from DisplayModeCapability.
Replace the signature with:
bool operator()(
const DisplayModeCapability & lhs,
const DisplayModeCapability& rhs
)const
{
if( lhs.m_resolution < rhs.m_resolution )
{
return true;
}
return false;
}
};
Nay, Resolution is simply a member of DisplayModeCapability
#ifndef RESOLUTION_H
#define RESOLUTION_H
// Standard Includes
#include <string>
//-------------------------------------------------------------------------=
-----------------
/**
* Resolution
**/
struct Resolution
{
Resolution(unsigned width, unsigned height);
Resolution(const Resolution & rhs);
~Resolution();
Resolution & operator = (const Resolution & rhs);
bool operator == (const Resolution & rhs) const;
bool operator != (const Resolution & rhs) const;
bool operator < (const Resolution & rhs) const;
bool operator > (const Resolution & rhs) const;
bool operator <= (const Resolution & rhs) const;
bool operator >= (const Resolution & rhs) const;
/**
* Forms a string of form "WidthXHeight"
**/
const std::string AsString() const;
unsigned m_width;
unsigned m_height;
};
#endif
-------------------------------------------------------------
#ifndef BASEDISPLAYATTRIBUTES_H
#define BASEDISPLAYATTRIBUTES_H
// EngineX Includes
#include "Resolution.h"
// Windows Includes
#include <dxgi.h>
//-------------------------------------------------------------------------=
-----------------
/**
* This structure is not intended for use.
* It is only provided as a common set of attributes to inherit from.
**/
struct BaseDisplayAttributes
{
BaseDisplayAttributes(const unsigned adapterIndex,
const unsigned monitorIndex,
const Resolution & resolution,
const DXGI_FORMAT format,
const unsigned refreshRateNumerator,
const unsigned refreshRateDenominator);
BaseDisplayAttributes(const BaseDisplayAttributes & rhs);
~BaseDisplayAttributes();
BaseDisplayAttributes & operator = (const BaseDisplayAttributes &
rhs);
bool operator == (const BaseDisplayAttributes & rhs);
bool operator != (const BaseDisplayAttributes & rhs);
unsigned m_adapterIndex;
unsigned m_monitorIndex;
Resolution m_resolution;
DXGI_FORMAT m_backbufferFormat;
unsigned m_refreshRateNumerator;
unsigned m_refreshRateDenominator;
};
#endif
-------------------------------------------------------------
#ifndef DISPLAYMODECAPABILITY_H
#define DISPLAYMODECAPABILITY_H
// EngineX Includes
#include "DisplayMode.h"
#include "BaseDisplayAttributes.h"
// Windows Includes
#include <dxgi.h>
//-------------------------------------------------------------------------=
-----------------
/**
* Display mode capability
**/
struct DisplayModeCapability : public BaseDisplayAttributes
{
DisplayModeCapability(const unsigned adapterIndex,
const unsigned monitorIndex,
const Resolution & resolution,
const DXGI_FORMAT backbufferFormat,
const unsigned refreshRateNumerator,
const unsigned refreshRateDenominator);
DisplayModeCapability(const DisplayModeCapability & rhs);
~DisplayModeCapability();
DisplayModeCapability & operator = (const DisplayModeCapability &
rhs);
bool operator == (const DisplayModeCapability & rhs);
bool operator != (const DisplayModeCapability & rhs);
/**
* Query whether a display mode is acceptable for use according to
this display mode capabilty
**/
bool CompareDisplayMode(const DisplayMode & displayMode);
};
#endif
-----------------------------------------------------------