aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/store-cast.hh
blob: ff62fc3593ef462f48e420941d699875e9a315d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#pragma once

#include "store-api.hh"

namespace nix {

template<typename T>
T & require(Store & store)
{
    auto * castedStore = dynamic_cast<T *>(&store);
    if (!castedStore)
        throw UsageError("%s not supported by store '%s'", T::operationName, store.getUri());
    return *castedStore;
}

}