Boost logo

Boost Users :

Subject: Re: [Boost-users] [graph] how do i test at compile time if a Graph is directed or undirected?
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2011-10-28 13:33:43


On Fri, 28 Oct 2011, Christoph wrote:

> Ok, and how do i do the check?
>
> if i have a template funktion
>
> template <class Ugraph>
> foo (Ugraph &g)
> {
> // boost::graph_traits <Ugraph>::directed_category =
> boost::undirectedS ??
> }
>
> and i only want to have compiled foo without errors if and only if the
> Ugraph is an undirected graph, how do i inform the compiler?

BOOST_STATIC_ASSERT(
   boost::is_base_and_derived<
     typename boost::graph_traits<Ugraph>::directed_category,
     boost::undirectedS>::value);

-- Jeremiah Willcock

>
> best regards
> christoph
>
> On Fri, 2011-10-28 at 10:43 -0400, Jeremiah Willcock wrote:
>> On Fri, 28 Oct 2011, Christoph wrote:
>>
>>> Hi,
>>>
>>> ist it possible to test at compile time if a graph is directed or
>>> undirected?
>>> I would like the compiler to give an error message if the graph is
>>> directed.
>>
>> See directed_category in
>> <URL:http://www.boost.org/doc/libs/1_47_0/libs/graph/doc/Graph.html> for
>> the way to check.
>>
>> -- Jeremiah Willcock
>> _______________________________________________
>> Boost-users mailing list
>> Boost-users_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
> --
> Christoph <c_p_at_[hidden]>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net